• 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_SOFTWARE_H_
6 #define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_SOFTWARE_H_
7 
8 #include "flutter/fml/macros.h"
9 #include "flutter/fml/platform/android/jni_weak_ref.h"
10 #include "flutter/fml/platform/android/scoped_java_ref.h"
11 #include "flutter/shell/gpu/gpu_surface_software.h"
12 #include "flutter/shell/platform/android/android_surface.h"
13 
14 namespace flutter {
15 
16 class AndroidSurfaceSoftware final : public AndroidSurface,
17                                      public GPUSurfaceSoftwareDelegate {
18  public:
19   AndroidSurfaceSoftware();
20 
21   ~AndroidSurfaceSoftware() override;
22 
23   // |AndroidSurface|
24   bool IsValid() const override;
25 
26   // |AndroidSurface|
27   bool ResourceContextMakeCurrent() override;
28 
29   // |AndroidSurface|
30   bool ResourceContextClearCurrent() override;
31 
32   // |AndroidSurface|
33   std::unique_ptr<Surface> CreateGPUSurface() override;
34 
35   // |AndroidSurface|
36   void TeardownOnScreenContext() override;
37 
38   // |AndroidSurface|
39   bool OnScreenSurfaceResize(const SkISize& size) const override;
40 
41   // |AndroidSurface|
42   bool SetNativeWindow(fml::RefPtr<AndroidNativeWindow> window) override;
43 
44   // |GPUSurfaceSoftwareDelegate|
45   sk_sp<SkSurface> AcquireBackingStore(const SkISize& size) override;
46 
47   // |GPUSurfaceSoftwareDelegate|
48   bool PresentBackingStore(sk_sp<SkSurface> backing_store) override;
49 
50   // |GPUSurfaceSoftwareDelegate|
51   ExternalViewEmbedder* GetExternalViewEmbedder() override;
52 
53  private:
54   sk_sp<SkSurface> sk_surface_;
55   fml::RefPtr<AndroidNativeWindow> native_window_;
56   SkColorType target_color_type_;
57   SkAlphaType target_alpha_type_;
58 
59   FML_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceSoftware);
60 };
61 
62 }  // namespace flutter
63 
64 #endif  // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_SOFTWARE_H_
65