Chromium Code Reviews| Index: content/common/gpu/client/gl_helper.cc |
| diff --git a/content/common/gpu/client/gl_helper.cc b/content/common/gpu/client/gl_helper.cc |
| index 7da9389bc10ef9c31f001eb5757a344f3ba69f30..0b0561d084b3ba8460533eb2aed491dddf760bc9 100644 |
| --- a/content/common/gpu/client/gl_helper.cc |
| +++ b/content/common/gpu/client/gl_helper.cc |
| @@ -127,7 +127,7 @@ class GLHelper::CopyTextureToImpl |
| const gfx::Rect& src_subrect, |
| const gfx::Size& dst_size, |
| unsigned char* out, |
| - bool readback_config_rgb565, |
| + const SkBitmap::Config config, |
| const base::Callback<void(bool)>& callback, |
| GLHelper::ScalerQuality quality); |
| @@ -142,7 +142,7 @@ class GLHelper::CopyTextureToImpl |
| int32 bytes_per_row, // generally dst_size.width() * 4 |
| int32 row_stride_bytes, // generally dst_size.width() * 4 |
| unsigned char* out, |
| - bool readback_config_rgb565, |
| + const SkBitmap::Config config, |
| const base::Callback<void(bool)>& callback); |
| void ReadbackPlane(TextureFrameBufferPair* source, |
| @@ -288,7 +288,7 @@ class GLHelper::CopyTextureToImpl |
| const gfx::Size& dst_size, |
| bool vertically_flip_texture, |
| bool swizzle, |
| - bool readback_config_rgb565, |
| + SkBitmap::Config config, |
| GLHelper::ScalerQuality quality); |
| static void nullcallback(bool success) {} |
| @@ -334,7 +334,7 @@ GLuint GLHelper::CopyTextureToImpl::ScaleTexture( |
| const gfx::Size& dst_size, |
| bool vertically_flip_texture, |
| bool swizzle, |
| - bool readback_config_rgb565, |
| + SkBitmap::Config config, |
| GLHelper::ScalerQuality quality) { |
| scoped_ptr<ScalerInterface> scaler( |
| helper_->CreateScaler(quality, |
| @@ -348,10 +348,18 @@ GLuint GLHelper::CopyTextureToImpl::ScaleTexture( |
| gl_->GenTextures(1, &dst_texture); |
| { |
| ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture); |
| - GLenum format = readback_config_rgb565 ? GL_RGB : GL_RGBA; |
| - GLenum type = readback_config_rgb565 ? |
| - GL_UNSIGNED_SHORT_5_6_5 : |
| - GL_UNSIGNED_BYTE; |
| + GLenum format, type; |
| + switch (config) { |
| + case SkBitmap::kRGB_565_Config: |
| + format = GL_RGB; |
| + type = GL_UNSIGNED_SHORT_5_6_5; |
| + break; |
| + case SkBitmap::kARGB_8888_Config: |
| + default: |
|
piman
2014/01/21 21:30:55
I don't think we should transparently fallback to
sivag
2014/01/22 10:35:09
Done.
|
| + format = GL_RGBA; |
| + type = GL_UNSIGNED_BYTE; |
| + break; |
| + } |
| gl_->TexImage2D(GL_TEXTURE_2D, |
| 0, |
| format, |
| @@ -371,13 +379,27 @@ void GLHelper::CopyTextureToImpl::ReadbackAsync( |
| int32 bytes_per_row, |
| int32 row_stride_bytes, |
| unsigned char* out, |
| - bool readback_config_rgb565, |
| + const SkBitmap::Config config, |
| const base::Callback<void(bool)>& callback) { |
| Request* request = |
| new Request(dst_size, bytes_per_row, row_stride_bytes, out, callback); |
| request_queue_.push(request); |
| request->buffer = 0u; |
| - int bytes_per_pixel = readback_config_rgb565 ? 2 : 4; |
| + GLenum format, type; |
| + int bytes_per_pixel = 0; |
| + switch (config) { |
| + case SkBitmap::kRGB_565_Config: |
| + format = GL_RGB; |
| + type = GL_UNSIGNED_SHORT_5_6_5; |
| + bytes_per_pixel = 2; |
| + break; |
| + case SkBitmap::kARGB_8888_Config: |
| + default: |
|
piman
2014/01/21 21:30:55
Same here.
sivag
2014/01/22 10:35:09
Done.
|
| + format = GL_RGBA; |
| + type = GL_UNSIGNED_BYTE; |
| + bytes_per_pixel = 4; |
| + break; |
| + } |
| gl_->GenBuffers(1, &request->buffer); |
| gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, request->buffer); |
| gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
| @@ -388,10 +410,6 @@ void GLHelper::CopyTextureToImpl::ReadbackAsync( |
| request->query = 0u; |
| gl_->GenQueriesEXT(1, &request->query); |
| gl_->BeginQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, request->query); |
| - GLenum format = readback_config_rgb565 ? GL_RGB : GL_RGBA; |
| - GLenum type = readback_config_rgb565 ? |
| - GL_UNSIGNED_SHORT_5_6_5 : |
| - GL_UNSIGNED_BYTE; |
| gl_->ReadPixels(0, |
| 0, |
| dst_size.width(), |
| @@ -412,7 +430,7 @@ void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture( |
| const gfx::Rect& src_subrect, |
| const gfx::Size& dst_size, |
| unsigned char* out, |
| - bool readback_config_rgb565, |
| + const SkBitmap::Config bitmap_config, |
| const base::Callback<void(bool)>& callback, |
| GLHelper::ScalerQuality quality) { |
| GLuint texture = ScaleTexture(src_texture, |
| @@ -425,7 +443,7 @@ void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture( |
| #else |
| false, |
| #endif |
| - readback_config_rgb565, |
| + bitmap_config, |
| quality); |
| ScopedFramebuffer dst_framebuffer(gl_); |
| ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, |
| @@ -436,12 +454,21 @@ void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture( |
| GL_TEXTURE_2D, |
| texture, |
| 0); |
| - int bytes_per_pixel = readback_config_rgb565 ? 2 : 4; |
| + int bytes_per_pixel = 0; |
| + switch (bitmap_config) { |
| + case SkBitmap::kRGB_565_Config: |
| + bytes_per_pixel = 2; |
| + break; |
| + case SkBitmap::kARGB_8888_Config: |
| + default: |
|
piman
2014/01/21 21:30:55
And here
sivag
2014/01/22 10:35:09
Done.
|
| + bytes_per_pixel = 4; |
| + break; |
| + } |
| ReadbackAsync(dst_size, |
| dst_size.width() * bytes_per_pixel, |
| dst_size.width() * bytes_per_pixel, |
| out, |
| - readback_config_rgb565, |
| + bitmap_config, |
| callback); |
| gl_->DeleteTextures(1, &texture); |
| } |
| @@ -485,7 +512,7 @@ GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture( |
| dst_size, |
| vertically_flip_texture, |
| false, |
| - false, |
| + SkBitmap::kARGB_8888_Config, |
| quality); |
| } |
| @@ -568,7 +595,7 @@ void GLHelper::CropScaleReadbackAndCleanTexture( |
| const gfx::Rect& src_subrect, |
| const gfx::Size& dst_size, |
| unsigned char* out, |
| - bool readback_config_rgb565, |
| + const SkBitmap::Config config, |
| const base::Callback<void(bool)>& callback) { |
| InitCopyTextToImpl(); |
| copy_texture_to_impl_->CropScaleReadbackAndCleanTexture( |
| @@ -577,7 +604,7 @@ void GLHelper::CropScaleReadbackAndCleanTexture( |
| src_subrect, |
| dst_size, |
| out, |
| - readback_config_rgb565, |
| + config, |
| callback, |
| GLHelper::SCALER_QUALITY_FAST); |
| } |
| @@ -589,12 +616,12 @@ void GLHelper::CropScaleReadbackAndCleanMailbox( |
| const gfx::Rect& src_subrect, |
| const gfx::Size& dst_size, |
| unsigned char* out, |
| - bool readback_config_rgb565, |
| + const SkBitmap::Config bitmap_config, |
| const base::Callback<void(bool)>& callback) { |
| GLuint mailbox_texture = ConsumeMailboxToTexture(src_mailbox, sync_point); |
| CropScaleReadbackAndCleanTexture( |
| mailbox_texture, src_size, src_subrect, dst_size, out, |
| - readback_config_rgb565, |
| + bitmap_config, |
| callback); |
| gl_->DeleteTextures(1, &mailbox_texture); |
| } |
| @@ -826,7 +853,7 @@ void GLHelper::CopyTextureToImpl::ReadbackPlane( |
| dst_subrect.width() >> size_shift, |
| target->stride(plane), |
| target->data(plane) + offset, |
| - false, |
| + SkBitmap::kARGB_8888_Config, |
| callback); |
| } |