Skip to content

Commit

Permalink
Document make_resource_current on FlutterOpenGLRendererConfig and war…
Browse files Browse the repository at this point in the history
…n if the callback is not set. (flutter#7648)
  • Loading branch information
chinmaygarde authored Jan 31, 2019
1 parent e7eb1c8 commit 64e1707
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
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

0 comments on commit 64e1707

Please sign in to comment.