9#include "third_party/skia/include/core/SkColorSpace.h"
10#include "third_party/skia/include/gpu/ganesh/GrBackendSurface.h"
11#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
12#include "third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h"
13#include "third_party/skia/include/gpu/ganesh/gl/GrGLTypes.h"
25 sk_sp<GrDirectContext> context,
27 std::shared_ptr<TestEGLContext> egl_context)
29 test_egl_context_(
std::move(egl_context)) {}
39 return CreateTexture(config, backing_store_out);
41 return CreateFramebuffer(config, backing_store_out);
43 return CreateSurface(config, backing_store_out);
66 return user_data->gl_surface->GetRasterSurfaceSnapshot();
70 return user_data->surface->makeImageSnapshot();
73bool EmbedderTestBackingStoreProducerGL::CreateFramebuffer(
76 const auto image_info =
80 SkSurfaces::RenderTarget(
context_.get(),
84 kBottomLeft_GrSurfaceOrigin,
90 FML_LOG(ERROR) <<
"Could not create render target for compositor layer.";
94 GrBackendRenderTarget render_target = SkSurfaces::GetBackendRenderTarget(
95 surface.get(), SkSurfaces::BackendHandleAccess::kDiscardWrite);
97 if (!render_target.isValid()) {
98 FML_LOG(ERROR) <<
"Backend render target was invalid.";
102 GrGLFramebufferInfo framebuffer_info = {};
103 if (!GrBackendRenderTargets::GetGLFramebufferInfo(render_target,
104 &framebuffer_info)) {
105 FML_LOG(ERROR) <<
"Could not access backend framebuffer info.";
122bool EmbedderTestBackingStoreProducerGL::CreateTexture(
125 const auto image_info =
129 SkSurfaces::RenderTarget(
context_.get(),
130 skgpu::Budgeted::kNo,
133 kBottomLeft_GrSurfaceOrigin,
139 FML_LOG(ERROR) <<
"Could not create render target for compositor layer.";
143 GrBackendTexture render_texture = SkSurfaces::GetBackendTexture(
144 surface.get(), SkSurfaces::BackendHandleAccess::kDiscardWrite);
146 if (!render_texture.isValid()) {
147 FML_LOG(ERROR) <<
"Backend render texture was invalid.";
151 GrGLTextureInfo texture_info = {};
152 if (!GrBackendTextures::GetGLTextureInfo(render_texture, &texture_info)) {
153 FML_LOG(ERROR) <<
"Could not access backend texture info.";
171bool EmbedderTestBackingStoreProducerGL::CreateSurface(
175 auto surface = std::make_unique<TestGLOnscreenOnlySurface>(
179 auto make_current = [](
void*
user_data,
bool* invalidate_state) ->
bool {
180 *invalidate_state =
false;
184 auto clear_current = [](
void*
user_data,
bool* invalidate_state) ->
bool {
185 *invalidate_state =
false;
191 auto destruction_callback = [](
void*
user_data) {
192 delete reinterpret_cast<UserData*
>(
user_data);
195 auto sk_surface =
surface->GetOnscreenSurface();
198 .surface = sk_surface,
199 .gl_surface = std::move(surface),
208 destruction_callback;
virtual ~EmbedderTestBackingStoreProducerGL()
EmbedderTestBackingStoreProducerGL(sk_sp< GrDirectContext > context, RenderTargetType type, std::shared_ptr< TestEGLContext > egl_context)
bool Create(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out) override
sk_sp< SkImage > MakeImageSnapshot(const FlutterBackingStore *backing_store) const override
sk_sp< SkSurface > GetSurface(const FlutterBackingStore *backing_store) const override
sk_sp< GrDirectContext > context_
@ kFlutterOpenGLTargetTypeFramebuffer
@ kFlutterOpenGLTargetTypeSurface
@ kFlutterOpenGLTargetTypeTexture
@ kFlutterBackingStoreTypeOpenGL
std::unique_ptr< TestGLOnscreenOnlySurface > gl_surface
#define FML_LOG(severity)
#define FML_CHECK(condition)
impeller::ISize32 DlISize
FlutterSize size
The size of the render target the engine expects to render into.
FlutterBackingStoreType type
Specifies the type of backing store.
FlutterOpenGLBackingStore open_gl
The description of the OpenGL backing store.
FlutterOpenGLSurface surface
FlutterOpenGLTexture texture
A texture for Flutter to render into.
FlutterOpenGLTargetType type
FlutterOpenGLFramebuffer framebuffer
uint32_t name
The name of the framebuffer.
VoidCallback destruction_callback
void * user_data
User data to be returned on the invocation of the destruction callback.
VoidCallback destruction_callback
FlutterOpenGLSurfaceCallback clear_current_callback
FlutterOpenGLSurfaceCallback make_current_callback
uint32_t name
The name of the texture.
VoidCallback destruction_callback
void * user_data
User data to be returned on the invocation of the destruction callback.
uint32_t format
The texture format (example GL_RGBA8).