Index: cc/output/gl_renderer.cc |
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc |
index 074d603b909daa5cff3e99bc5b424d43d26fd54b..e5e1f2827fb45496ee8ba26b4a5c0a5386041268 100644 |
--- a/cc/output/gl_renderer.cc |
+++ b/cc/output/gl_renderer.cc |
@@ -653,8 +653,8 @@ scoped_ptr<ScopedResource> GLRenderer::DrawBackgroundFilters( |
scoped_ptr<ScopedResource> device_background_texture = |
ScopedResource::create(resource_provider_); |
if (!device_background_texture->Allocate(window_rect.size(), |
- GL_RGB, |
- ResourceProvider::TextureUsageAny)) { |
+ ResourceProvider::TextureUsageAny, |
+ RGBA_8888)) { |
return scoped_ptr<ScopedResource>(); |
} else { |
ResourceProvider::ScopedWriteLockGL lock(resource_provider_, |
@@ -679,8 +679,8 @@ scoped_ptr<ScopedResource> GLRenderer::DrawBackgroundFilters( |
scoped_ptr<ScopedResource> background_texture = |
ScopedResource::create(resource_provider_); |
if (!background_texture->Allocate(quad->rect.size(), |
- GL_RGBA, |
- ResourceProvider::TextureUsageFramebuffer)) |
+ ResourceProvider::TextureUsageFramebuffer, |
+ RGBA_8888)) |
return scoped_ptr<ScopedResource>(); |
const RenderPass* target_render_pass = frame->current_render_pass; |
@@ -1702,10 +1702,10 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, |
on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( |
quad->texture_size, |
- GL_RGBA, |
GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, |
GL_CLAMP_TO_EDGE, |
- ResourceProvider::TextureUsageAny); |
+ ResourceProvider::TextureUsageAny, |
+ quad->texture_format); |
} |
SkBitmapDevice device(on_demand_tile_raster_bitmap_); |
@@ -1714,9 +1714,25 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, |
quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, |
quad->contents_scale, NULL); |
+ uint8_t* bitmap_pixels = NULL; |
+ SkBitmap on_demand_tile_raster_bitmap_dest; |
+ SkBitmap::Config config = SkBitmapConfigFromFormat(quad->texture_format); |
+ if (on_demand_tile_raster_bitmap_.getConfig() != config) { |
+ on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest, |
+ config); |
+ // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the |
+ // bitmap data. This check will be removed once crbug.com/293728 is fixed. |
+ CHECK_EQ(0u, on_demand_tile_raster_bitmap_dest.rowBytes() % 4); |
+ bitmap_pixels = reinterpret_cast<uint8_t*>( |
+ on_demand_tile_raster_bitmap_dest.getPixels()); |
+ } else { |
+ bitmap_pixels = reinterpret_cast<uint8_t*>( |
+ on_demand_tile_raster_bitmap_.getPixels()); |
+ } |
+ |
resource_provider_->SetPixels( |
on_demand_tile_raster_resource_id_, |
- reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), |
+ bitmap_pixels, |
gfx::Rect(quad->texture_size), |
gfx::Rect(quad->texture_size), |
gfx::Vector2d()); |
@@ -2205,7 +2221,7 @@ void GLRenderer::GetFramebufferPixelsAsync( |
GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
GLC(context_, context_->texParameteri( |
GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
- GetFramebufferTexture(texture_id, GL_RGBA, window_rect); |
+ GetFramebufferTexture(texture_id, RGBA_8888, window_rect); |
gpu::Mailbox mailbox; |
unsigned sync_point = 0; |
@@ -2297,7 +2313,7 @@ void GLRenderer::DoGetFramebufferPixels( |
// Copy the contents of the current (IOSurface-backed) framebuffer into a |
// temporary texture. |
GetFramebufferTexture(temporary_texture, |
- GL_RGBA, |
+ RGBA_8888, |
gfx::Rect(current_surface_size_)); |
temporary_fbo = context_->createFramebuffer(); |
// Attach this texture to an FBO, and perform the readback from that FBO. |
@@ -2447,9 +2463,8 @@ void GLRenderer::PassOnSkBitmap( |
request->SendBitmapResult(bitmap.Pass()); |
} |
-void GLRenderer::GetFramebufferTexture(unsigned texture_id, |
- unsigned texture_format, |
- gfx::Rect window_rect) { |
+void GLRenderer::GetFramebufferTexture( |
+ unsigned texture_id, ResourceFormat texture_format, gfx::Rect window_rect) { |
DCHECK(texture_id); |
DCHECK_GE(window_rect.x(), 0); |
DCHECK_GE(window_rect.y(), 0); |
@@ -2458,14 +2473,15 @@ void GLRenderer::GetFramebufferTexture(unsigned texture_id, |
GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); |
GLC(context_, |
- context_->copyTexImage2D(GL_TEXTURE_2D, |
- 0, |
- texture_format, |
- window_rect.x(), |
- window_rect.y(), |
- window_rect.width(), |
- window_rect.height(), |
- 0)); |
+ context_->copyTexImage2D( |
+ GL_TEXTURE_2D, |
+ 0, |
+ ResourceProvider::GetGLDataFormat(texture_format), |
+ window_rect.x(), |
+ window_rect.y(), |
+ window_rect.width(), |
+ window_rect.height(), |
+ 0)); |
GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); |
} |