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())); |