From cb31ce37fac7a06e82d724c262b157a2e3ce53ec Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Fri, 8 Feb 2019 14:21:47 -0800 Subject: [PATCH] Document GPUSurfaceGLDelegate methods and move it to its own file. (flutter/engine#7755) --- .../ci/licenses_golden/licenses_flutter | 1 + engine/src/flutter/shell/gpu/BUILD.gn | 1 + engine/src/flutter/shell/gpu/gpu_surface_gl.h | 24 +------- .../shell/gpu/gpu_surface_gl_delegate.h | 60 +++++++++++++++++++ 4 files changed, 63 insertions(+), 23 deletions(-) create mode 100644 engine/src/flutter/shell/gpu/gpu_surface_gl_delegate.h diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index d9ed2700a3..7d5e643fdc 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -403,6 +403,7 @@ FILE: ../../../flutter/shell/common/vsync_waiter_fallback.cc FILE: ../../../flutter/shell/common/vsync_waiter_fallback.h FILE: ../../../flutter/shell/gpu/gpu_surface_gl.cc FILE: ../../../flutter/shell/gpu/gpu_surface_gl.h +FILE: ../../../flutter/shell/gpu/gpu_surface_gl_delegate.h FILE: ../../../flutter/shell/gpu/gpu_surface_software.cc FILE: ../../../flutter/shell/gpu/gpu_surface_software.h FILE: ../../../flutter/shell/gpu/gpu_surface_vulkan.cc diff --git a/engine/src/flutter/shell/gpu/BUILD.gn b/engine/src/flutter/shell/gpu/BUILD.gn index a886b0192c..5e7bcddbfb 100644 --- a/engine/src/flutter/shell/gpu/BUILD.gn +++ b/engine/src/flutter/shell/gpu/BUILD.gn @@ -28,6 +28,7 @@ source_set("gpu_surface_gl") { sources = [ "$gpu_dir/gpu_surface_gl.cc", "$gpu_dir/gpu_surface_gl.h", + "$gpu_dir/gpu_surface_gl_delegate.h", ] deps = gpu_common_deps + [ "//third_party/skia" ] diff --git a/engine/src/flutter/shell/gpu/gpu_surface_gl.h b/engine/src/flutter/shell/gpu/gpu_surface_gl.h index a268e6d280..2be751297b 100644 --- a/engine/src/flutter/shell/gpu/gpu_surface_gl.h +++ b/engine/src/flutter/shell/gpu/gpu_surface_gl.h @@ -12,33 +12,11 @@ #include "flutter/fml/macros.h" #include "flutter/fml/memory/weak_ptr.h" #include "flutter/shell/common/surface.h" +#include "flutter/shell/gpu/gpu_surface_gl_delegate.h" #include "third_party/skia/include/gpu/GrContext.h" namespace shell { -class GPUSurfaceGLDelegate { - public: - virtual bool GLContextMakeCurrent() = 0; - - virtual bool GLContextClearCurrent() = 0; - - virtual bool GLContextPresent() = 0; - - virtual intptr_t GLContextFBO() const = 0; - - virtual bool GLContextFBOResetAfterPresent() const; - - virtual bool UseOffscreenSurface() const; - - virtual SkMatrix GLContextSurfaceTransformation() const; - - virtual flow::ExternalViewEmbedder* GetExternalViewEmbedder(); - - using GLProcResolver = - std::function; - virtual GLProcResolver GetGLProcResolver() const; -}; - class GPUSurfaceGL : public Surface { public: GPUSurfaceGL(GPUSurfaceGLDelegate* delegate); diff --git a/engine/src/flutter/shell/gpu/gpu_surface_gl_delegate.h b/engine/src/flutter/shell/gpu/gpu_surface_gl_delegate.h new file mode 100644 index 0000000000..36e7d2912c --- /dev/null +++ b/engine/src/flutter/shell/gpu/gpu_surface_gl_delegate.h @@ -0,0 +1,60 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_GL_DELEGATE_H_ +#define FLUTTER_SHELL_GPU_GPU_SURFACE_GL_DELEGATE_H_ + +#include "flutter/flow/embedded_views.h" +#include "flutter/fml/macros.h" +#include "third_party/skia/include/core/SkMatrix.h" + +namespace shell { + +class GPUSurfaceGLDelegate { + public: + // Called to make the main GL context current on the current thread. + virtual bool GLContextMakeCurrent() = 0; + + // Called to clear the current GL context on the thread. This may be called on + // either the GPU or IO threads. + virtual bool GLContextClearCurrent() = 0; + + // Called to present the main GL surface. This is only called for the main GL + // context and not any of the contexts dedicated for IO. + virtual bool GLContextPresent() = 0; + + // The ID of the main window bound framebuffer. Typically FBO0. + virtual intptr_t GLContextFBO() const = 0; + + // The rendering subsystem assumes that the ID of the main window bound + // framebuffer remains constant throughout. If this assumption in incorrect, + // embedders are required to return true from this method. In such cases, + // GLContextFBO() will be called again to acquire the new FBO ID for rendering + // subsequent frames. + virtual bool GLContextFBOResetAfterPresent() const; + + // Create an offscreen surface to render into before onscreen composition. + virtual bool UseOffscreenSurface() const; + + // A transformation applied to the onscreen surface before the canvas is + // flushed. + virtual SkMatrix GLContextSurfaceTransformation() const; + + // Get a reference to the external views embedder. This happens on the same + // thread that the renderer is operating on. + virtual flow::ExternalViewEmbedder* GetExternalViewEmbedder(); + + using GLProcResolver = + std::function; + // Provide a custom GL proc resolver. If no such resolver is present, Skia + // will attempt to do GL proc address resolution on its own. Embedders that + // have specific opinions on GL API selection or need to add their own + // instrumentation to specific GL calls can specify custom GL functions + // here. + virtual GLProcResolver GetGLProcResolver() const; +}; + +} // namespace shell + +#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_GL_DELEGATE_H_