diff options
author | 2017-06-16 18:07:54 -0700 | |
---|---|---|
committer | 2017-06-16 18:07:54 -0700 | |
commit | 88e060f8817a4d8969fd55f07760c168f9620efc (patch) | |
tree | f5cc6196021b3f4165749a09cd8969c163c5cfa0 /libs/hwui/OpenGLReadback.cpp | |
parent | e9bec628542ba1d87a3783faae9efbf7cce8611f (diff) |
Add support for RGBA_F16 readbacks
WCG windows render into RGBA16F surfaces, we need to give the readback
API the ability to read the raw source data for testing.
Bug: 62728191
Test: CtsViewTestCases
Change-Id: I93ead84207dab38fba02d4419b5ae18df9555f8e
Diffstat (limited to 'libs/hwui/OpenGLReadback.cpp')
-rw-r--r-- | libs/hwui/OpenGLReadback.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/libs/hwui/OpenGLReadback.cpp b/libs/hwui/OpenGLReadback.cpp index 4ef0f4bd2712..b073070b58b6 100644 --- a/libs/hwui/OpenGLReadback.cpp +++ b/libs/hwui/OpenGLReadback.cpp @@ -133,8 +133,7 @@ inline CopyResult copyTextureInto(Caches& caches, RenderState& renderState, return CopyResult::DestinationInvalid; } - // TODO: Add support for RGBA_F16 destinations - if (bitmap->colorType() == kRGBA_F16_SkColorType) { + if (bitmap->colorType() == kRGBA_F16_SkColorType && !caches.extensions().hasFloatTextures()) { ALOGW("Can't copy surface into bitmap, RGBA_F16 config is not supported"); return CopyResult::DestinationInvalid; } @@ -148,24 +147,34 @@ inline CopyResult copyTextureInto(Caches& caches, RenderState& renderState, GLuint texture; GLenum format; + GLenum internalFormat; GLenum type; switch (bitmap->colorType()) { case kAlpha_8_SkColorType: format = GL_ALPHA; + internalFormat = GL_ALPHA; type = GL_UNSIGNED_BYTE; break; case kRGB_565_SkColorType: format = GL_RGB; + internalFormat = GL_RGB; type = GL_UNSIGNED_SHORT_5_6_5; break; case kARGB_4444_SkColorType: format = GL_RGBA; + internalFormat = GL_RGBA; type = GL_UNSIGNED_SHORT_4_4_4_4; break; + case kRGBA_F16_SkColorType: + format = GL_RGBA; + internalFormat = GL_RGBA16F; + type = GL_HALF_FLOAT; + break; case kN32_SkColorType: default: format = GL_RGBA; + internalFormat = GL_RGBA; type = GL_UNSIGNED_BYTE; break; } @@ -184,7 +193,7 @@ inline CopyResult copyTextureInto(Caches& caches, RenderState& renderState, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexImage2D(GL_TEXTURE_2D, 0, format, destWidth, destHeight, + glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, destWidth, destHeight, 0, format, type, nullptr); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); @@ -220,6 +229,7 @@ inline CopyResult copyTextureInto(Caches& caches, RenderState& renderState, ortho.loadOrtho(destWidth, destHeight); renderState.render(glop, ortho); + // TODO: We should convert to linear space when the target is RGBA16F glReadPixels(0, 0, bitmap->width(), bitmap->height(), format, type, bitmap->getPixels()); } |