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 |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/string_split.h" | 13 #include "base/string_split.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "cc/compositor_frame.h" | 16 #include "cc/compositor_frame.h" |
17 #include "cc/compositor_frame_ack.h" | |
17 #include "cc/compositor_frame_metadata.h" | 18 #include "cc/compositor_frame_metadata.h" |
18 #include "cc/damage_tracker.h" | 19 #include "cc/damage_tracker.h" |
19 #include "cc/geometry_binding.h" | 20 #include "cc/geometry_binding.h" |
20 #include "cc/gl_frame_data.h" | 21 #include "cc/gl_frame_data.h" |
21 #include "cc/layer_quad.h" | 22 #include "cc/layer_quad.h" |
22 #include "cc/math_util.h" | 23 #include "cc/math_util.h" |
23 #include "cc/priority_calculator.h" | 24 #include "cc/priority_calculator.h" |
24 #include "cc/proxy.h" | 25 #include "cc/proxy.h" |
25 #include "cc/render_pass.h" | 26 #include "cc/render_pass.h" |
26 #include "cc/render_surface_filters.h" | 27 #include "cc/render_surface_filters.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 , m_offscreenFramebufferId(0) | 77 , m_offscreenFramebufferId(0) |
77 , m_sharedGeometryQuad(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)) | 78 , m_sharedGeometryQuad(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)) |
78 , m_outputSurface(outputSurface) | 79 , m_outputSurface(outputSurface) |
79 , m_context(outputSurface->Context3D()) | 80 , m_context(outputSurface->Context3D()) |
80 , m_isViewportChanged(false) | 81 , m_isViewportChanged(false) |
81 , m_isBackbufferDiscarded(false) | 82 , m_isBackbufferDiscarded(false) |
82 , m_discardBackbufferWhenNotVisible(false) | 83 , m_discardBackbufferWhenNotVisible(false) |
83 , m_isUsingBindUniform(false) | 84 , m_isUsingBindUniform(false) |
84 , m_visible(true) | 85 , m_visible(true) |
85 , m_isScissorEnabled(false) | 86 , m_isScissorEnabled(false) |
87 , m_renderToMailbox(outputSurface->Capabilities().render_to_mailbox) | |
86 { | 88 { |
87 DCHECK(m_context); | 89 DCHECK(m_context); |
90 m_pendingFrames.push_back(MailboxTexture()); | |
88 } | 91 } |
89 | 92 |
90 bool GLRenderer::initialize() | 93 bool GLRenderer::initialize() |
91 { | 94 { |
92 if (!m_context->makeContextCurrent()) | 95 if (!m_context->makeContextCurrent()) |
93 return false; | 96 return false; |
94 | 97 |
95 m_context->setContextLostCallback(this); | 98 m_context->setContextLostCallback(this); |
96 m_context->pushGroupMarkerEXT("CompositorContext"); | 99 m_context->pushGroupMarkerEXT("CompositorContext"); |
97 | 100 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 viewportChanged(); | 149 viewportChanged(); |
147 return true; | 150 return true; |
148 } | 151 } |
149 | 152 |
150 GLRenderer::~GLRenderer() | 153 GLRenderer::~GLRenderer() |
151 { | 154 { |
152 m_context->setSwapBuffersCompleteCallbackCHROMIUM(0); | 155 m_context->setSwapBuffersCompleteCallbackCHROMIUM(0); |
153 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0); | 156 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0); |
154 m_context->setContextLostCallback(0); | 157 m_context->setContextLostCallback(0); |
155 cleanupSharedObjects(); | 158 cleanupSharedObjects(); |
159 | |
160 DCHECK(m_pendingFrames.size() == 1); | |
piman
2013/01/18 02:14:11
What ensures that this doesn't get deleted while a
| |
161 if (m_pendingFrames.back().textureId) | |
162 m_context->deleteTexture(m_pendingFrames.back().textureId); | |
156 } | 163 } |
157 | 164 |
158 const RendererCapabilities& GLRenderer::capabilities() const | 165 const RendererCapabilities& GLRenderer::capabilities() const |
159 { | 166 { |
160 return m_capabilities; | 167 return m_capabilities; |
161 } | 168 } |
162 | 169 |
163 WebGraphicsContext3D* GLRenderer::context() | 170 WebGraphicsContext3D* GLRenderer::context() |
164 { | 171 { |
165 return m_context; | 172 return m_context; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 void GLRenderer::releaseRenderPassTextures() | 206 void GLRenderer::releaseRenderPassTextures() |
200 { | 207 { |
201 m_renderPassTextures.clear(); | 208 m_renderPassTextures.clear(); |
202 } | 209 } |
203 | 210 |
204 void GLRenderer::viewportChanged() | 211 void GLRenderer::viewportChanged() |
205 { | 212 { |
206 m_isViewportChanged = true; | 213 m_isViewportChanged = true; |
207 } | 214 } |
208 | 215 |
216 void GLRenderer::receiveCompositorFrameAck(const CompositorFrameAck& ack) | |
217 { | |
218 if (m_renderToMailbox) { | |
danakj
2013/01/18 01:01:41
if (!m_renderToMailbox)
return;
| |
219 onSwapBuffersComplete(); | |
Sami
2013/01/25 23:17:27
Should we consume the texture and insert the sync
| |
220 | |
221 DCHECK(m_pendingFrames.size()); | |
222 if (!ack.mailbox.isZero()) { | |
223 std::vector<MailboxTexture>::iterator it = m_pendingFrames.begin(); | |
224 for (; it != m_pendingFrames.end(); it++) { | |
danakj
2013/01/18 01:01:41
shouldn't the frame always be the .front() here, s
no sievers
2013/01/18 01:14:54
The one exception is skipped frames. When RWHV dec
| |
225 if (!memcmp(ack.mailbox.name, it->mailbox.name, sizeof(Mailbox:: name))) | |
226 break; | |
227 } | |
228 CHECK(it != m_pendingFrames.end()); | |
229 MailboxTexture& texture = *it; | |
230 | |
231 DCHECK(texture.textureId); | |
danakj
2013/01/18 01:01:41
if you like, i think you could create a texture id
| |
232 m_context->bindTexture(GL_TEXTURE_2D, texture.textureId); | |
233 | |
234 // If the consumer is bouncing back the same texture (i.e. skipping the frame), | |
235 // we don't have to synchronize here (sync_point == 0). | |
236 if (ack.sync_point) | |
237 m_context->waitSyncPoint(ack.sync_point); | |
238 | |
239 m_context->consumeTextureCHROMIUM(GL_TEXTURE_2D, ack.mailbox.name); | |
240 m_returnedTextures.push(texture); | |
241 m_pendingFrames.erase(it); | |
242 } else { | |
243 // Either this is the very first ACK or the oldest buffer is not bei ng returned | |
244 // because the frontbuffer was discarded in the browser. | |
245 MailboxTexture& texture = m_pendingFrames.front(); | |
246 if (texture.textureId) | |
247 m_context->deleteTexture(texture.textureId); | |
248 m_pendingFrames.erase(m_pendingFrames.begin()); | |
249 } | |
250 } | |
251 } | |
252 | |
209 void GLRenderer::clearFramebuffer(DrawingFrame& frame) | 253 void GLRenderer::clearFramebuffer(DrawingFrame& frame) |
210 { | 254 { |
211 // On DEBUG builds, opaque render passes are cleared to blue to easily see r egions that were not drawn on the screen. | 255 // On DEBUG builds, opaque render passes are cleared to blue to easily see r egions that were not drawn on the screen. |
212 if (frame.currentRenderPass->has_transparent_background) | 256 if (frame.currentRenderPass->has_transparent_background) |
213 GLC(m_context, m_context->clearColor(0, 0, 0, 0)); | 257 GLC(m_context, m_context->clearColor(0, 0, 0, 0)); |
214 else | 258 else |
215 GLC(m_context, m_context->clearColor(0, 0, 1, 1)); | 259 GLC(m_context, m_context->clearColor(0, 0, 1, 1)); |
216 | 260 |
217 #ifdef NDEBUG | 261 #ifdef NDEBUG |
218 if (frame.currentRenderPass->has_transparent_background) | 262 if (frame.currentRenderPass->has_transparent_background) |
219 #endif | 263 #endif |
220 m_context->clear(GL_COLOR_BUFFER_BIT); | 264 m_context->clear(GL_COLOR_BUFFER_BIT); |
221 } | 265 } |
222 | 266 |
223 void GLRenderer::beginDrawingFrame(DrawingFrame& frame) | 267 void GLRenderer::beginDrawingFrame(DrawingFrame& frame) |
224 { | 268 { |
225 // FIXME: Remove this once backbuffer is automatically recreated on first us e | 269 // FIXME: Remove this once backbuffer is automatically recreated on first us e |
226 ensureBackbuffer(); | 270 ensureBackbuffer(); |
227 | 271 |
228 if (viewportSize().IsEmpty()) | 272 if (viewportSize().IsEmpty()) |
229 return; | 273 return; |
230 | 274 |
231 TRACE_EVENT0("cc", "GLRenderer::drawLayers"); | 275 TRACE_EVENT0("cc", "GLRenderer::drawLayers"); |
232 if (m_isViewportChanged) { | 276 if (m_isViewportChanged) { |
233 // Only reshape when we know we are going to draw. Otherwise, the reshap e | 277 // Only reshape when we know we are going to draw. Otherwise, the reshap e |
234 // can leave the window at the wrong size if we never draw and the prope r | 278 // can leave the window at the wrong size if we never draw and the prope r |
235 // viewport size is never set. | 279 // viewport size is never set. |
236 m_isViewportChanged = false; | 280 m_isViewportChanged = false; |
237 m_context->reshape(viewportWidth(), viewportHeight()); | 281 m_context->reshape(viewportWidth(), viewportHeight()); |
282 | |
283 if (m_renderToMailbox) { | |
284 discardBackbuffer(); | |
285 ensureBackbuffer(); | |
286 } | |
238 } | 287 } |
239 | 288 |
240 makeContextCurrent(); | 289 makeContextCurrent(); |
241 // Bind the common vertex attributes used for drawing all the layers. | 290 // Bind the common vertex attributes used for drawing all the layers. |
242 m_sharedGeometry->prepareForDraw(); | 291 m_sharedGeometry->prepareForDraw(); |
243 | 292 |
244 GLC(m_context, m_context->disable(GL_DEPTH_TEST)); | 293 GLC(m_context, m_context->disable(GL_DEPTH_TEST)); |
245 GLC(m_context, m_context->disable(GL_CULL_FACE)); | 294 GLC(m_context, m_context->disable(GL_CULL_FACE)); |
246 GLC(m_context, m_context->colorMask(true, true, true, true)); | 295 GLC(m_context, m_context->colorMask(true, true, true, true)); |
247 GLC(m_context, m_context->enable(GL_BLEND)); | 296 GLC(m_context, m_context->enable(GL_BLEND)); |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1169 m_currentFramebufferLock.reset(); | 1218 m_currentFramebufferLock.reset(); |
1170 m_swapBufferRect.Union(gfx::ToEnclosingRect(frame.rootDamageRect)); | 1219 m_swapBufferRect.Union(gfx::ToEnclosingRect(frame.rootDamageRect)); |
1171 | 1220 |
1172 GLC(m_context, m_context->disable(GL_BLEND)); | 1221 GLC(m_context, m_context->disable(GL_BLEND)); |
1173 m_blendShadow = false; | 1222 m_blendShadow = false; |
1174 | 1223 |
1175 if (settings().compositorFrameMessage) { | 1224 if (settings().compositorFrameMessage) { |
1176 CompositorFrame compositor_frame; | 1225 CompositorFrame compositor_frame; |
1177 compositor_frame.metadata = m_client->makeCompositorFrameMetadata(); | 1226 compositor_frame.metadata = m_client->makeCompositorFrameMetadata(); |
1178 compositor_frame.gl_frame_data.reset(new GLFrameData()); | 1227 compositor_frame.gl_frame_data.reset(new GLFrameData()); |
1179 // FIXME: Fill in GLFrameData when we implement swapping with it. | 1228 |
1229 if (m_renderToMailbox) { | |
1230 // In non-threaded mode there is no swap throttling yet. | |
1231 DCHECK(m_client->hasImplThread()); | |
1232 | |
1233 DCHECK(!viewportSize().IsEmpty()); | |
1234 DCHECK(!m_currentBacking.mailbox.isZero()); | |
1235 GLC(m_context, m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_CO LOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0)); | |
1236 context()->bindTexture(GL_TEXTURE_2D, m_currentBacking.textureId); | |
1237 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, m_currentBacking.ma ilbox.name); | |
1238 compositor_frame.gl_frame_data->mailbox = m_currentBacking.mailbox; | |
1239 compositor_frame.gl_frame_data->size = m_currentBacking.size; | |
1240 DCHECK(viewportSize() == m_currentBacking.size); | |
1241 compositor_frame.gl_frame_data->sync_point = context()->insertSyncPo int(); | |
1242 m_pendingFrames.push_back(m_currentBacking); | |
1243 m_currentBacking = MailboxTexture(); | |
1244 } | |
1245 | |
1180 m_outputSurface->SendFrameToParentCompositor(&compositor_frame); | 1246 m_outputSurface->SendFrameToParentCompositor(&compositor_frame); |
1181 } | 1247 } |
1182 } | 1248 } |
1183 | 1249 |
1184 void GLRenderer::finishDrawingQuadList() | 1250 void GLRenderer::finishDrawingQuadList() |
1185 { | 1251 { |
1186 flushTextureQuadCache(); | 1252 flushTextureQuadCache(); |
1187 } | 1253 } |
1188 | 1254 |
1189 bool GLRenderer::flippedFramebuffer() const | 1255 bool GLRenderer::flippedFramebuffer() const |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1299 // We're done! Time to swapbuffers! | 1365 // We're done! Time to swapbuffers! |
1300 | 1366 |
1301 if (m_capabilities.usingPartialSwap) { | 1367 if (m_capabilities.usingPartialSwap) { |
1302 // If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport) | 1368 // If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport) |
1303 m_swapBufferRect.Intersect(gfx::Rect(gfx::Point(), viewportSize())); | 1369 m_swapBufferRect.Intersect(gfx::Rect(gfx::Point(), viewportSize())); |
1304 int flippedYPosOfRectBottom = viewportHeight() - m_swapBufferRect.y() - m_swapBufferRect.height(); | 1370 int flippedYPosOfRectBottom = viewportHeight() - m_swapBufferRect.y() - m_swapBufferRect.height(); |
1305 m_context->postSubBufferCHROMIUM(m_swapBufferRect.x(), flippedYPosOfRect Bottom, m_swapBufferRect.width(), m_swapBufferRect.height()); | 1371 m_context->postSubBufferCHROMIUM(m_swapBufferRect.x(), flippedYPosOfRect Bottom, m_swapBufferRect.width(), m_swapBufferRect.height()); |
1306 } else { | 1372 } else { |
1307 // Note that currently this has the same effect as swapBuffers; we shoul d | 1373 // Note that currently this has the same effect as swapBuffers; we shoul d |
1308 // consider exposing a different entry point on WebGraphicsContext3D. | 1374 // consider exposing a different entry point on WebGraphicsContext3D. |
1309 m_context->prepareTexture(); | 1375 if (m_renderToMailbox) |
1376 m_context->flush(); | |
piman
2013/01/18 02:14:11
We definitely also want to support the partial swa
Sami
2013/01/25 23:17:27
Is it necessary to flush after inserting a sync po
piman
2013/01/25 23:44:56
The flush isn't necessary to ensure the sync point
Sami
2013/01/26 00:30:27
Thanks for the explanation. I was just wondering w
piman
2013/01/26 00:37:35
It does an implicit shallow flush FWIW, to ensure
| |
1377 else | |
1378 m_context->prepareTexture(); | |
1310 } | 1379 } |
1311 | 1380 |
1312 m_swapBufferRect = gfx::Rect(); | 1381 m_swapBufferRect = gfx::Rect(); |
1313 | 1382 |
1314 return true; | 1383 return true; |
1315 } | 1384 } |
1316 | 1385 |
1317 void GLRenderer::onSwapBuffersComplete() | 1386 void GLRenderer::onSwapBuffersComplete() |
1318 { | 1387 { |
1319 m_client->onSwapBuffersComplete(); | 1388 m_client->onSwapBuffersComplete(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1367 TRACE_EVENT0("cc", "GLRenderer::enforceMemoryPolicy dropping resources") ; | 1436 TRACE_EVENT0("cc", "GLRenderer::enforceMemoryPolicy dropping resources") ; |
1368 releaseRenderPassTextures(); | 1437 releaseRenderPassTextures(); |
1369 if (m_discardBackbufferWhenNotVisible) | 1438 if (m_discardBackbufferWhenNotVisible) |
1370 discardBackbuffer(); | 1439 discardBackbuffer(); |
1371 GLC(m_context, m_context->flush()); | 1440 GLC(m_context, m_context->flush()); |
1372 } | 1441 } |
1373 } | 1442 } |
1374 | 1443 |
1375 void GLRenderer::discardBackbuffer() | 1444 void GLRenderer::discardBackbuffer() |
1376 { | 1445 { |
1377 if (m_isBackbufferDiscarded) | 1446 if (m_renderToMailbox && m_currentBacking.textureId) { |
1378 return; | 1447 if (m_currentBacking.textureId) { |
1448 context()->deleteTexture(m_currentBacking.textureId); | |
1449 m_currentBacking.textureId = 0; | |
1450 m_currentBacking.mailbox = Mailbox(); | |
1451 } | |
1379 | 1452 |
1380 if (!m_capabilities.usingDiscardBackbuffer) | 1453 while (m_returnedTextures.size()) { |
1381 return; | 1454 m_context->deleteTexture(m_returnedTextures.front()); |
1455 m_returnedTextures.pop(); | |
1456 } | |
1382 | 1457 |
1383 m_context->discardBackbufferCHROMIUM(); | 1458 } else { |
1459 if (m_isBackbufferDiscarded) | |
1460 return; | |
1461 | |
1462 if (!m_capabilities.usingDiscardBackbuffer) | |
1463 return; | |
1464 | |
1465 m_context->discardBackbufferCHROMIUM(); | |
1466 } | |
1467 | |
1384 m_isBackbufferDiscarded = true; | 1468 m_isBackbufferDiscarded = true; |
1385 | 1469 |
1386 // Damage tracker needs a full reset every time framebuffer is discarded. | 1470 // Damage tracker needs a full reset every time framebuffer is discarded. |
1387 m_client->setFullRootLayerDamage(); | 1471 m_client->setFullRootLayerDamage(); |
1388 } | 1472 } |
1389 | 1473 |
1390 void GLRenderer::ensureBackbuffer() | 1474 void GLRenderer::ensureBackbuffer() |
1391 { | 1475 { |
1392 if (!m_isBackbufferDiscarded) | 1476 if (m_renderToMailbox) { |
1393 return; | 1477 if (!m_currentBacking.textureId) { |
1478 while (m_returnedTextures.size()) { | |
1479 MailboxTexture& texture = m_returnedTextures.front(); | |
1480 if (texture.size == viewportSize()) { | |
1481 m_currentBacking = texture; | |
1482 m_returnedTextures.pop(); | |
1483 break; | |
1484 } | |
1394 | 1485 |
1395 if (!m_capabilities.usingDiscardBackbuffer) | 1486 m_context->deleteTexture(texture.textureId); |
1396 return; | 1487 m_returnedTextures.pop(); |
1488 } | |
1397 | 1489 |
1398 m_context->ensureBackbufferCHROMIUM(); | 1490 if (!m_currentBacking.textureId) { |
1491 m_currentBacking.textureId = context()->createTexture(); | |
1492 m_currentBacking.size = viewportSize(); | |
1493 m_context->genMailboxCHROMIUM(m_currentBacking.mailbox.name); | |
1494 m_context->bindTexture(GL_TEXTURE_2D, m_currentBacking.textureId ); | |
1495 m_context->texParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, G L_LINEAR); | |
Sami
2013/01/25 23:17:27
Nit: could use texParameteri consistently.
no sievers
2013/02/06 23:36:00
Done.
| |
1496 m_context->texParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, G L_LINEAR); | |
1497 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CL AMP_TO_EDGE); | |
1498 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CL AMP_TO_EDGE); | |
1499 m_context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, | |
1500 viewportSize().width(), viewportSize().hei ght(), 0, | |
1501 GL_RGBA, GL_UNSIGNED_BYTE, NULL); | |
1502 } | |
1503 DCHECK(m_currentBacking.textureId); | |
1504 } | |
1505 } else { | |
1506 if (!m_isBackbufferDiscarded) | |
1507 return; | |
1508 | |
1509 if (!m_capabilities.usingDiscardBackbuffer) | |
1510 return; | |
1511 | |
1512 m_context->ensureBackbufferCHROMIUM(); | |
1513 } | |
1399 m_isBackbufferDiscarded = false; | 1514 m_isBackbufferDiscarded = false; |
1400 } | 1515 } |
1401 | 1516 |
1402 void GLRenderer::onContextLost() | 1517 void GLRenderer::onContextLost() |
1403 { | 1518 { |
1404 m_client->didLoseOutputSurface(); | 1519 m_client->didLoseOutputSurface(); |
1405 } | 1520 } |
1406 | 1521 |
1407 | 1522 |
1408 void GLRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect) | 1523 void GLRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1492 DCHECK(texture->id()); | 1607 DCHECK(texture->id()); |
1493 frame.currentRenderPass = 0; | 1608 frame.currentRenderPass = 0; |
1494 frame.currentTexture = texture; | 1609 frame.currentTexture = texture; |
1495 | 1610 |
1496 return bindFramebufferToTexture(frame, texture, viewportRect); | 1611 return bindFramebufferToTexture(frame, texture, viewportRect); |
1497 } | 1612 } |
1498 | 1613 |
1499 void GLRenderer::bindFramebufferToOutputSurface(DrawingFrame& frame) | 1614 void GLRenderer::bindFramebufferToOutputSurface(DrawingFrame& frame) |
1500 { | 1615 { |
1501 m_currentFramebufferLock.reset(); | 1616 m_currentFramebufferLock.reset(); |
1502 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, 0)); | 1617 |
1618 if (m_renderToMailbox) { | |
1619 ensureBackbuffer(); | |
1620 DCHECK(m_offscreenFramebufferId); | |
1621 DCHECK(m_currentBacking.textureId); | |
1622 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, m_offscreenFra mebufferId)); | |
1623 GLC(m_context, m_context->framebufferTexture2D( | |
1624 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_currentBa cking.textureId, 0)); | |
1625 } else { | |
1626 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, 0)); | |
1627 } | |
1503 } | 1628 } |
1504 | 1629 |
1505 bool GLRenderer::bindFramebufferToTexture(DrawingFrame& frame, const ScopedResou rce* texture, const gfx::Rect& framebufferRect) | 1630 bool GLRenderer::bindFramebufferToTexture(DrawingFrame& frame, const ScopedResou rce* texture, const gfx::Rect& framebufferRect) |
1506 { | 1631 { |
1507 DCHECK(texture->id()); | 1632 DCHECK(texture->id()); |
1508 | 1633 |
1509 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, m_offscreenFramebu fferId)); | 1634 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, m_offscreenFramebu fferId)); |
1510 m_currentFramebufferLock = make_scoped_ptr(new ResourceProvider::ScopedWrite LockGL(m_resourceProvider, texture->id())); | 1635 m_currentFramebufferLock = make_scoped_ptr(new ResourceProvider::ScopedWrite LockGL(m_resourceProvider, texture->id())); |
1511 unsigned textureId = m_currentFramebufferLock->textureId(); | 1636 unsigned textureId = m_currentFramebufferLock->textureId(); |
1512 GLC(m_context, m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTA CHMENT0, GL_TEXTURE_2D, textureId, 0)); | 1637 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 Loading... | |
1797 | 1922 |
1798 releaseRenderPassTextures(); | 1923 releaseRenderPassTextures(); |
1799 } | 1924 } |
1800 | 1925 |
1801 bool GLRenderer::isContextLost() | 1926 bool GLRenderer::isContextLost() |
1802 { | 1927 { |
1803 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1928 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1804 } | 1929 } |
1805 | 1930 |
1806 } // namespace cc | 1931 } // namespace cc |
OLD | NEW |