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

Side by Side Diff: cc/gl_renderer.cc

Issue 12371002: [cc] Mailbox Output Surface Support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/gl_renderer.h ('k') | cc/gl_renderer_unittest.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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi lity"); 133 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi lity");
134 134
135 if (extensions.count("GL_CHROMIUM_iosurface")) 135 if (extensions.count("GL_CHROMIUM_iosurface"))
136 DCHECK(extensions.count("GL_ARB_texture_rectangle")); 136 DCHECK(extensions.count("GL_ARB_texture_rectangle"));
137 137
138 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager") 138 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager")
139 && settings().useMemoryManagement; 139 && settings().useMemoryManagement;
140 if (m_capabilities.usingGpuMemoryManager) 140 if (m_capabilities.usingGpuMemoryManager)
141 m_context->setMemoryAllocationChangedCallbackCHROMIUM(this); 141 m_context->setMemoryAllocationChangedCallbackCHROMIUM(this);
142 142
143 m_capabilities.usingDiscardBackbuffer = extensions.count("GL_CHROMIUM_discar d_backbuffer");
144
145 m_capabilities.usingEglImage = extensions.count("GL_OES_EGL_image_external") ; 143 m_capabilities.usingEglImage = extensions.count("GL_OES_EGL_image_external") ;
146 144
147 m_capabilities.maxTextureSize = m_resourceProvider->maxTextureSize(); 145 m_capabilities.maxTextureSize = m_resourceProvider->maxTextureSize();
148 m_capabilities.bestTextureFormat = m_resourceProvider->bestTextureFormat(); 146 m_capabilities.bestTextureFormat = m_resourceProvider->bestTextureFormat();
149 147
150 // The updater can access textures while the GLRenderer is using them. 148 // The updater can access textures while the GLRenderer is using them.
151 m_capabilities.allowPartialTextureUpdates = true; 149 m_capabilities.allowPartialTextureUpdates = true;
152 150
153 // Check for texture fast paths. Currently we always use MO8 textures, 151 // Check for texture fast paths. Currently we always use MO8 textures,
154 // so we only need to avoid POT textures if we have an NPOT fast-path. 152 // so we only need to avoid POT textures if we have an NPOT fast-path.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 248
251 if (viewportSize().IsEmpty()) 249 if (viewportSize().IsEmpty())
252 return; 250 return;
253 251
254 TRACE_EVENT0("cc", "GLRenderer::drawLayers"); 252 TRACE_EVENT0("cc", "GLRenderer::drawLayers");
255 if (m_isViewportChanged) { 253 if (m_isViewportChanged) {
256 // Only reshape when we know we are going to draw. Otherwise, the reshap e 254 // Only reshape when we know we are going to draw. Otherwise, the reshap e
257 // can leave the window at the wrong size if we never draw and the prope r 255 // can leave the window at the wrong size if we never draw and the prope r
258 // viewport size is never set. 256 // viewport size is never set.
259 m_isViewportChanged = false; 257 m_isViewportChanged = false;
260 m_context->reshape(viewportWidth(), viewportHeight()); 258 m_outputSurface->Reshape(gfx::Size(viewportWidth(), viewportHeight()));
261 } 259 }
262 260
263 makeContextCurrent(); 261 makeContextCurrent();
264 // Bind the common vertex attributes used for drawing all the layers. 262 // Bind the common vertex attributes used for drawing all the layers.
265 m_sharedGeometry->prepareForDraw(); 263 m_sharedGeometry->prepareForDraw();
266 264
267 GLC(m_context, m_context->disable(GL_DEPTH_TEST)); 265 GLC(m_context, m_context->disable(GL_DEPTH_TEST));
268 GLC(m_context, m_context->disable(GL_CULL_FACE)); 266 GLC(m_context, m_context->disable(GL_CULL_FACE));
269 GLC(m_context, m_context->colorMask(true, true, true, true)); 267 GLC(m_context, m_context->colorMask(true, true, true, true));
270 GLC(m_context, m_context->enable(GL_BLEND)); 268 GLC(m_context, m_context->enable(GL_BLEND));
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 { 1207 {
1210 m_currentFramebufferLock.reset(); 1208 m_currentFramebufferLock.reset();
1211 m_swapBufferRect.Union(gfx::ToEnclosingRect(frame.rootDamageRect)); 1209 m_swapBufferRect.Union(gfx::ToEnclosingRect(frame.rootDamageRect));
1212 1210
1213 GLC(m_context, m_context->disable(GL_BLEND)); 1211 GLC(m_context, m_context->disable(GL_BLEND));
1214 m_blendShadow = false; 1212 m_blendShadow = false;
1215 1213
1216 if (settings().compositorFrameMessage) { 1214 if (settings().compositorFrameMessage) {
1217 CompositorFrame compositor_frame; 1215 CompositorFrame compositor_frame;
1218 compositor_frame.metadata = m_client->makeCompositorFrameMetadata(); 1216 compositor_frame.metadata = m_client->makeCompositorFrameMetadata();
1219 compositor_frame.gl_frame_data.reset(new GLFrameData());
1220 // FIXME: Fill in GLFrameData when we implement swapping with it.
1221 m_outputSurface->SendFrameToParentCompositor(&compositor_frame); 1217 m_outputSurface->SendFrameToParentCompositor(&compositor_frame);
1222 } 1218 }
1223 } 1219 }
1224 1220
1225 void GLRenderer::finishDrawingQuadList() 1221 void GLRenderer::finishDrawingQuadList()
1226 { 1222 {
1227 flushTextureQuadCache(); 1223 flushTextureQuadCache();
1228 } 1224 }
1229 1225
1230 bool GLRenderer::flippedFramebuffer() const 1226 bool GLRenderer::flippedFramebuffer() const
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 DCHECK(m_visible); 1332 DCHECK(m_visible);
1337 DCHECK(!m_isBackbufferDiscarded); 1333 DCHECK(!m_isBackbufferDiscarded);
1338 1334
1339 TRACE_EVENT0("cc", "GLRenderer::swapBuffers"); 1335 TRACE_EVENT0("cc", "GLRenderer::swapBuffers");
1340 // We're done! Time to swapbuffers! 1336 // We're done! Time to swapbuffers!
1341 1337
1342 if (m_capabilities.usingPartialSwap) { 1338 if (m_capabilities.usingPartialSwap) {
1343 // If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport) 1339 // If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport)
1344 m_swapBufferRect.Intersect(gfx::Rect(gfx::Point(), viewportSize())); 1340 m_swapBufferRect.Intersect(gfx::Rect(gfx::Point(), viewportSize()));
1345 int flippedYPosOfRectBottom = viewportHeight() - m_swapBufferRect.y() - m_swapBufferRect.height(); 1341 int flippedYPosOfRectBottom = viewportHeight() - m_swapBufferRect.y() - m_swapBufferRect.height();
1346 m_context->postSubBufferCHROMIUM(m_swapBufferRect.x(), flippedYPosOfRect Bottom, m_swapBufferRect.width(), m_swapBufferRect.height()); 1342 m_outputSurface->PostSubBuffer(gfx::Rect(m_swapBufferRect.x(), flippedYP osOfRectBottom, m_swapBufferRect.width(), m_swapBufferRect.height()));
1347 } else { 1343 } else {
1348 // Note that currently this has the same effect as swapBuffers; we shoul d 1344 m_outputSurface->SwapBuffers();
1349 // consider exposing a different entry point on WebGraphicsContext3D.
1350 m_context->prepareTexture();
1351 } 1345 }
1352 1346
1353 m_swapBufferRect = gfx::Rect(); 1347 m_swapBufferRect = gfx::Rect();
1354 1348
1355 // We don't have real fences, so we mark read fences as passed 1349 // We don't have real fences, so we mark read fences as passed
1356 // assuming a double-buffered GPU pipeline. A texture can be 1350 // assuming a double-buffered GPU pipeline. A texture can be
1357 // written to after one full frame has past since it was last read. 1351 // written to after one full frame has past since it was last read.
1358 if (m_lastSwapFence) 1352 if (m_lastSwapFence)
1359 static_cast<SimpleSwapFence*>(m_lastSwapFence.get())->setHasPassed(); 1353 static_cast<SimpleSwapFence*>(m_lastSwapFence.get())->setHasPassed();
1360 m_lastSwapFence = m_resourceProvider->getReadLockFence(); 1354 m_lastSwapFence = m_resourceProvider->getReadLockFence();
1361 m_resourceProvider->setReadLockFence(new SimpleSwapFence()); 1355 m_resourceProvider->setReadLockFence(new SimpleSwapFence());
1362 1356
1363 return true; 1357 return true;
1364 } 1358 }
1365 1359
1360 void GLRenderer::receiveCompositorFrameAck(const CompositorFrameAck& ack) {
1361 onSwapBuffersComplete();
1362 }
1363
1366 void GLRenderer::onSwapBuffersComplete() 1364 void GLRenderer::onSwapBuffersComplete()
1367 { 1365 {
1368 m_client->onSwapBuffersComplete(); 1366 m_client->onSwapBuffersComplete();
1369 } 1367 }
1370 1368
1371 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio n) 1369 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio n)
1372 { 1370 {
1373 // Just ignore the memory manager when it says to set the limit to zero 1371 // Just ignore the memory manager when it says to set the limit to zero
1374 // bytes. This will happen when the memory manager thinks that the renderer 1372 // bytes. This will happen when the memory manager thinks that the renderer
1375 // is not visible (which the renderer knows better). 1373 // is not visible (which the renderer knows better).
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 m_resourceProvider->releaseCachedData(); 1418 m_resourceProvider->releaseCachedData();
1421 GLC(m_context, m_context->flush()); 1419 GLC(m_context, m_context->flush());
1422 } 1420 }
1423 } 1421 }
1424 1422
1425 void GLRenderer::discardBackbuffer() 1423 void GLRenderer::discardBackbuffer()
1426 { 1424 {
1427 if (m_isBackbufferDiscarded) 1425 if (m_isBackbufferDiscarded)
1428 return; 1426 return;
1429 1427
1430 if (!m_capabilities.usingDiscardBackbuffer) 1428 m_outputSurface->DiscardBackbuffer();
1431 return;
1432 1429
1433 m_context->discardBackbufferCHROMIUM();
1434 m_isBackbufferDiscarded = true; 1430 m_isBackbufferDiscarded = true;
1435 1431
1436 // Damage tracker needs a full reset every time framebuffer is discarded. 1432 // Damage tracker needs a full reset every time framebuffer is discarded.
1437 m_client->setFullRootLayerDamage(); 1433 m_client->setFullRootLayerDamage();
1438 } 1434 }
1439 1435
1440 void GLRenderer::ensureBackbuffer() 1436 void GLRenderer::ensureBackbuffer()
1441 { 1437 {
1442 if (!m_isBackbufferDiscarded) 1438 if (!m_isBackbufferDiscarded)
1443 return; 1439 return;
1444 1440
1445 if (!m_capabilities.usingDiscardBackbuffer) 1441 m_outputSurface->EnsureBackbuffer();
1446 return;
1447
1448 m_context->ensureBackbufferCHROMIUM();
1449 m_isBackbufferDiscarded = false; 1442 m_isBackbufferDiscarded = false;
1450 } 1443 }
1451 1444
1452 void GLRenderer::onContextLost() 1445 void GLRenderer::onContextLost()
1453 { 1446 {
1454 m_client->didLoseOutputSurface(); 1447 m_client->didLoseOutputSurface();
1455 } 1448 }
1456 1449
1457 1450
1458 void GLRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect) 1451 void GLRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 DCHECK(texture->id()); 1535 DCHECK(texture->id());
1543 frame.currentRenderPass = 0; 1536 frame.currentRenderPass = 0;
1544 frame.currentTexture = texture; 1537 frame.currentTexture = texture;
1545 1538
1546 return bindFramebufferToTexture(frame, texture, viewportRect); 1539 return bindFramebufferToTexture(frame, texture, viewportRect);
1547 } 1540 }
1548 1541
1549 void GLRenderer::bindFramebufferToOutputSurface(DrawingFrame& frame) 1542 void GLRenderer::bindFramebufferToOutputSurface(DrawingFrame& frame)
1550 { 1543 {
1551 m_currentFramebufferLock.reset(); 1544 m_currentFramebufferLock.reset();
1552 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, 0)); 1545 m_outputSurface->BindFramebuffer();
1553 } 1546 }
1554 1547
1555 bool GLRenderer::bindFramebufferToTexture(DrawingFrame& frame, const ScopedResou rce* texture, const gfx::Rect& framebufferRect) 1548 bool GLRenderer::bindFramebufferToTexture(DrawingFrame& frame, const ScopedResou rce* texture, const gfx::Rect& framebufferRect)
1556 { 1549 {
1557 DCHECK(texture->id()); 1550 DCHECK(texture->id());
1558 1551
1559 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, m_offscreenFramebu fferId)); 1552 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, m_offscreenFramebu fferId));
1560 m_currentFramebufferLock = make_scoped_ptr(new ResourceProvider::ScopedWrite LockGL(m_resourceProvider, texture->id())); 1553 m_currentFramebufferLock = make_scoped_ptr(new ResourceProvider::ScopedWrite LockGL(m_resourceProvider, texture->id()));
1561 unsigned textureId = m_currentFramebufferLock->textureId(); 1554 unsigned textureId = m_currentFramebufferLock->textureId();
1562 GLC(m_context, m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTA CHMENT0, GL_TEXTURE_2D, textureId, 0)); 1555 GLC(m_context, m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTA CHMENT0, GL_TEXTURE_2D, textureId, 0));
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 1840
1848 releaseRenderPassTextures(); 1841 releaseRenderPassTextures();
1849 } 1842 }
1850 1843
1851 bool GLRenderer::isContextLost() 1844 bool GLRenderer::isContextLost()
1852 { 1845 {
1853 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); 1846 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR);
1854 } 1847 }
1855 1848
1856 } // namespace cc 1849 } // namespace cc
OLDNEW
« no previous file with comments | « cc/gl_renderer.h ('k') | cc/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698