Flutter Engine
android_surface_software.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_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/external_view_embedder/external_view_embedder.h"
13 #include "flutter/shell/platform/android/jni/platform_view_android_jni.h"
14 #include "flutter/shell/platform/android/surface/android_surface.h"
15 
16 namespace flutter {
17 
20  public:
22  std::shared_ptr<AndroidContext> android_context,
23  std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
24  std::shared_ptr<AndroidExternalViewEmbedder> external_view_embedder);
25 
26  ~AndroidSurfaceSoftware() override;
27 
28  // |AndroidSurface|
29  bool IsValid() const override;
30 
31  // |AndroidSurface|
32  bool ResourceContextMakeCurrent() override;
33 
34  // |AndroidSurface|
35  bool ResourceContextClearCurrent() override;
36 
37  // |AndroidSurface|
38  std::unique_ptr<Surface> CreateGPUSurface(
39  GrDirectContext* gr_context) override;
40 
41  // |AndroidSurface|
42  void TeardownOnScreenContext() override;
43 
44  // |AndroidSurface|
45  bool OnScreenSurfaceResize(const SkISize& size) override;
46 
47  // |AndroidSurface|
49 
50  // |GPUSurfaceSoftwareDelegate|
51  sk_sp<SkSurface> AcquireBackingStore(const SkISize& size) override;
52 
53  // |GPUSurfaceSoftwareDelegate|
54  bool PresentBackingStore(sk_sp<SkSurface> backing_store) override;
55 
56  // |GPUSurfaceSoftwareDelegate|
58 
59  private:
60  const std::shared_ptr<AndroidExternalViewEmbedder> external_view_embedder_;
61 
62  sk_sp<SkSurface> sk_surface_;
63  fml::RefPtr<AndroidNativeWindow> native_window_;
64  SkColorType target_color_type_;
65  SkAlphaType target_alpha_type_;
66 
67  FML_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceSoftware);
68 };
69 
70 } // namespace flutter
71 
72 #endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_SOFTWARE_H_
bool OnScreenSurfaceResize(const SkISize &size) override
ExternalViewEmbedder * GetExternalViewEmbedder() override
Gets the view embedder that controls how the Flutter layer hierarchy split into multiple chunks shoul...
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
Interface implemented by all platform surfaces that can present a software backing store to the "scre...
sk_sp< SkSurface > AcquireBackingStore(const SkISize &size) override
Called when the GPU surface needs a new buffer to render a new frame into.
bool SetNativeWindow(fml::RefPtr< AndroidNativeWindow > window) override
std::unique_ptr< Surface > CreateGPUSurface(GrDirectContext *gr_context) override
bool PresentBackingStore(sk_sp< SkSurface > backing_store) override
Called by the platform when a frame has been rendered into the backing store and the platform must di...
AndroidSurfaceSoftware(std::shared_ptr< AndroidContext > android_context, std::shared_ptr< PlatformViewAndroidJNI > jni_facade, std::shared_ptr< AndroidExternalViewEmbedder > external_view_embedder)