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

Side by Side 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: Rebase. 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 unified diff | Download patch
« no previous file with comments | « no previous file | cc/resource_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/gl_renderer.h" 5 #include "cc/gl_renderer.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "ui/gfx/rect_conversions.h" 44 #include "ui/gfx/rect_conversions.h"
45 45
46 using WebKit::WebGraphicsContext3D; 46 using WebKit::WebGraphicsContext3D;
47 using WebKit::WebGraphicsMemoryAllocation; 47 using WebKit::WebGraphicsMemoryAllocation;
48 using WebKit::WebSharedGraphicsContext3D; 48 using WebKit::WebSharedGraphicsContext3D;
49 49
50 namespace cc { 50 namespace cc {
51 51
52 namespace { 52 namespace {
53 53
54 // TODO(epenner): This should probably be moved to output surface.
55 //
56 // This implements a simple fence based on client side swaps.
57 // This is to isolate the ResourceProvider from 'frames' which
58 // it shouldn't need to care about, while still allowing us to
59 // enforce good texture recycling behavior strictly throughout
60 // the compositor (don't recycle a texture while it's in use).
61 class SimpleSwapFence : public ResourceProvider::Fence {
62 public:
63 SimpleSwapFence() : m_hasPassed(false) {}
64 virtual bool hasPassed() OVERRIDE { return m_hasPassed; }
65 void setHasPassed() { m_hasPassed = true; }
66 private:
67 virtual ~SimpleSwapFence() {}
68 bool m_hasPassed;
69 };
70
54 bool needsIOSurfaceReadbackWorkaround() 71 bool needsIOSurfaceReadbackWorkaround()
55 { 72 {
56 #if defined(OS_MACOSX) 73 #if defined(OS_MACOSX)
57 return true; 74 return true;
58 #else 75 #else
59 return false; 76 return false;
60 #endif 77 #endif
61 } 78 }
62 79
63 } // anonymous namespace 80 } // anonymous namespace
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 } 1300 }
1284 1301
1285 bool GLRenderer::swapBuffers() 1302 bool GLRenderer::swapBuffers()
1286 { 1303 {
1287 DCHECK(m_visible); 1304 DCHECK(m_visible);
1288 DCHECK(!m_isBackbufferDiscarded); 1305 DCHECK(!m_isBackbufferDiscarded);
1289 1306
1290 TRACE_EVENT0("cc", "GLRenderer::swapBuffers"); 1307 TRACE_EVENT0("cc", "GLRenderer::swapBuffers");
1291 // We're done! Time to swapbuffers! 1308 // We're done! Time to swapbuffers!
1292 1309
1310 scoped_refptr<ResourceProvider::Fence> lastSwapFence = m_resourceProvider->g etReadLockFence();
1311 if (lastSwapFence)
1312 static_cast<SimpleSwapFence*>(lastSwapFence.get())->setHasPassed();
1313 m_resourceProvider->setReadLockFence(new SimpleSwapFence());
1314
1293 if (m_capabilities.usingPartialSwap) { 1315 if (m_capabilities.usingPartialSwap) {
1294 // If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport) 1316 // If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport)
1295 m_swapBufferRect.Intersect(gfx::Rect(gfx::Point(), viewportSize())); 1317 m_swapBufferRect.Intersect(gfx::Rect(gfx::Point(), viewportSize()));
1296 int flippedYPosOfRectBottom = viewportHeight() - m_swapBufferRect.y() - m_swapBufferRect.height(); 1318 int flippedYPosOfRectBottom = viewportHeight() - m_swapBufferRect.y() - m_swapBufferRect.height();
1297 m_context->postSubBufferCHROMIUM(m_swapBufferRect.x(), flippedYPosOfRect Bottom, m_swapBufferRect.width(), m_swapBufferRect.height()); 1319 m_context->postSubBufferCHROMIUM(m_swapBufferRect.x(), flippedYPosOfRect Bottom, m_swapBufferRect.width(), m_swapBufferRect.height());
1298 } else { 1320 } else {
1299 // Note that currently this has the same effect as swapBuffers; we shoul d 1321 // Note that currently this has the same effect as swapBuffers; we shoul d
1300 // consider exposing a different entry point on WebGraphicsContext3D. 1322 // consider exposing a different entry point on WebGraphicsContext3D.
1301 m_context->prepareTexture(); 1323 m_context->prepareTexture();
1302 } 1324 }
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 1811
1790 releaseRenderPassTextures(); 1812 releaseRenderPassTextures();
1791 } 1813 }
1792 1814
1793 bool GLRenderer::isContextLost() 1815 bool GLRenderer::isContextLost()
1794 { 1816 {
1795 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); 1817 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR);
1796 } 1818 }
1797 1819
1798 } // namespace cc 1820 } // namespace cc
OLDNEW
« 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