OLD | NEW |
---|---|
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 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1275 setShaderOpacity(1, program->fragmentShader().alphaLocation()); | 1275 setShaderOpacity(1, program->fragmentShader().alphaLocation()); |
1276 drawQuadGeometry(frame, drawMatrix, rect, program->vertexShader().matrixLoca tion()); | 1276 drawQuadGeometry(frame, drawMatrix, rect, program->vertexShader().matrixLoca tion()); |
1277 } | 1277 } |
1278 | 1278 |
1279 void GLRenderer::finish() | 1279 void GLRenderer::finish() |
1280 { | 1280 { |
1281 TRACE_EVENT0("cc", "GLRenderer::finish"); | 1281 TRACE_EVENT0("cc", "GLRenderer::finish"); |
1282 m_context->finish(); | 1282 m_context->finish(); |
1283 } | 1283 } |
1284 | 1284 |
1285 // TODO(epenner): This should probably be moved to output surface. | |
1286 namespace { | |
1287 // This implements a simple fence based on client side swaps. | |
1288 // This is to isolate the ResourceProvider from 'frames' which | |
1289 // it shouldn't need to care about, while still allowing us to | |
1290 // enforce good texture recycling behavior strictly throughout | |
1291 // the compositor (don't recycle a texture while it's in use). | |
1292 class SimpleSwapFence : public ResourceProvider::Fence { | |
1293 public: | |
1294 SimpleSwapFence() : m_hasPassed(false) {} | |
1295 virtual bool hasPassed() OVERRIDE { return m_hasPassed; } | |
1296 bool setHasPassed() { m_hasPassed = true; } | |
1297 private: | |
1298 bool m_hasPassed; | |
1299 }; | |
1300 } | |
piman
2013/02/05 23:47:02
nit: move to the top of the file instead of in the
| |
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 Loading... | |
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 |
OLD | NEW |