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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 , m_isScissorEnabled(false) | 104 , m_isScissorEnabled(false) |
105 { | 105 { |
106 DCHECK(m_context); | 106 DCHECK(m_context); |
107 } | 107 } |
108 | 108 |
109 bool GLRenderer::initialize() | 109 bool GLRenderer::initialize() |
110 { | 110 { |
111 if (!m_context->makeContextCurrent()) | 111 if (!m_context->makeContextCurrent()) |
112 return false; | 112 return false; |
113 | 113 |
114 m_context->setContextLostCallback(this); | |
115 m_context->pushGroupMarkerEXT("CompositorContext"); | 114 m_context->pushGroupMarkerEXT("CompositorContext"); |
116 | 115 |
117 std::string extensionsString = UTF16ToASCII(m_context->getString(GL_EXTENSIO
NS)); | 116 std::string extensionsString = UTF16ToASCII(m_context->getString(GL_EXTENSIO
NS)); |
118 std::vector<std::string> extensionsList; | 117 std::vector<std::string> extensionsList; |
119 base::SplitString(extensionsString, ' ', &extensionsList); | 118 base::SplitString(extensionsString, ' ', &extensionsList); |
120 std::set<std::string> extensions(extensionsList.begin(), extensionsList.end(
)); | 119 std::set<std::string> extensions(extensionsList.begin(), extensionsList.end(
)); |
121 | 120 |
122 if (settings().acceleratePainting && extensions.count("GL_EXT_texture_format
_BGRA8888") | 121 if (settings().acceleratePainting && extensions.count("GL_EXT_texture_format
_BGRA8888") |
123 && extensions.count("GL_EXT_read_format_bg
ra")) | 122 && extensions.count("GL_EXT_read_format_bg
ra")) |
124 m_capabilities.usingAcceleratedPainting = true; | 123 m_capabilities.usingAcceleratedPainting = true; |
125 else | 124 else |
126 m_capabilities.usingAcceleratedPainting = false; | 125 m_capabilities.usingAcceleratedPainting = false; |
127 | 126 |
128 m_capabilities.usingPartialSwap = settings().partialSwapEnabled && extension
s.count("GL_CHROMIUM_post_sub_buffer"); | 127 m_capabilities.usingPartialSwap = settings().partialSwapEnabled && extension
s.count("GL_CHROMIUM_post_sub_buffer"); |
129 | 128 |
130 // Use the swapBuffers callback only with the threaded proxy. | |
131 if (m_client->hasImplThread()) | |
132 m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM
_swapbuffers_complete_callback"); | |
133 if (m_capabilities.usingSwapCompleteCallback) | |
134 m_context->setSwapBuffersCompleteCallbackCHROMIUM(this); | |
135 | |
136 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi
lity"); | 129 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi
lity"); |
137 | 130 |
138 if (extensions.count("GL_CHROMIUM_iosurface")) | 131 if (extensions.count("GL_CHROMIUM_iosurface")) |
139 DCHECK(extensions.count("GL_ARB_texture_rectangle")); | 132 DCHECK(extensions.count("GL_ARB_texture_rectangle")); |
140 | 133 |
141 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem
ory_manager") | 134 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem
ory_manager") |
142 && settings().useMemoryManagement; | 135 && settings().useMemoryManagement; |
143 if (m_capabilities.usingGpuMemoryManager) | 136 if (m_capabilities.usingGpuMemoryManager) |
144 m_context->setMemoryAllocationChangedCallbackCHROMIUM(this); | 137 m_context->setMemoryAllocationChangedCallbackCHROMIUM(this); |
145 | 138 |
(...skipping 20 matching lines...) Expand all Loading... |
166 if (!initializeSharedObjects()) | 159 if (!initializeSharedObjects()) |
167 return false; | 160 return false; |
168 | 161 |
169 // Make sure the viewport and context gets initialized, even if it is to zer
o. | 162 // Make sure the viewport and context gets initialized, even if it is to zer
o. |
170 viewportChanged(); | 163 viewportChanged(); |
171 return true; | 164 return true; |
172 } | 165 } |
173 | 166 |
174 GLRenderer::~GLRenderer() | 167 GLRenderer::~GLRenderer() |
175 { | 168 { |
176 m_context->setSwapBuffersCompleteCallbackCHROMIUM(0); | |
177 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0); | 169 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0); |
178 m_context->setContextLostCallback(0); | |
179 cleanupSharedObjects(); | 170 cleanupSharedObjects(); |
180 } | 171 } |
181 | 172 |
182 const RendererCapabilities& GLRenderer::capabilities() const | 173 const RendererCapabilities& GLRenderer::capabilities() const |
183 { | 174 { |
184 return m_capabilities; | 175 return m_capabilities; |
185 } | 176 } |
186 | 177 |
187 WebGraphicsContext3D* GLRenderer::context() | 178 WebGraphicsContext3D* GLRenderer::context() |
188 { | 179 { |
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 // assuming a double-buffered GPU pipeline. A texture can be | 1363 // assuming a double-buffered GPU pipeline. A texture can be |
1373 // written to after one full frame has past since it was last read. | 1364 // written to after one full frame has past since it was last read. |
1374 if (m_lastSwapFence) | 1365 if (m_lastSwapFence) |
1375 static_cast<SimpleSwapFence*>(m_lastSwapFence.get())->setHasPassed(); | 1366 static_cast<SimpleSwapFence*>(m_lastSwapFence.get())->setHasPassed(); |
1376 m_lastSwapFence = m_resourceProvider->GetReadLockFence(); | 1367 m_lastSwapFence = m_resourceProvider->GetReadLockFence(); |
1377 m_resourceProvider->SetReadLockFence(new SimpleSwapFence()); | 1368 m_resourceProvider->SetReadLockFence(new SimpleSwapFence()); |
1378 | 1369 |
1379 return true; | 1370 return true; |
1380 } | 1371 } |
1381 | 1372 |
1382 void GLRenderer::receiveCompositorFrameAck(const CompositorFrameAck& ack) { | |
1383 onSwapBuffersComplete(); | |
1384 } | |
1385 | |
1386 void GLRenderer::onSwapBuffersComplete() | |
1387 { | |
1388 m_client->onSwapBuffersComplete(); | |
1389 } | |
1390 | |
1391 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio
n) | 1373 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio
n) |
1392 { | 1374 { |
1393 // Just ignore the memory manager when it says to set the limit to zero | 1375 // Just ignore the memory manager when it says to set the limit to zero |
1394 // bytes. This will happen when the memory manager thinks that the renderer | 1376 // bytes. This will happen when the memory manager thinks that the renderer |
1395 // is not visible (which the renderer knows better). | 1377 // is not visible (which the renderer knows better). |
1396 if (allocation.bytesLimitWhenVisible) { | 1378 if (allocation.bytesLimitWhenVisible) { |
1397 ManagedMemoryPolicy policy( | 1379 ManagedMemoryPolicy policy( |
1398 allocation.bytesLimitWhenVisible, | 1380 allocation.bytesLimitWhenVisible, |
1399 priorityCutoff(allocation.priorityCutoffWhenVisible), | 1381 priorityCutoff(allocation.priorityCutoffWhenVisible), |
1400 allocation.bytesLimitWhenNotVisible, | 1382 allocation.bytesLimitWhenNotVisible, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 | 1439 |
1458 void GLRenderer::ensureBackbuffer() | 1440 void GLRenderer::ensureBackbuffer() |
1459 { | 1441 { |
1460 if (!m_isBackbufferDiscarded) | 1442 if (!m_isBackbufferDiscarded) |
1461 return; | 1443 return; |
1462 | 1444 |
1463 m_outputSurface->EnsureBackbuffer(); | 1445 m_outputSurface->EnsureBackbuffer(); |
1464 m_isBackbufferDiscarded = false; | 1446 m_isBackbufferDiscarded = false; |
1465 } | 1447 } |
1466 | 1448 |
1467 void GLRenderer::onContextLost() | |
1468 { | |
1469 m_client->didLoseOutputSurface(); | |
1470 } | |
1471 | |
1472 | |
1473 void GLRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect) | 1449 void GLRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect) |
1474 { | 1450 { |
1475 DCHECK(rect.right() <= viewportWidth()); | 1451 DCHECK(rect.right() <= viewportWidth()); |
1476 DCHECK(rect.bottom() <= viewportHeight()); | 1452 DCHECK(rect.bottom() <= viewportHeight()); |
1477 | 1453 |
1478 if (!pixels) | 1454 if (!pixels) |
1479 return; | 1455 return; |
1480 | 1456 |
1481 makeContextCurrent(); | 1457 makeContextCurrent(); |
1482 | 1458 |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 | 1838 |
1863 releaseRenderPassTextures(); | 1839 releaseRenderPassTextures(); |
1864 } | 1840 } |
1865 | 1841 |
1866 bool GLRenderer::isContextLost() | 1842 bool GLRenderer::isContextLost() |
1867 { | 1843 { |
1868 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1844 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1869 } | 1845 } |
1870 | 1846 |
1871 } // namespace cc | 1847 } // namespace cc |
OLD | NEW |