Flutter Engine
android_surface_gl.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_GL_H_
6 #define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_GL_H_
7 
8 #include <jni.h>
9 
10 #include <memory>
11 
12 #include "flutter/fml/macros.h"
13 #include "flutter/shell/gpu/gpu_surface_gl.h"
14 #include "flutter/shell/platform/android/android_context_gl.h"
15 #include "flutter/shell/platform/android/android_environment_gl.h"
16 #include "flutter/shell/platform/android/external_view_embedder/external_view_embedder.h"
17 #include "flutter/shell/platform/android/jni/platform_view_android_jni.h"
18 #include "flutter/shell/platform/android/surface/android_surface.h"
19 
20 namespace flutter {
21 
23  public AndroidSurface {
24  public:
26  std::shared_ptr<AndroidContext> android_context,
27  std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
28  std::shared_ptr<AndroidExternalViewEmbedder> external_view_embedder);
29 
30  ~AndroidSurfaceGL() override;
31 
32  // |AndroidSurface|
33  bool IsValid() const override;
34 
35  // |AndroidSurface|
36  std::unique_ptr<Surface> CreateGPUSurface(
37  GrDirectContext* gr_context) override;
38 
39  // |AndroidSurface|
40  void TeardownOnScreenContext() override;
41 
42  // |AndroidSurface|
43  bool OnScreenSurfaceResize(const SkISize& size) override;
44 
45  // |AndroidSurface|
46  bool ResourceContextMakeCurrent() override;
47 
48  // |AndroidSurface|
49  bool ResourceContextClearCurrent() override;
50 
51  // |AndroidSurface|
53 
54  // |GPUSurfaceGLDelegate|
55  std::unique_ptr<GLContextResult> GLContextMakeCurrent() override;
56 
57  // |GPUSurfaceGLDelegate|
58  bool GLContextClearCurrent() override;
59 
60  // |GPUSurfaceGLDelegate|
61  bool GLContextPresent(uint32_t fbo_id) override;
62 
63  // |GPUSurfaceGLDelegate|
64  intptr_t GLContextFBO(GLFrameInfo frame_info) const override;
65 
66  // |GPUSurfaceGLDelegate|
68 
69  // |GPUSurfaceGLDelegate|
70  sk_sp<const GrGLInterface> GetGLInterface() const override;
71 
72  private:
73  const std::shared_ptr<AndroidExternalViewEmbedder> external_view_embedder_;
74  const std::shared_ptr<AndroidContextGL> android_context_;
75 
76  fml::RefPtr<AndroidNativeWindow> native_window_;
77  std::unique_ptr<AndroidEGLSurface> onscreen_surface_;
78  std::unique_ptr<AndroidEGLSurface> offscreen_surface_;
79 
80  FML_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceGL);
81 };
82 
83 } // namespace flutter
84 
85 #endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_GL_H_
bool OnScreenSurfaceResize(const SkISize &size) override
intptr_t GLContextFBO(GLFrameInfo frame_info) const override
sk_sp< const GrGLInterface > GetGLInterface() const override
bool IsValid() const override
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
bool GLContextClearCurrent() override
bool ResourceContextClearCurrent() override
ExternalViewEmbedder * GetExternalViewEmbedder() override
Gets the view embedder that controls how the Flutter layer hierarchy split into multiple chunks shoul...
bool GLContextPresent(uint32_t fbo_id) override
void TeardownOnScreenContext() override
AndroidSurfaceGL(std::shared_ptr< AndroidContext > android_context, std::shared_ptr< PlatformViewAndroidJNI > jni_facade, std::shared_ptr< AndroidExternalViewEmbedder > external_view_embedder)
std::unique_ptr< GLContextResult > GLContextMakeCurrent() override
bool SetNativeWindow(fml::RefPtr< AndroidNativeWindow > window) override
bool ResourceContextMakeCurrent() override
std::unique_ptr< Surface > CreateGPUSurface(GrDirectContext *gr_context) override