Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions shell/platform/darwin/ios/ios_external_texture_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class IOSExternalTextureGL : public flutter::Texture {
void CreateTextureFromPixelBuffer();

void EnsureTextureCacheExists();
bool NeedUpdateTexture(bool freeze);

bool new_frame_ready_ = false;
NSObject<FlutterTexture>* external_texture_;
fml::CFRef<CVOpenGLESTextureCacheRef> cache_ref_;
fml::CFRef<CVOpenGLESTextureRef> texture_ref_;
Expand Down
13 changes: 11 additions & 2 deletions shell/platform/darwin/ios/ios_external_texture_gl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,24 @@
}
}

bool IOSExternalTextureGL::NeedUpdateTexture(bool freeze) {
// Update texture if `texture_ref_` is reset to `nullptr` when GrContext
// is destroied or new frame is ready.
return (!freeze && new_frame_ready_) || !texture_ref_;
}

void IOSExternalTextureGL::Paint(SkCanvas& canvas,
const SkRect& bounds,
bool freeze,
GrContext* context) {
EnsureTextureCacheExists();
if (!freeze) {
if (NeedUpdateTexture(freeze)) {
auto pixelBuffer = [external_texture_ copyPixelBuffer];
if (pixelBuffer) {
buffer_ref_.Reset(pixelBuffer);
}
CreateTextureFromPixelBuffer();
new_frame_ready_ = false;
}
if (!texture_ref_) {
return;
Expand Down Expand Up @@ -93,6 +100,8 @@
cache_ref_.Reset(nullptr);
}

void IOSExternalTextureGL::MarkNewFrameAvailable() {}
void IOSExternalTextureGL::MarkNewFrameAvailable() {
new_frame_ready_ = true;
}

} // namespace flutter