Index: cc/output/gl_renderer.cc |
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc |
index 0b56c9d400ac7158bf4ac5eefc1139fd818d2ec8..5d594275a4615a871f548775b295982a2c6a9295 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; |
@@ -1689,6 +1689,7 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, |
return; |
} |
+ ResourceFormat format = resource_provider_->memory_efficient_texture_format(); |
if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || |
on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { |
on_demand_tile_raster_bitmap_.setConfig( |
@@ -1700,12 +1701,13 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, |
if (on_demand_tile_raster_resource_id_) |
resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
+ |
reveman
2013/09/17 02:48:12
nit: no need for this blank line
kaanb
2013/09/17 04:12:18
Done.
|
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 +1716,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(format); |
reveman
2013/09/17 02:48:12
this should be using quad->texture_format
kaanb
2013/09/17 04:12:18
Done.
|
+ 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()); |
+ } 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 +2220,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 +2312,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 +2462,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 +2472,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)); |
} |