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 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 } | 1302 } |
1303 | 1303 |
1304 bool GLRenderer::swapBuffers() | 1304 bool GLRenderer::swapBuffers() |
1305 { | 1305 { |
1306 DCHECK(m_visible); | 1306 DCHECK(m_visible); |
1307 DCHECK(!m_isBackbufferDiscarded); | 1307 DCHECK(!m_isBackbufferDiscarded); |
1308 | 1308 |
1309 TRACE_EVENT0("cc", "GLRenderer::swapBuffers"); | 1309 TRACE_EVENT0("cc", "GLRenderer::swapBuffers"); |
1310 // We're done! Time to swapbuffers! | 1310 // We're done! Time to swapbuffers! |
1311 | 1311 |
1312 scoped_refptr<ResourceProvider::Fence> lastSwapFence = m_resourceProvider->g
etReadLockFence(); | |
1313 if (lastSwapFence) | |
1314 static_cast<SimpleSwapFence*>(lastSwapFence.get())->setHasPassed(); | |
1315 m_resourceProvider->setReadLockFence(new SimpleSwapFence()); | |
1316 | |
1317 if (m_capabilities.usingPartialSwap) { | 1312 if (m_capabilities.usingPartialSwap) { |
1318 // If supported, we can save significant bandwidth by only swapping the
damaged/scissored region (clamped to the viewport) | 1313 // If supported, we can save significant bandwidth by only swapping the
damaged/scissored region (clamped to the viewport) |
1319 m_swapBufferRect.Intersect(gfx::Rect(gfx::Point(), viewportSize())); | 1314 m_swapBufferRect.Intersect(gfx::Rect(gfx::Point(), viewportSize())); |
1320 int flippedYPosOfRectBottom = viewportHeight() - m_swapBufferRect.y() -
m_swapBufferRect.height(); | 1315 int flippedYPosOfRectBottom = viewportHeight() - m_swapBufferRect.y() -
m_swapBufferRect.height(); |
1321 m_context->postSubBufferCHROMIUM(m_swapBufferRect.x(), flippedYPosOfRect
Bottom, m_swapBufferRect.width(), m_swapBufferRect.height()); | 1316 m_context->postSubBufferCHROMIUM(m_swapBufferRect.x(), flippedYPosOfRect
Bottom, m_swapBufferRect.width(), m_swapBufferRect.height()); |
1322 } else { | 1317 } else { |
1323 // Note that currently this has the same effect as swapBuffers; we shoul
d | 1318 // Note that currently this has the same effect as swapBuffers; we shoul
d |
1324 // consider exposing a different entry point on WebGraphicsContext3D. | 1319 // consider exposing a different entry point on WebGraphicsContext3D. |
1325 m_context->prepareTexture(); | 1320 m_context->prepareTexture(); |
1326 } | 1321 } |
1327 | 1322 |
1328 m_swapBufferRect = gfx::Rect(); | 1323 m_swapBufferRect = gfx::Rect(); |
1329 | 1324 |
| 1325 // We don't have real fences, so we mark read fences as passed |
| 1326 // assuming a double-buffered GPU pipeline. A texture can be |
| 1327 // written to after one full frame has past since it was last read. |
| 1328 if (m_lastSwapFence) |
| 1329 static_cast<SimpleSwapFence*>(m_lastSwapFence.get())->setHasPassed(); |
| 1330 m_lastSwapFence = m_resourceProvider->getReadLockFence(); |
| 1331 m_resourceProvider->setReadLockFence(new SimpleSwapFence()); |
| 1332 |
1330 return true; | 1333 return true; |
1331 } | 1334 } |
1332 | 1335 |
1333 void GLRenderer::onSwapBuffersComplete() | 1336 void GLRenderer::onSwapBuffersComplete() |
1334 { | 1337 { |
1335 m_client->onSwapBuffersComplete(); | 1338 m_client->onSwapBuffersComplete(); |
1336 } | 1339 } |
1337 | 1340 |
1338 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio
n) | 1341 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio
n) |
1339 { | 1342 { |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 | 1816 |
1814 releaseRenderPassTextures(); | 1817 releaseRenderPassTextures(); |
1815 } | 1818 } |
1816 | 1819 |
1817 bool GLRenderer::isContextLost() | 1820 bool GLRenderer::isContextLost() |
1818 { | 1821 { |
1819 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1822 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1820 } | 1823 } |
1821 | 1824 |
1822 } // namespace cc | 1825 } // namespace cc |
OLD | NEW |