Chromium Code Reviews| Index: cc/output/gl_renderer.cc |
| diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc |
| index 0b56c9d400ac7158bf4ac5eefc1139fd818d2ec8..c1fe2673bdc57f49a3d1dd1bf9f082e86a5404a3 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,22 @@ 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); |
| + bitmap_pixels = reinterpret_cast<uint8_t*>( |
| + on_demand_tile_raster_bitmap_dest.getPixels()); |
|
reveman
2013/09/17 22:09:38
Add the same CHECK_EQ and TODO here.
kaanb
2013/09/17 22:40:01
Done.
|
| + } 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 +2218,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 +2310,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 +2460,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 +2470,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)); |
| } |