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

Unified Diff: cc/gl_renderer.cc

Issue 12197004: cc: Enforce correct recycling in resource pool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved to renderer. Addressed feedback. Created 7 years, 10 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 | « no previous file | cc/resource_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/gl_renderer.cc
diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc
index b3bad726fbef27b43eb65f2414cddf9aa8695f15..8c0e9fb1692c11436413819bb2a0cf742c60970f 100644
--- a/cc/gl_renderer.cc
+++ b/cc/gl_renderer.cc
@@ -1282,6 +1282,23 @@ void GLRenderer::finish()
m_context->finish();
}
+// TODO(epenner): This should probably be moved to output surface.
+namespace {
+// This implements a simple fence based on client side swaps.
+// This is to isolate the ResourceProvider from 'frames' which
+// it shouldn't need to care about, while still allowing us to
+// enforce good texture recycling behavior strictly throughout
+// the compositor (don't recycle a texture while it's in use).
+class SimpleSwapFence : public ResourceProvider::Fence {
+public:
+ SimpleSwapFence() : m_hasPassed(false) {}
+ virtual bool hasPassed() OVERRIDE { return m_hasPassed; }
+ bool setHasPassed() { m_hasPassed = true; }
+private:
+ bool m_hasPassed;
+};
+}
piman 2013/02/05 23:47:02 nit: move to the top of the file instead of in the
+
bool GLRenderer::swapBuffers()
{
DCHECK(m_visible);
@@ -1290,6 +1307,11 @@ bool GLRenderer::swapBuffers()
TRACE_EVENT0("cc", "GLRenderer::swapBuffers");
// We're done! Time to swapbuffers!
+ scoped_refptr<ResourceProvider::Fence> lastSwapFence = m_resourceProvider->getReadLockFence();
+ if (lastSwapFence)
+ static_cast<SimpleSwapFence*>(lastSwapFence.get())->setHasPassed();
+ m_resourceProvider->setReadLockFence(new SimpleSwapFence());
+
if (m_capabilities.usingPartialSwap) {
// If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport)
m_swapBufferRect.Intersect(gfx::Rect(gfx::Point(), viewportSize()));
« no previous file with comments | « no previous file | cc/resource_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698