7#include "flutter/third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
8#include "flutter/third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h"
13 const std::shared_ptr<AndroidContextGLSkia>& context,
16 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade,
20void ImageExternalTextureGLSkia::Attach(
PaintContext& context) {
28void ImageExternalTextureGLSkia::Detach() {
32void ImageExternalTextureGLSkia::BindImageToTexture(
35 if (!
image.is_valid() || tex == 0) {
38 glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
39 glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES,
40 static_cast<GLeglImageOES
>(
image.get().
image));
43sk_sp<flutter::DlImage> ImageExternalTextureGLSkia::CreateDlImage(
44 PaintContext& context,
46 std::optional<HardwareBufferKey>
id,
49 glGenTextures(1, &texture_name);
52 unique_texture.
reset(gl_texture);
54 BindImageToTexture(egl_image, unique_texture.
get().texture_name);
55 GrGLTextureInfo textureInfo = {
56 GL_TEXTURE_EXTERNAL_OES, unique_texture.
get().texture_name, GL_RGBA8_OES};
58 GrBackendTextures::MakeGL(1, 1, skgpu::Mipmapped::kNo, textureInfo);
60 gl_entries_[
id.value_or(0)] = GlEntry{.egl_image = std::move(egl_image),
61 .texture = std::move(unique_texture)};
63 context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin,
64 kRGBA_8888_SkColorType, kPremul_SkAlphaType,
nullptr));
static sk_sp< DlImage > Make(const SkImage *image)
std::unordered_map< HardwareBufferKey, GlEntry > gl_entries_
void Attach(PaintContext &context) override
ImageExternalTextureGLSkia(const std::shared_ptr< AndroidContextGLSkia > &context, int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &image_textury_entry, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade, ImageExternalTexture::ImageLifecycle lifecycle)
ImageLifecycle
Whether the last image should be reset when the context is destroyed.
void reset(const T &value=Traits::InvalidValue())
FlutterVulkanImage * image
FlutterVulkanImageHandle image