Skip to content

Commit

Permalink
Fix gpu surface coordinte issue
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaowei-guan committed Apr 29, 2024
1 parent ace9a97 commit 6e2a3c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion shell/platform/embedder/embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ typedef struct {
} FlutterTransformation;

typedef void (*VoidCallback)(void* /* user data */);
typedef bool (*BoolCallback)(void* /* user data */);

typedef enum {
/// Specifies an OpenGL texture target type. Textures are specified using
Expand Down Expand Up @@ -371,6 +372,8 @@ typedef struct {
uint32_t format;
/// User data to be returned on the invocation of the destruction callback.
void* user_data;
/// Callback invoked that texture start binding.
BoolCallback bind_callback;
/// Callback invoked (on an engine managed thread) that asks the embedder to
/// collect the texture.
VoidCallback destruction_callback;
Expand Down Expand Up @@ -414,7 +417,6 @@ typedef enum {
kFlutterGpuSurfaceTexture
} FlutterTextureType;

typedef bool (*BoolCallback)(void* /* user data */);
typedef FlutterTransformation (*TransformationCallback)(void* /* user data */);
typedef uint32_t (*UIntCallback)(void* /* user data */);
typedef bool (*SoftwareSurfacePresentCallback)(void* /* user data */,
Expand Down
11 changes: 9 additions & 2 deletions shell/platform/embedder/embedder_external_texture_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ sk_sp<DlImage> EmbedderExternalTextureSkiaGL::ResolveTexture(
if (release_proc) {
release_proc(texture->user_data);
}
FML_LOG(ERROR) << "Could not create external texture->";
return nullptr;
}

Expand Down Expand Up @@ -201,7 +200,6 @@ sk_sp<DlImage> EmbedderExternalTextureGLImpellerSurface::ResolveTexture(
if (!texture) {
return nullptr;
}

size_t width = size.width();
size_t height = size.height();

Expand All @@ -222,13 +220,22 @@ sk_sp<DlImage> EmbedderExternalTextureGLImpellerSurface::ResolveTexture(
auto textureGLES = std::make_shared<impeller::TextureGLES>(
gl_context.GetReactor(), desc,
impeller::TextureGLES::IsWrapped::kWrapped);
textureGLES->SetCoordinateSystem(
impeller::TextureCoordinateSystem::kUploadFromHost);
if (!textureGLES->Bind()) {
if (texture->destruction_callback) {
texture->destruction_callback(texture->user_data);
}
return nullptr;
}

if (!texture->bind_callback(texture->user_data)) {
if (texture->destruction_callback) {
texture->destruction_callback(texture->user_data);
}
return nullptr;
}

if (texture->destruction_callback) {
texture->destruction_callback(texture->user_data);
}
Expand Down

0 comments on commit 6e2a3c7

Please sign in to comment.