Commit ebea30f5 authored by Alexis Hetu's avatar Alexis Hetu Committed by Commit Bot

Allow RG8 format for SkImage created from texture

Using an RGBA8 image for an RG8 texture was causing confusion in the
underlying driver where copyTexSubImage could be disallowed because
of unequal formats between the framebuffer and texture (RG8 vs RGBA8)
while the application was seeing 2 RGBA8 textures. Removing the
workaround is now possible and fixes the issue.

Bug: 985458
Change-Id: I6a1ac80f05adb67917ddda34835c9be7f0d5d1ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2499264Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: default avatarAndres Calderon Jaramillo <andrescj@chromium.org>
Commit-Queue: Alexis Hétu <sugoi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820905}
parent 33b0d70c
......@@ -182,19 +182,10 @@ class ImageTransferCacheEntryTest
DCHECK_EQ(height, allocated_texture.height());
DCHECK(!allocated_texture.hasMipMaps());
DCHECK(allocated_texture_info.fTarget == GL_TEXTURE_2D);
if (texture_format == GL_RG8_EXT) {
// TODO(crbug.com/985458): using GL_RGBA8_EXT is a workaround so that we
// can make a SkImage out of a GL_RG8_EXT texture. Revisit this once Skia
// supports a corresponding SkColorType.
allocated_texture = GrBackendTexture(
width, height, GrMipMapped::kNo,
GrGLTextureInfo{GL_TEXTURE_2D, allocated_texture_info.fID,
GL_RGBA8_EXT});
}
*released = false;
return SkImage::MakeFromTexture(
gr_context, allocated_texture, kTopLeft_GrSurfaceOrigin,
texture_format == GL_RG8_EXT ? kRGBA_8888_SkColorType
texture_format == GL_RG8_EXT ? kR8G8_unorm_SkColorType
: kAlpha_8_SkColorType,
kOpaque_SkAlphaType, nullptr /* colorSpace */, MarkTextureAsReleased,
released);
......
......@@ -358,17 +358,14 @@ void ImageDecodeAcceleratorStub::ProcessCompletedDecode(
shared_context_state->PessimisticallyResetGrContext();
// Create a SkImage using the texture.
// TODO(crbug.com/985458): ideally, we use GL_RG8_EXT for the NV12 chroma
// plane. However, Skia does not have a corresponding SkColorType. Revisit
// this when it's supported.
const GrBackendTexture plane_backend_texture(
plane_size.width(), plane_size.height(), GrMipMapped::kNo,
GrGLTextureInfo{GL_TEXTURE_EXTERNAL_OES, resource->texture,
is_nv12_chroma_plane ? GL_RGBA8_EXT : GL_R8_EXT});
is_nv12_chroma_plane ? GL_RG8_EXT : GL_R8_EXT});
plane_sk_images[plane] = SkImage::MakeFromTexture(
shared_context_state->gr_context(), plane_backend_texture,
kTopLeft_GrSurfaceOrigin,
is_nv12_chroma_plane ? kRGBA_8888_SkColorType : kAlpha_8_SkColorType,
is_nv12_chroma_plane ? kR8G8_unorm_SkColorType : kAlpha_8_SkColorType,
kOpaque_SkAlphaType, nullptr /* colorSpace */, CleanUpResource,
resource);
if (!plane_sk_images[plane]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment