Flutter Engine
flutter::AndroidSurfaceSoftware Class Referencefinal

#include <android_surface_software.h>

Inheritance diagram for flutter::AndroidSurfaceSoftware:
flutter::AndroidSurface flutter::GPUSurfaceSoftwareDelegate

Public Member Functions

 AndroidSurfaceSoftware (const std::shared_ptr< AndroidContext > &android_context, std::shared_ptr< PlatformViewAndroidJNI > jni_facade)
 
 ~AndroidSurfaceSoftware () override
 
bool IsValid () const override
 
bool ResourceContextMakeCurrent () override
 
bool ResourceContextClearCurrent () override
 
std::unique_ptr< SurfaceCreateGPUSurface (GrDirectContext *gr_context) override
 
void TeardownOnScreenContext () override
 
bool OnScreenSurfaceResize (const SkISize &size) override
 
bool SetNativeWindow (fml::RefPtr< AndroidNativeWindow > window) override
 
sk_sp< SkSurface > AcquireBackingStore (const SkISize &size) override
 Called when the GPU surface needs a new buffer to render a new frame into. More...
 
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 display it on-screen. More...
 
- Public Member Functions inherited from flutter::AndroidSurface
virtual ~AndroidSurface ()
 
virtual std::unique_ptr< SurfaceCreateSnapshotSurface ()
 
virtual std::shared_ptr< impeller::ContextGetImpellerContext ()
 
- Public Member Functions inherited from flutter::GPUSurfaceSoftwareDelegate
 ~GPUSurfaceSoftwareDelegate ()
 

Additional Inherited Members

- Protected Member Functions inherited from flutter::AndroidSurface
 AndroidSurface (const std::shared_ptr< AndroidContext > &android_context)
 
- Protected Attributes inherited from flutter::AndroidSurface
std::shared_ptr< AndroidContextandroid_context_
 

Detailed Description

Definition at line 17 of file android_surface_software.h.

Constructor & Destructor Documentation

◆ AndroidSurfaceSoftware()

flutter::AndroidSurfaceSoftware::AndroidSurfaceSoftware ( const std::shared_ptr< AndroidContext > &  android_context,
std::shared_ptr< PlatformViewAndroidJNI jni_facade 
)

Definition at line 41 of file android_surface_software.cc.

References ~AndroidSurfaceSoftware().

44  : AndroidSurface(android_context) {
45  GetSkColorType(WINDOW_FORMAT_RGBA_8888, &target_color_type_,
46  &target_alpha_type_);
47 }
AndroidSurface(const std::shared_ptr< AndroidContext > &android_context)

◆ ~AndroidSurfaceSoftware()

flutter::AndroidSurfaceSoftware::~AndroidSurfaceSoftware ( )
overridedefault

Referenced by AndroidSurfaceSoftware().

Member Function Documentation

◆ AcquireBackingStore()

sk_sp< SkSurface > flutter::AndroidSurfaceSoftware::AcquireBackingStore ( const SkISize &  size)
overridevirtual

Called when the GPU surface needs a new buffer to render a new frame into.

Parameters
[in]sizeThe size of the frame.
Returns
A raster surface returned by the platform.

Implements flutter::GPUSurfaceSoftwareDelegate.

Definition at line 82 of file android_surface_software.cc.

References IsValid(), and TRACE_EVENT0.

83  {
84  TRACE_EVENT0("flutter", "AndroidSurfaceSoftware::AcquireBackingStore");
85  if (!IsValid()) {
86  return nullptr;
87  }
88 
89  if (sk_surface_ != nullptr &&
90  SkISize::Make(sk_surface_->width(), sk_surface_->height()) == size) {
91  // The old and new surface sizes are the same. Nothing to do here.
92  return sk_surface_;
93  }
94 
95  SkImageInfo image_info =
96  SkImageInfo::Make(size.fWidth, size.fHeight, target_color_type_,
97  target_alpha_type_, SkColorSpace::MakeSRGB());
98 
99  sk_surface_ = SkSurface::MakeRaster(image_info);
100 
101  return sk_surface_;
102 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:90
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data observatory The hostname IP address on which the Dart Observatory should be served If not defaults to or::depending on whether ipv6 is specified disable Disable the Dart Observatory The observatory is never available in release mode Bind to the IPv6 localhost address for the Dart Observatory Ignored if observatory host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent Remove all existing persistent cache This is mainly for debugging purposes such as reproducing the shader compilation jank use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:226

◆ CreateGPUSurface()

std::unique_ptr< Surface > flutter::AndroidSurfaceSoftware::CreateGPUSurface ( GrDirectContext *  gr_context)
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 64 of file android_surface_software.cc.

References IsValid(), and surface.

67  {
68  if (!IsValid()) {
69  return nullptr;
70  }
71 
72  auto surface =
73  std::make_unique<GPUSurfaceSoftware>(this, true /* render to surface */);
74 
75  if (!surface->IsValid()) {
76  return nullptr;
77  }
78 
79  return surface;
80 }
VkSurfaceKHR surface
Definition: main.cc:47

◆ IsValid()

bool flutter::AndroidSurfaceSoftware::IsValid ( ) const
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 51 of file android_surface_software.cc.

Referenced by AcquireBackingStore(), CreateGPUSurface(), and PresentBackingStore().

51  {
52  return true;
53 }

◆ OnScreenSurfaceResize()

bool flutter::AndroidSurfaceSoftware::OnScreenSurfaceResize ( const SkISize &  size)
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 149 of file android_surface_software.cc.

149  {
150  return true;
151 }

◆ PresentBackingStore()

bool flutter::AndroidSurfaceSoftware::PresentBackingStore ( sk_sp< SkSurface >  backing_store)
overridevirtual

Called by the platform when a frame has been rendered into the backing store and the platform must display it on-screen.

Parameters
[in]backing_storeThe software backing store to present.
Returns
Returns if the platform could present the backing store onto the screen.

Implements flutter::GPUSurfaceSoftwareDelegate.

Definition at line 104 of file android_surface_software.cc.

References alpha_type, color_type, IsValid(), and TRACE_EVENT0.

105  {
106  TRACE_EVENT0("flutter", "AndroidSurfaceSoftware::PresentBackingStore");
107  if (!IsValid() || backing_store == nullptr) {
108  return false;
109  }
110 
111  SkPixmap pixmap;
112  if (!backing_store->peekPixels(&pixmap)) {
113  return false;
114  }
115 
116  ANativeWindow_Buffer native_buffer;
117  if (ANativeWindow_lock(native_window_->handle(), &native_buffer, nullptr)) {
118  return false;
119  }
120 
121  SkColorType color_type;
122  SkAlphaType alpha_type;
123  if (GetSkColorType(native_buffer.format, &color_type, &alpha_type)) {
124  SkImageInfo native_image_info = SkImageInfo::Make(
125  native_buffer.width, native_buffer.height, color_type, alpha_type);
126 
127  std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirect(
128  native_image_info, native_buffer.bits,
129  native_buffer.stride * SkColorTypeBytesPerPixel(color_type));
130 
131  if (canvas) {
132  SkBitmap bitmap;
133  if (bitmap.installPixels(pixmap)) {
134  canvas->drawImageRect(
135  bitmap.asImage(),
136  SkRect::MakeIWH(native_buffer.width, native_buffer.height),
137  SkSamplingOptions());
138  }
139  }
140  }
141 
142  ANativeWindow_unlockAndPost(native_window_->handle());
143 
144  return true;
145 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:90
uint32_t color_type
uint32_t alpha_type

◆ ResourceContextClearCurrent()

bool flutter::AndroidSurfaceSoftware::ResourceContextClearCurrent ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 60 of file android_surface_software.cc.

60  {
61  return false;
62 }

◆ ResourceContextMakeCurrent()

bool flutter::AndroidSurfaceSoftware::ResourceContextMakeCurrent ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 55 of file android_surface_software.cc.

55  {
56  // Resource Context always not available on software backend.
57  return false;
58 }

◆ SetNativeWindow()

bool flutter::AndroidSurfaceSoftware::SetNativeWindow ( fml::RefPtr< AndroidNativeWindow window)
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 153 of file android_surface_software.cc.

154  {
155  native_window_ = std::move(window);
156  if (!(native_window_ && native_window_->IsValid()))
157  return false;
158  int32_t window_format = ANativeWindow_getFormat(native_window_->handle());
159  if (window_format < 0)
160  return false;
161  if (!GetSkColorType(window_format, &target_color_type_, &target_alpha_type_))
162  return false;
163  return true;
164 }

◆ TeardownOnScreenContext()

void flutter::AndroidSurfaceSoftware::TeardownOnScreenContext ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 147 of file android_surface_software.cc.

147 {}

The documentation for this class was generated from the following files: