-
Notifications
You must be signed in to change notification settings - Fork 2
[Tizen] Re-implemented render external texture gl for impeller to avoid change FlutterOpenGLTexture and use deprecated api #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: flutter-3.38.3
Are you sure you want to change the base?
Conversation
…id change FlutterOpenGLTexture and use deprecated api
JSUYA
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review.
I left a comment. Please check it.
| auto it = impeller_gl_textures_.find(texture->name); | ||
| if (it != impeller_gl_textures_.end()) { | ||
| image = it->second; | ||
| } else { | ||
| impeller::TextureDescriptor desc; | ||
| desc.size = impeller::ISize(texture->width, texture->height); | ||
| desc.storage_mode = impeller::StorageMode::kDevicePrivate; | ||
| desc.format = impeller::PixelFormat::kR8G8B8A8UNormInt; | ||
| if (texture->target == GL_TEXTURE_EXTERNAL_OES) { | ||
| desc.type = impeller::TextureType::kTextureExternalOES; | ||
| } else { | ||
| desc.type = impeller::TextureType::kTexture2D; | ||
| } | ||
| return nullptr; | ||
| } | ||
|
|
||
| if (!image) { | ||
| // In case Skia rejects the image, call the release proc so that | ||
| // embedders can perform collection of intermediates. | ||
| if (texture->destruction_callback) { | ||
| texture->destruction_callback(texture->user_data); | ||
| impeller::ContextGLES& context = | ||
| impeller::ContextGLES::Cast(*aiks_context->GetContext()); | ||
| impeller::HandleGLES handle = context.GetReactor()->CreateHandle( | ||
| impeller::HandleType::kTexture, texture->name); | ||
|
|
||
| image = | ||
| impeller::TextureGLES::WrapTexture(context.GetReactor(), desc, handle); | ||
| if (!image) { | ||
| // In case Skia rejects the image, call the release proc so that | ||
| // embedders can perform collection of intermediates. | ||
| if (texture->destruction_callback) { | ||
| texture->destruction_callback(texture->user_data); | ||
| } | ||
| FML_LOG(ERROR) << "Could not create external texture"; | ||
| return nullptr; | ||
| } | ||
| FML_LOG(ERROR) << "Could not create external texture"; | ||
| return nullptr; | ||
| } | ||
|
|
||
| if (texture->destruction_callback) { | ||
| texture->destruction_callback(texture->user_data); | ||
| } | ||
| image->SetCoordinateSystem( | ||
| impeller::TextureCoordinateSystem::kUploadFromHost); | ||
|
|
||
| return impeller::DlImageImpeller::Make(image); | ||
| } | ||
|
|
||
| sk_sp<DlImage> EmbedderExternalTextureGL::ResolveTextureImpellerSurface( | ||
| impeller::AiksContext* aiks_context, | ||
| std::unique_ptr<FlutterOpenGLTexture> texture) { | ||
| impeller::TextureDescriptor desc; | ||
| desc.size = impeller::ISize(texture->width, texture->height); | ||
| desc.storage_mode = impeller::StorageMode::kDevicePrivate; | ||
| desc.format = impeller::PixelFormat::kR8G8B8A8UNormInt; | ||
| desc.type = impeller::TextureType::kTextureExternalOES; | ||
| impeller::ContextGLES& context = | ||
| impeller::ContextGLES::Cast(*aiks_context->GetContext()); | ||
| std::shared_ptr<impeller::TextureGLES> image = | ||
| std::make_shared<impeller::TextureGLES>(context.GetReactor(), desc); | ||
| image->MarkContentsInitialized(); | ||
| image->SetCoordinateSystem( | ||
| impeller::TextureCoordinateSystem::kUploadFromHost); | ||
| if (!image->Bind()) { | ||
| if (texture->destruction_callback) { | ||
| texture->destruction_callback(texture->user_data); | ||
| } | ||
| FML_LOG(ERROR) << "Could not bind texture"; | ||
| return nullptr; | ||
| } | ||
|
|
||
| if (!image) { | ||
| // In case Skia rejects the image, call the release proc so that | ||
| // embedders can perform collection of intermediates. | ||
| if (texture->destruction_callback) { | ||
| texture->destruction_callback(texture->user_data); | ||
| } | ||
| FML_LOG(ERROR) << "Could not create external texture"; | ||
| return nullptr; | ||
| } | ||
|
|
||
| if (!texture->bind_callback(texture->user_data)) { | ||
| if (texture->destruction_callback) { | ||
| texture->destruction_callback(texture->user_data); | ||
| if (texture->destruction_callback && | ||
| !context.GetReactor()->RegisterCleanupCallback( | ||
| handle, | ||
| [callback = texture->destruction_callback, | ||
| user_data = texture->user_data]() { callback(user_data); })) { | ||
| FML_LOG(ERROR) << "Could not register destruction callback"; | ||
| return nullptr; | ||
| } | ||
| return nullptr; | ||
| } | ||
|
|
||
| if (texture->destruction_callback) { | ||
| texture->destruction_callback(texture->user_data); | ||
| impeller_gl_textures_[texture->name] = image; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -138,6 +140,11 @@ sk_sp<DlImage> EmbedderExternalTextureGL::ResolveTextureImpeller(
return nullptr;
}
+ auto it = impeller_gl_textures_.find(texture->name);
+ if (it != impeller_gl_textures_.end()) {
+ std::shared_ptr<impeller::TextureGLES> image = it->second;
+ return impeller::DlImageImpeller::Make(image);
+ }
+
impeller::TextureDescriptor desc;
desc.size = impeller::ISize(texture->width, texture->height);
@@ -166,6 +173,8 @@ sk_sp<DlImage> EmbedderExternalTextureGL::ResolveTextureImpeller(
return nullptr;
}
+ impeller_gl_textures_[texture->name] = image;
+
return impeller::DlImageImpeller::Make(image);
}If I understand correctly...
If you want to reuse a texture, we can minimize code diffs by immediately returning the image.
However, I have a few questions.
- When will the images(textures) remaining in
impeller_gl_textures_be removed ? - Will calling impeller_gl_textures_.clear in
OnTextureUnregistered()cause problems? - Will this cause problems if the texture size changes?
We have supported render external texture gl for Impeller
flutter-tizen/engine#368
But this PR has two issues:
So I tried to revert offical PR to render external gl for impeller
flutter/engine#56277
But this PR doesn't work on Tizen platform, I think This PR may not have been verified.
To avoid change FlutterOpenGLTexture and use deprecated api, so I re-implemented render external texture gl for impeller based on this offical PR.
Fix flutter-tizen/embedder#131