Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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 SkISize &size) override
 
bool SetNativeWindow (fml::RefPtr< AndroidNativeWindow > window) override
 
sk_sp< SkSurfaceAcquireBackingStore (const SkISize &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 ()
 
- 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 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 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 SkISize::Make(sk_surface_->width(), sk_surface_->height()) == size) {
90 // The old and new surface sizes are the same. Nothing to do here.
91 return sk_surface_;
92 }
93
94 SkImageInfo image_info =
95 SkImageInfo::Make(size.fWidth, size.fHeight, target_color_type_,
96 target_alpha_type_, SkColorSpace::MakeSRGB());
97
98 sk_surface_ = SkSurfaces::Raster(image_info);
99
100 return sk_surface_;
101}
static sk_sp< SkColorSpace > MakeSRGB()
int width() const
Definition SkSurface.h:178
int height() const
Definition SkSurface.h:184
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
it will be possible to load the file into Perfetto s trace viewer 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:259
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
#define TRACE_EVENT0(category_group, name)

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

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

◆ OnScreenSurfaceResize()

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

Implements flutter::AndroidSurface.

Definition at line 148 of file android_surface_software.cc.

148 {
149 return true;
150}

◆ 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 103 of file android_surface_software.cc.

104 {
105 TRACE_EVENT0("flutter", "AndroidSurfaceSoftware::PresentBackingStore");
106 if (!IsValid() || backing_store == nullptr) {
107 return false;
108 }
109
110 SkPixmap pixmap;
111 if (!backing_store->peekPixels(&pixmap)) {
112 return false;
113 }
114
115 ANativeWindow_Buffer native_buffer;
116 if (ANativeWindow_lock(native_window_->handle(), &native_buffer, nullptr)) {
117 return false;
118 }
119
122 if (GetSkColorType(native_buffer.format, &color_type, &alpha_type)) {
123 SkImageInfo native_image_info = SkImageInfo::Make(
124 native_buffer.width, native_buffer.height, color_type, alpha_type);
125
126 std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirect(
127 native_image_info, native_buffer.bits,
128 native_buffer.stride * SkColorTypeBytesPerPixel(color_type));
129
130 if (canvas) {
132 if (bitmap.installPixels(pixmap)) {
133 canvas->drawImageRect(
134 bitmap.asImage(),
135 SkRect::MakeIWH(native_buffer.width, native_buffer.height),
137 }
138 }
139 }
140
141 ANativeWindow_unlockAndPost(native_window_->handle());
142
143 return true;
144}
SkAlphaType
Definition SkAlphaType.h:26
SkColorType
Definition SkColorType.h:19
SK_API int SkColorTypeBytesPerPixel(SkColorType ct)
static std::unique_ptr< SkCanvas > MakeRasterDirect(const SkImageInfo &info, void *pixels, size_t rowBytes, const SkSurfaceProps *props=nullptr)
bool peekPixels(SkPixmap *pixmap)
uint32_t color_type
uint32_t alpha_type
static SkRect MakeIWH(int w, int h)
Definition SkRect.h:623

◆ 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)
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 152 of file android_surface_software.cc.

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

◆ TeardownOnScreenContext()

void flutter::AndroidSurfaceSoftware::TeardownOnScreenContext ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 146 of file android_surface_software.cc.

146{}

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