Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::IOSSurfaceSoftware Class Referencefinal

#include <ios_surface_software.h>

Inheritance diagram for flutter::IOSSurfaceSoftware:
flutter::IOSSurface flutter::GPUSurfaceSoftwareDelegate

Public Member Functions

 IOSSurfaceSoftware (const fml::scoped_nsobject< CALayer > &layer, std::shared_ptr< IOSContext > context)
 
 ~IOSSurfaceSoftware () override
 
bool IsValid () const override
 
void UpdateStorageSizeIfNecessary () override
 
std::unique_ptr< SurfaceCreateGPUSurface (GrDirectContext *gr_context=nullptr) override
 
sk_sp< SkSurfaceAcquireBackingStore (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::IOSSurface
std::shared_ptr< IOSContextGetContext () const
 
virtual ~IOSSurface ()
 
virtual bool IsValid () const =0
 
virtual void UpdateStorageSizeIfNecessary ()=0
 
virtual std::unique_ptr< SurfaceCreateGPUSurface (GrDirectContext *gr_context=nullptr)=0
 
- Public Member Functions inherited from flutter::GPUSurfaceSoftwareDelegate
 ~GPUSurfaceSoftwareDelegate ()
 
virtual sk_sp< SkSurfaceAcquireBackingStore (const SkISize &size)=0
 Called when the GPU surface needs a new buffer to render a new frame into. More...
 
virtual bool PresentBackingStore (sk_sp< SkSurface > backing_store)=0
 Called by the platform when a frame has been rendered into the backing store and the platform must display it on-screen. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from flutter::IOSSurface
static std::unique_ptr< IOSSurfaceCreate (std::shared_ptr< IOSContext > context, const fml::scoped_nsobject< CALayer > &layer)
 
- Protected Member Functions inherited from flutter::IOSSurface
 IOSSurface (std::shared_ptr< IOSContext > ios_context)
 

Detailed Description

Definition at line 21 of file ios_surface_software.h.

Constructor & Destructor Documentation

◆ IOSSurfaceSoftware()

flutter::IOSSurfaceSoftware::IOSSurfaceSoftware ( const fml::scoped_nsobject< CALayer > &  layer,
std::shared_ptr< IOSContext context 
)

Definition at line 22 of file ios_surface_software.mm.

24 : IOSSurface(std::move(context)), layer_(layer) {}
IOSSurface(std::shared_ptr< IOSContext > ios_context)
Definition: ios_surface.mm:49

◆ ~IOSSurfaceSoftware()

flutter::IOSSurfaceSoftware::~IOSSurfaceSoftware ( )
overridedefault

Member Function Documentation

◆ AcquireBackingStore()

sk_sp< SkSurface > flutter::IOSSurfaceSoftware::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 53 of file ios_surface_software.mm.

53 {
54 TRACE_EVENT0("flutter", "IOSSurfaceSoftware::AcquireBackingStore");
55 if (!IsValid()) {
56 return nullptr;
57 }
58
59 if (sk_surface_ != nullptr &&
60 SkISize::Make(sk_surface_->width(), sk_surface_->height()) == size) {
61 // The old and new surface sizes are the same. Nothing to do here.
62 return sk_surface_;
63 }
64
67 sk_surface_ = SkSurfaces::Raster(info, nullptr);
68 return sk_surface_;
69}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
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 MakeN32(int width, int height, SkAlphaType at)
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

◆ CreateGPUSurface()

std::unique_ptr< Surface > flutter::IOSSurfaceSoftware::CreateGPUSurface ( GrDirectContext gr_context = nullptr)
overridevirtual

Implements flutter::IOSSurface.

Definition at line 39 of file ios_surface_software.mm.

39 {
40 if (!IsValid()) {
41 return nullptr;
42 }
43
44 auto surface = std::make_unique<GPUSurfaceSoftware>(this, true /* render to surface */);
45
46 if (!surface->IsValid()) {
47 return nullptr;
48 }
49
50 return surface;
51}
VkSurfaceKHR surface
Definition: main.cc:49

◆ IsValid()

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

Implements flutter::IOSSurface.

Definition at line 28 of file ios_surface_software.mm.

28 {
29 return layer_;
30}

◆ PresentBackingStore()

bool flutter::IOSSurfaceSoftware::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 71 of file ios_surface_software.mm.

71 {
72 TRACE_EVENT0("flutter", "IOSSurfaceSoftware::PresentBackingStore");
73 if (!IsValid() || backing_store == nullptr) {
74 return false;
75 }
76
77 SkPixmap pixmap;
78 if (!backing_store->peekPixels(&pixmap)) {
79 return false;
80 }
81
82 // Some basic sanity checking.
83 uint64_t expected_pixmap_data_size = pixmap.width() * pixmap.height() * 4;
84
85 const size_t pixmap_size = pixmap.computeByteSize();
86
87 if (expected_pixmap_data_size != pixmap_size) {
88 return false;
89 }
90
91 fml::CFRef<CGColorSpaceRef> colorspace(CGColorSpaceCreateDeviceRGB());
92
93 // Setup the data provider that gives CG a view into the pixmap.
94 fml::CFRef<CGDataProviderRef> pixmap_data_provider(CGDataProviderCreateWithData(
95 nullptr, // info
96 pixmap.addr32(), // data
97 pixmap_size, // size
98 nullptr // release callback
99 ));
100
101 if (!pixmap_data_provider) {
102 return false;
103 }
104
105 // Create the CGImageRef representation on the pixmap.
106 fml::CFRef<CGImageRef> pixmap_image(CGImageCreate(pixmap.width(), // width
107 pixmap.height(), // height
108 8, // bits per component
109 32, // bits per pixel
110 pixmap.rowBytes(), // bytes per row
111 colorspace, // colorspace
112 kCGImageAlphaPremultipliedLast, // bitmap info
113 pixmap_data_provider, // data provider
114 nullptr, // decode array
115 false, // should interpolate
116 kCGRenderingIntentDefault // rendering intent
117 ));
118
119 if (!pixmap_image) {
120 return false;
121 }
122
123 layer_.get().contents = (__bridge id)(static_cast<CGImageRef>(pixmap_image));
124
125 return true;
126}
const uint32_t * addr32() const
Definition: SkPixmap.h:352
size_t rowBytes() const
Definition: SkPixmap.h:145
int width() const
Definition: SkPixmap.h:160
size_t computeByteSize() const
Definition: SkPixmap.h:231
int height() const
Definition: SkPixmap.h:166
bool peekPixels(SkPixmap *pixmap)
Definition: SkSurface.cpp:121
T get() const __attribute((ns_returns_not_retained))
const uintptr_t id

◆ UpdateStorageSizeIfNecessary()

void flutter::IOSSurfaceSoftware::UpdateStorageSizeIfNecessary ( )
overridevirtual

Implements flutter::IOSSurface.

Definition at line 32 of file ios_surface_software.mm.

32 {
33 // Nothing to do here. We don't need an external entity to tell us when our
34 // backing store needs to be updated. Instead, we let the frame tell us its
35 // size so we can update to match. This method was added to work around
36 // Android oddities.
37}

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