| Flutter iOS Embedder |

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

`#include <ios_surface_software.h>`

Inheritance diagram for flutter::IOSSurfaceSoftware:

## Public Member Functions
| IOSSurfaceSoftware (CALayer *layer, std::shared_ptr< IOSContext > context)
| ~IOSSurfaceSoftware () override
bool | IsValid () const override
void | UpdateStorageSizeIfNecessary () override
std::unique_ptr< Surface > | CreateGPUSurface (GrDirectContext *gr_context=nullptr) override
sk_sp< SkSurface > | AcquireBackingStore (const SkISize &size) override
bool | PresentBackingStore (sk_sp< SkSurface > backing_store) override
Public Member Functions inherited from flutter::IOSSurface
std::shared_ptr< IOSContext > | GetContext () const
virtual | ~IOSSurface ()

## Additional Inherited Members
Static Public Member Functions inherited from flutter::IOSSurface
static std::unique_ptr< IOSSurface > | Create (std::shared_ptr< IOSContext > context, CALayer *layer)
Protected Member Functions inherited from flutter::IOSSurface
| IOSSurface (std::shared_ptr< IOSContext > ios_context)

## Detailed Description

Definition at line 20 of file ios_surface_software.h.

## Constructor & Destructor Documentation

## ◆ IOSSurfaceSoftware()

flutter::IOSSurfaceSoftware::IOSSurfaceSoftware | ( | CALayer * | layer,
|  | std::shared_ptr< IOSContext > | context
| ) |  |

Definition at line 23 of file ios_surface_software.mm.

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

## ◆ ~IOSSurfaceSoftware()

flutter::IOSSurfaceSoftware::~IOSSurfaceSoftware | ( |  | ) |
| override default

## Member Function Documentation

## ◆ AcquireBackingStore()

sk_sp< SkSurface > flutter::IOSSurfaceSoftware::AcquireBackingStore | ( | const SkISize & | size | ) |
| override

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
65 SkImageInfo info = SkImageInfo::MakeN32(size.fWidth, size.fHeight, kPremul_SkAlphaType,
66 SkColorSpace::MakeSRGB());
67 sk_surface_ = SkSurfaces::Raster(info, nullptr);
68 return sk_surface_;
69 }
flutter::IOSSurfaceSoftware::IsValid
bool IsValid() const override
Definition: ios_surface_software.mm:28

References IsValid().

## ◆ CreateGPUSurface()

std::unique_ptr< Surface > flutter::IOSSurfaceSoftware::CreateGPUSurface | ( | GrDirectContext * | gr_context = `nullptr` | ) |
| override virtual

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 }

References IsValid().

## ◆ IsValid()

bool flutter::IOSSurfaceSoftware::IsValid | ( |  | ) | const
| override virtual

Implements flutter::IOSSurface.

Definition at line 28 of file ios_surface_software.mm.

28 {
29 return layer_;
30 }

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

## ◆ PresentBackingStore()

bool flutter::IOSSurfaceSoftware::PresentBackingStore | ( | sk_sp< SkSurface > | backing_store | ) |
| override

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_.contents = (__bridge id) static_cast<CGImageRef>(pixmap_image);
124
125 return true;
126 }

References IsValid().

## ◆ UpdateStorageSizeIfNecessary()

void flutter::IOSSurfaceSoftware::UpdateStorageSizeIfNecessary | ( |  | ) |
| override virtual

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:

- shell/platform/darwin/ios/ios_surface_software.h
- shell/platform/darwin/ios/ios_surface_software.mm