Index: cc/output/gl_renderer.cc |
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc |
index 48611c498189b0050a4856998c214834d509a370..c1f73f82aaaf4fcb5bc5459ce1a16c426d99e82c 100644 |
--- a/cc/output/gl_renderer.cc |
+++ b/cc/output/gl_renderer.cc |
@@ -3942,7 +3942,29 @@ void GLRenderer::CopyRenderPassDrawQuadToOverlayResource( |
// |params.dst_rect| now contain values that reflect a potentially increased |
// size quad. |
gfx::RectF updated_dst_rect = params.dst_rect; |
- *new_bounds = updated_dst_rect; |
+ |
+ // Round the size of the IOSurface to a multiple of 64 pixels. This reduces |
+ // memory fragmentation. https://crbug.com/146070. This also allows IOSurfaces |
+ // to be more easily reused during a resize operation. |
+ uint32_t iosurface_multiple = 64; |
ccameron
2016/08/15 18:37:06
May be more concise to do
updated_dst_rest.set_w
erikchen
2016/08/15 19:31:57
Done, although we can't change updated_dst_rect, s
|
+ uint32_t iosurface_width = updated_dst_rect.width(); |
+ if (iosurface_width % iosurface_multiple != 0) { |
+ iosurface_width -= iosurface_width % iosurface_multiple; |
+ iosurface_width += iosurface_multiple; |
+ } |
+ |
+ uint32_t iosurface_height = updated_dst_rect.height(); |
+ if (iosurface_height % iosurface_multiple != 0) { |
+ iosurface_height -= iosurface_height % iosurface_multiple; |
+ iosurface_height += iosurface_multiple; |
+ } |
+ |
+ *resource = overlay_resource_pool_->AcquireResource( |
+ gfx::Size(iosurface_width, iosurface_height), ResourceFormat::RGBA_8888, |
+ output_surface_->device_color_space()); |
+ *new_bounds = |
+ gfx::RectF(updated_dst_rect.x(), updated_dst_rect.y(), |
+ (*resource)->size().width(), (*resource)->size().height()); |
// Calculate new projection and window matrices for a minimally sized viewport |
// using InitializeViewport(). This requires creating a dummy DrawingFrame. |
@@ -3982,9 +4004,6 @@ void GLRenderer::CopyRenderPassDrawQuadToOverlayResource( |
} |
// Establish destination texture. |
- *resource = overlay_resource_pool_->AcquireResource( |
- gfx::Size(updated_dst_rect.width(), updated_dst_rect.height()), |
- ResourceFormat::RGBA_8888, output_surface_->device_color_space()); |
ResourceProvider::ScopedWriteLockGL destination(resource_provider_, |
(*resource)->id(), false); |
GLuint temp_fbo; |