• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <memory>
10 
11 #include "flutter/fml/macros.h"
12 #include "flutter/shell/gpu/gpu_surface_gl.h"
13 #include "flutter/shell/platform/android/android_context_gl.h"
14 #include "flutter/shell/platform/android/android_environment_gl.h"
15 #include "flutter/shell/platform/android/android_surface.h"
16 
17 namespace flutter {
18 
19 class AndroidSurfaceGL final : public GPUSurfaceGLDelegate,
20                                public AndroidSurface {
21  public:
22   AndroidSurfaceGL();
23 
24   ~AndroidSurfaceGL() override;
25 
26   bool IsOffscreenContextValid() const;
27 
28   // |AndroidSurface|
29   bool IsValid() const override;
30 
31   // |AndroidSurface|
32   std::unique_ptr<Surface> CreateGPUSurface() override;
33 
34   // |AndroidSurface|
35   void TeardownOnScreenContext() override;
36 
37   // |AndroidSurface|
38   bool OnScreenSurfaceResize(const SkISize& size) const override;
39 
40   // |AndroidSurface|
41   bool ResourceContextMakeCurrent() override;
42 
43   // |AndroidSurface|
44   bool ResourceContextClearCurrent() override;
45 
46   // |AndroidSurface|
47   bool SetNativeWindow(fml::RefPtr<AndroidNativeWindow> window) override;
48 
49   // |GPUSurfaceGLDelegate|
50   bool GLContextMakeCurrent() override;
51 
52   // |GPUSurfaceGLDelegate|
53   bool GLContextClearCurrent() override;
54 
55   // |GPUSurfaceGLDelegate|
56   bool GLContextPresent() override;
57 
58   // |GPUSurfaceGLDelegate|
59   intptr_t GLContextFBO() const override;
60 
61   // |GPUSurfaceGLDelegate|
62   ExternalViewEmbedder* GetExternalViewEmbedder() override;
63 
64  private:
65   fml::RefPtr<AndroidContextGL> onscreen_context_;
66   fml::RefPtr<AndroidContextGL> offscreen_context_;
67 
68   FML_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceGL);
69 };
70 
71 }  // namespace flutter
72 
73 #endif  // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_GL_H_
74