Index: cc/output/gl_renderer.cc |
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc |
index 89b1e00554a01a3e2eed1ac300305bae578e7be0..67d02a434f3bcd2c6cd781e6a286ed3d3087ef30 100644 |
--- a/cc/output/gl_renderer.cc |
+++ b/cc/output/gl_renderer.cc |
@@ -258,6 +258,8 @@ GLRenderer::~GLRenderer() { |
pending_async_read_pixels_.pop_back(); |
} |
+ in_use_overlay_resources_.clear(); |
+ |
CleanupSharedObjects(); |
} |
@@ -2000,6 +2002,8 @@ void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { |
GLC(gl_, gl_->Disable(GL_BLEND)); |
blend_shadow_ = false; |
+ |
+ ScheduleOverlays(frame); |
} |
void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } |
@@ -2171,6 +2175,11 @@ void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { |
} |
output_surface_->SwapBuffers(&compositor_frame); |
+ // Release previously used overlay resources and hold onto the pending ones |
+ // until the next swap buffers. |
+ in_use_overlay_resources_.clear(); |
+ in_use_overlay_resources_.swap(pending_overlay_resources_); |
+ |
swap_buffer_rect_ = gfx::Rect(); |
// We don't have real fences, so we mark read fences as passed |
@@ -3047,4 +3056,30 @@ bool GLRenderer::IsContextLost() { |
return output_surface_->context_provider()->IsContextLost(); |
} |
+void GLRenderer::ScheduleOverlays(DrawingFrame* frame) { |
+ if (!frame->overlay_list.size()) |
+ return; |
+ |
+ ResourceProvider::ResourceIdArray resources; |
+ OverlayCandidateList& overlays = frame->overlay_list; |
+ OverlayCandidateList::iterator it; |
+ for (it = overlays.begin(); it != overlays.end(); ++it) { |
+ const OverlayCandidate& overlay = *it; |
+ // Skip primary plane. |
+ if (overlay.plane_z_order == 0) |
+ continue; |
+ |
+ pending_overlay_resources_.push_back( |
+ make_scoped_ptr(new ResourceProvider::ScopedExportLock( |
+ resource_provider(), overlay.resource_id))); |
+ |
+ context_support_->ScheduleOverlayPlane( |
+ overlay.plane_z_order, |
+ overlay.transform, |
+ pending_overlay_resources_.back()->GetMailbox(), |
+ overlay.display_rect, |
+ overlay.uv_rect); |
+ } |
+} |
+ |
} // namespace cc |