Flutter Engine
 
Loading...
Searching...
No Matches
flutter::AndroidSurfaceSoftware Class Referencefinal

#include <android_surface_software.h>

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

Public Member Functions

 AndroidSurfaceSoftware ()
 
 ~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 DlISize &size) override
 
bool SetNativeWindow (fml::RefPtr< AndroidNativeWindow > window, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade) override
 
sk_sp< SkSurface > AcquireBackingStore (const DlISize &size) override
 Called when the GPU surface needs a new buffer to render a new frame into.
 
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.
 
- Public Member Functions inherited from flutter::AndroidSurface
virtual ~AndroidSurface ()
 
virtual std::unique_ptr< SurfaceCreateSnapshotSurface ()
 
virtual std::shared_ptr< impeller::ContextGetImpellerContext ()
 
virtual void SetupImpellerSurface ()
 
- Public Member Functions inherited from flutter::GPUSurfaceSoftwareDelegate
 ~GPUSurfaceSoftwareDelegate ()
 

Additional Inherited Members

- Protected Member Functions inherited from flutter::AndroidSurface
 AndroidSurface ()
 

Detailed Description

Definition at line 19 of file android_surface_software.h.

Constructor & Destructor Documentation

◆ AndroidSurfaceSoftware()

flutter::AndroidSurfaceSoftware::AndroidSurfaceSoftware ( )

Definition at line 43 of file android_surface_software.cc.

43 {
44 GetSkColorType(WINDOW_FORMAT_RGBA_8888, &target_color_type_,
45 &target_alpha_type_);
46}

◆ ~AndroidSurfaceSoftware()

flutter::AndroidSurfaceSoftware::~AndroidSurfaceSoftware ( )
overridedefault

Member Function Documentation

◆ AcquireBackingStore()

sk_sp< SkSurface > flutter::AndroidSurfaceSoftware::AcquireBackingStore ( const DlISize 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 81 of file android_surface_software.cc.

82 {
83 TRACE_EVENT0("flutter", "AndroidSurfaceSoftware::AcquireBackingStore");
84 if (!IsValid()) {
85 return nullptr;
86 }
87
88 if (sk_surface_ != nullptr && //
89 sk_surface_->width() == size.width &&
90 sk_surface_->height() == size.height) {
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.width, size.height, target_color_type_,
97 target_alpha_type_, SkColorSpace::MakeSRGB());
98
99 sk_surface_ = SkSurfaces::Raster(image_info);
100
101 return sk_surface_;
102}
it will be possible to load the file into Perfetto s trace viewer 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
#define TRACE_EVENT0(category_group, name)

References IsValid(), flutter::size, and TRACE_EVENT0.

◆ CreateGPUSurface()

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

Implements flutter::AndroidSurface.

Definition at line 63 of file android_surface_software.cc.

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

References IsValid(), and surface.

◆ IsValid()

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

Implements flutter::AndroidSurface.

Definition at line 50 of file android_surface_software.cc.

50 {
51 return true;
52}

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

◆ OnScreenSurfaceResize()

bool flutter::AndroidSurfaceSoftware::OnScreenSurfaceResize ( const DlISize 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.

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}
uint32_t color_type
uint32_t alpha_type

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

◆ ResourceContextClearCurrent()

bool flutter::AndroidSurfaceSoftware::ResourceContextClearCurrent ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 59 of file android_surface_software.cc.

59 {
60 return false;
61}

◆ ResourceContextMakeCurrent()

bool flutter::AndroidSurfaceSoftware::ResourceContextMakeCurrent ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 54 of file android_surface_software.cc.

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

◆ SetNativeWindow()

bool flutter::AndroidSurfaceSoftware::SetNativeWindow ( fml::RefPtr< AndroidNativeWindow window,
const std::shared_ptr< PlatformViewAndroidJNI > &  jni_facade 
)
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 153 of file android_surface_software.cc.

155 {
156 native_window_ = std::move(window);
157 if (!(native_window_ && native_window_->IsValid())) {
158 return false;
159 }
160 int32_t window_format = ANativeWindow_getFormat(native_window_->handle());
161 if (window_format < 0) {
162 return false;
163 }
164 if (!GetSkColorType(window_format, &target_color_type_,
165 &target_alpha_type_)) {
166 return false;
167 }
168 return true;
169}
GLFWwindow * window
Definition main.cc:60

References window.

◆ 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: