Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[embedder] Document make_resource_current on FlutterOpenGLRendererConfig and warn if the callback is not set. #7648

Merged
merged 1 commit into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions shell/platform/embedder/embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ typedef struct {
BoolCallback clear_current;
BoolCallback present;
UIntCallback fbo_callback;
// This is an optional callback. Flutter will ask the emebdder to create a GL
// context current on a background thread. If the embedder is able to do so,
// Flutter will assume that this context is in the same sharegroup as the main
// rendering context and use this context for asynchronous texture uploads.
// Though optional, it is recommended that all embedders set this callback as
// it will lead to better performance in texture handling.
BoolCallback make_resource_current;
// By default, the renderer config assumes that the FBO does not change for
// the duration of the engine run. If this argument is true, the
Expand Down
11 changes: 9 additions & 2 deletions shell/platform/embedder/embedder_surface_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,16 @@ std::unique_ptr<Surface> EmbedderSurfaceGL::CreateGPUSurface() {
sk_sp<GrContext> EmbedderSurfaceGL::CreateResourceContext() const {
auto callback = gl_dispatch_table_.gl_make_resource_current_callback;
if (callback && callback()) {
return IOManager::CreateCompatibleResourceLoadingContext(
GrBackend::kOpenGL_GrBackend);
if (auto context = IOManager::CreateCompatibleResourceLoadingContext(
GrBackend::kOpenGL_GrBackend)) {
return context;
}
}

FML_LOG(ERROR)
<< "Could not create a resource context for async texture uploads. "
"Expect degraded performance. Set a valid make_resource_current "
"callback on FlutterOpenGLRendererConfig.";
return nullptr;
}

Expand Down