Flutter Engine
 
Loading...
Searching...
No Matches
FlutterDarwinExternalTextureMetal Class Reference

#include <FlutterDarwinExternalTextureMetal.h>

Inheritance diagram for FlutterDarwinExternalTextureMetal:

Instance Methods

(nullable instancetype) - initWithTextureCache:textureID:texture:enableImpeller:
 
(void) - paintContext:bounds:freeze:sampling:
 
(void) - onGrContextCreated
 
(void) - onGrContextDestroyed
 
(void) - markNewFrameAvailable
 
(void) - onTextureUnregistered
 

Properties

int64_t textureID
 

Detailed Description

Definition at line 45 of file FlutterDarwinExternalTextureMetal.h.

Method Documentation

◆ initWithTextureCache:textureID:texture:enableImpeller:

- (nullable instancetype) initWithTextureCache: (nonnull CVMetalTextureCacheRef)  textureCache
textureID: (int64_t)  textureID
texture: (nonnull NSObject< FlutterTexture > *)  texture
enableImpeller: (BOOL enableImpeller 

◆ markNewFrameAvailable

- (void) markNewFrameAvailable

Definition at line 35 of file FlutterDarwinExternalTextureMetal.mm.

115 {
117}

◆ onGrContextCreated

- (void) onGrContextCreated

Definition at line 35 of file FlutterDarwinExternalTextureMetal.mm.

98 {
99 // External images in this backend have no thread affinity and are not tied to the context in any
100 // way. Instead, they are tied to the Metal device which is associated with the cache already and
101 // is consistent throughout the shell run.
102}

◆ onGrContextDestroyed

- (void) onGrContextDestroyed

Definition at line 35 of file FlutterDarwinExternalTextureMetal.mm.

104 {
105 // The image must be reset because it is tied to the onscreen context. But the pixel buffer that
106 // created the image is still around. In case of context reacquisition, that last pixel
107 // buffer will be used to materialize the image in case the application fails to provide a new
108 // one.
109 _externalImage.reset();
110 if (_textureCache) {
111 CVMetalTextureCacheFlush(_textureCache, /* options (must be zero) */ 0);
112 }
113}
sk_sp< flutter::DlImage > _externalImage

◆ onTextureUnregistered

- (void) onTextureUnregistered

Definition at line 35 of file FlutterDarwinExternalTextureMetal.mm.

119 {
120 if ([_externalTexture respondsToSelector:@selector(onTextureUnregistered:)]) {
121 [_externalTexture onTextureUnregistered:_externalTexture];
122 }
123}
NSObject< FlutterTexture > * _externalTexture

◆ paintContext:bounds:freeze:sampling:

- (void) paintContext: (flutter::Texture::PaintContext&)  context
bounds: (const SkRect&)  bounds
freeze: (BOOL freeze
sampling: (const flutter::DlImageSampling sampling 

Definition at line 35 of file FlutterDarwinExternalTextureMetal.mm.

60 bounds:(const SkRect&)bounds
61 freeze:(BOOL)freeze
62 sampling:(const flutter::DlImageSampling)sampling {
63 const bool needsUpdatedTexture = (!freeze && _textureFrameAvailable) || !_externalImage;
64
65 if (needsUpdatedTexture) {
66 [self onNeedsUpdatedTexture:context];
67 }
68
69 if (_externalImage) {
70 context.canvas->DrawImageRect(
71 _externalImage, // image
72 flutter::DlRect::Make(_externalImage->GetBounds()), // source rect
73 flutter::ToDlRect(bounds), // destination rect
74 sampling, // sampling
75 context.paint, // paint
77 );
78 }
79}
virtual void DrawImageRect(const sk_sp< DlImage > &image, const DlRect &src, const DlRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, DlSrcRectConstraint constraint=DlSrcRectConstraint::kFast)=0
const DlRect & ToDlRect(const SkRect &rect)
static constexpr std::enable_if_t< std::is_floating_point_v< FT >, TRect > Make(const TRect< U > &rect)
Definition rect.h:157
int BOOL

Property Documentation

◆ textureID

- (int64_t) textureID
readnonatomicassign

Definition at line 65 of file FlutterDarwinExternalTextureMetal.h.


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