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/jni/platform_view_android_jni.h"
17 #include "flutter/shell/platform/android/surface/android_surface.h"
18 
19 namespace flutter {
20 
22  public AndroidSurface {
23  public:
24  AndroidSurfaceGL(const std::shared_ptr<AndroidContext>& android_context,
25  std::shared_ptr<PlatformViewAndroidJNI> jni_facade);
26 
27  ~AndroidSurfaceGL() override;
28 
29  // |AndroidSurface|
30  bool IsValid() const override;
31 
32  // |AndroidSurface|
33  std::unique_ptr<Surface> CreateGPUSurface(
34  GrDirectContext* gr_context) override;
35 
36  // |AndroidSurface|
37  void TeardownOnScreenContext() override;
38 
39  // |AndroidSurface|
40  bool OnScreenSurfaceResize(const SkISize& size) override;
41 
42  // |AndroidSurface|
43  bool ResourceContextMakeCurrent() override;
44 
45  // |AndroidSurface|
46  bool ResourceContextClearCurrent() override;
47 
48  // |AndroidSurface|
50 
51  // |AndroidSurface|
52  virtual std::unique_ptr<Surface> CreatePbufferSurface() override;
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|
67  sk_sp<const GrGLInterface> GetGLInterface() const override;
68 
69  private:
70  fml::RefPtr<AndroidNativeWindow> native_window_;
71  std::unique_ptr<AndroidEGLSurface> onscreen_surface_;
72  std::unique_ptr<AndroidEGLSurface> offscreen_surface_;
73 
74  //----------------------------------------------------------------------------
75  /// @brief Takes the super class AndroidSurface's AndroidContext and
76  /// return a raw pointer to an AndroidContextGL.
77  ///
78  AndroidContextGL* GLContextPtr() const;
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
virtual std::unique_ptr< Surface > CreatePbufferSurface() override
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
AndroidSurfaceGL(const std::shared_ptr< AndroidContext > &android_context, std::shared_ptr< PlatformViewAndroidJNI > jni_facade)
bool GLContextClearCurrent() override
bool ResourceContextClearCurrent() override
bool GLContextPresent(uint32_t fbo_id) override
void TeardownOnScreenContext() override
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