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/jni/platform_view_android_jni.h"
13 #include "flutter/shell/platform/android/surface/android_surface.h"
14 
15 namespace flutter {
16 
19  public:
20  AndroidSurfaceSoftware(const std::shared_ptr<AndroidContext>& android_context,
21  std::shared_ptr<PlatformViewAndroidJNI> jni_facade);
22 
23  ~AndroidSurfaceSoftware() override;
24 
25  // |AndroidSurface|
26  bool IsValid() const override;
27 
28  // |AndroidSurface|
29  bool ResourceContextMakeCurrent() override;
30 
31  // |AndroidSurface|
32  bool ResourceContextClearCurrent() override;
33 
34  // |AndroidSurface|
35  std::unique_ptr<Surface> CreateGPUSurface(
36  GrDirectContext* gr_context) override;
37 
38  // |AndroidSurface|
39  void TeardownOnScreenContext() override;
40 
41  // |AndroidSurface|
42  bool OnScreenSurfaceResize(const SkISize& size) override;
43 
44  // |AndroidSurface|
46 
47  // |GPUSurfaceSoftwareDelegate|
48  sk_sp<SkSurface> AcquireBackingStore(const SkISize& size) override;
49 
50  // |GPUSurfaceSoftwareDelegate|
51  bool PresentBackingStore(sk_sp<SkSurface> backing_store) 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_
bool OnScreenSurfaceResize(const SkISize &size) override
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(const std::shared_ptr< AndroidContext > &android_context, std::shared_ptr< PlatformViewAndroidJNI > jni_facade)