Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3059)

Unified Diff: cc/output/gl_renderer.cc

Issue 2015923003: Reland of Add logic to ResourceProvider to correctly lock GpuMemoryBuffer Resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/resources/resource_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 1c33fe663f15adfcab6193ea2b8b2809165fce21..437dfa8fdd549b417b19eb8c501953be2f64ee4e 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -394,7 +394,6 @@
pending_async_read_pixels_.pop_back();
}
- swapped_overlay_resources_.clear();
CleanupSharedObjects();
}
@@ -2717,23 +2716,51 @@
}
compositor_frame.gl_frame_data->sub_buffer_rect = swap_buffer_rect_;
}
- output_surface_->SwapBuffers(&compositor_frame);
+
+ swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_));
+ pending_overlay_resources_.clear();
// We always hold onto resources until an extra frame has swapped, to make
// sure we don't update the buffer while it's being scanned out.
- swapped_overlay_resources_.push_back(std::move(pending_overlay_resources_));
- pending_overlay_resources_.clear();
if (!settings_->release_overlay_resources_on_swap_complete &&
- swapped_overlay_resources_.size() > 2) {
- swapped_overlay_resources_.pop_front();
- }
+ swapping_overlay_resources_.size() > 2) {
+ swapping_overlay_resources_.pop_front();
+ }
+
+ output_surface_->SwapBuffers(&compositor_frame);
+
swap_buffer_rect_ = gfx::Rect();
}
void GLRenderer::SwapBuffersComplete() {
- if (settings_->release_overlay_resources_on_swap_complete &&
- !swapped_overlay_resources_.empty()) {
- swapped_overlay_resources_.pop_front();
+ // On OS X, the logic in this block moves resources into
+ // |swapped_and_acked_overlay_resources_|, and then erases resources from
+ // |swapped_and_acked_overlay_resources_| that are no longer in use by the
+ // Window Server. On other platforms, since resources are never in use by the
+ // Window Server, this is equivalent to just erasing all resources from the
+ // first element of |swapping_overlay_resources_|.
+ if (settings_->release_overlay_resources_on_swap_complete) {
+ // Move resources known to be acked into
+ // |swapped_and_acked_overlay_resources_|.
+ if (!swapping_overlay_resources_.empty()) {
+ for (OverlayResourceLock& lock : swapping_overlay_resources_.front()) {
+ swapped_and_acked_overlay_resources_[lock->GetResourceId()] =
+ std::move(lock);
+ }
+ swapping_overlay_resources_.pop_front();
+ }
+
+ // Release resources that are no longer in use by the Window Server.
+ auto it = swapped_and_acked_overlay_resources_.begin();
+ while (it != swapped_and_acked_overlay_resources_.end()) {
+ if (it->second->GetGpuMemoryBuffer() &&
+ it->second->GetGpuMemoryBuffer()->IsInUseByMacOSWindowServer()) {
+ ++it;
+ continue;
+ }
+
+ it = swapped_and_acked_overlay_resources_.erase(it);
+ }
}
}
@@ -3604,9 +3631,9 @@
unsigned texture_id = 0;
if (ca_layer_overlay.contents_resource_id) {
pending_overlay_resources_.push_back(
- base::WrapUnique(new ResourceProvider::ScopedReadLockGL(
+ base::WrapUnique(new ResourceProvider::ScopedReadLockGpuMemoryBuffer(
resource_provider_, ca_layer_overlay.contents_resource_id)));
- texture_id = pending_overlay_resources_.back()->texture_id();
+ texture_id = pending_overlay_resources_.back()->GetTextureId();
}
GLfloat contents_rect[4] = {
ca_layer_overlay.contents_rect.x(), ca_layer_overlay.contents_rect.y(),
@@ -3647,9 +3674,9 @@
DCHECK(texture_id || IsContextLost());
} else {
pending_overlay_resources_.push_back(
- base::WrapUnique(new ResourceProvider::ScopedReadLockGL(
+ base::WrapUnique(new ResourceProvider::ScopedReadLockGpuMemoryBuffer(
resource_provider_, overlay.resource_id)));
- texture_id = pending_overlay_resources_.back()->texture_id();
+ texture_id = pending_overlay_resources_.back()->GetTextureId();
}
context_support_->ScheduleOverlayPlane(
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/resources/resource_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698