OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 PassOwnPtr<LayerPainterChromium> co
ntentPaint, | 140 PassOwnPtr<LayerPainterChromium> co
ntentPaint, |
141 bool accelerateDrawing) | 141 bool accelerateDrawing) |
142 : CCLayerTreeHost(client) | 142 : CCLayerTreeHost(client) |
143 , m_viewportScrollPosition(IntPoint(-1, -1)) | 143 , m_viewportScrollPosition(IntPoint(-1, -1)) |
144 , m_rootLayer(0) | 144 , m_rootLayer(0) |
145 , m_accelerateDrawing(false) | 145 , m_accelerateDrawing(false) |
146 , m_currentRenderSurface(0) | 146 , m_currentRenderSurface(0) |
147 , m_offscreenFramebufferId(0) | 147 , m_offscreenFramebufferId(0) |
148 , m_compositeOffscreen(false) | 148 , m_compositeOffscreen(false) |
149 , m_context(context) | 149 , m_context(context) |
150 , m_contextSupportsLatch(false) | |
151 , m_contextSupportsTextureFormatBGRA(false) | 150 , m_contextSupportsTextureFormatBGRA(false) |
152 , m_contextSupportsReadFormatBGRA(false) | 151 , m_contextSupportsReadFormatBGRA(false) |
153 , m_animating(false) | 152 , m_animating(false) |
154 , m_defaultRenderSurface(0) | 153 , m_defaultRenderSurface(0) |
155 { | 154 { |
156 WebCore::Extensions3D* extensions = m_context->getExtensions(); | 155 WebCore::Extensions3D* extensions = m_context->getExtensions(); |
157 m_contextSupportsLatch = extensions->supports("GL_CHROMIUM_latch"); | |
158 m_contextSupportsMapSub = extensions->supports("GL_CHROMIUM_map_sub"); | 156 m_contextSupportsMapSub = extensions->supports("GL_CHROMIUM_map_sub"); |
159 if (m_contextSupportsMapSub) | 157 if (m_contextSupportsMapSub) |
160 extensions->ensureEnabled("GL_CHROMIUM_map_sub"); | 158 extensions->ensureEnabled("GL_CHROMIUM_map_sub"); |
161 m_contextSupportsTextureFormatBGRA = extensions->supports("GL_EXT_texture_fo
rmat_BGRA8888"); | 159 m_contextSupportsTextureFormatBGRA = extensions->supports("GL_EXT_texture_fo
rmat_BGRA8888"); |
162 if (m_contextSupportsTextureFormatBGRA) | 160 if (m_contextSupportsTextureFormatBGRA) |
163 extensions->ensureEnabled("GL_EXT_texture_format_BGRA8888"); | 161 extensions->ensureEnabled("GL_EXT_texture_format_BGRA8888"); |
164 m_contextSupportsReadFormatBGRA = extensions->supports("GL_EXT_read_format_b
gra"); | 162 m_contextSupportsReadFormatBGRA = extensions->supports("GL_EXT_read_format_b
gra"); |
165 if (m_contextSupportsReadFormatBGRA) | 163 if (m_contextSupportsReadFormatBGRA) |
166 extensions->ensureEnabled("GL_EXT_read_format_bgra"); | 164 extensions->ensureEnabled("GL_EXT_read_format_bgra"); |
167 | 165 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 291 |
294 m_computedRenderSurfaceLayerList = adoptPtr(new LayerList()); | 292 m_computedRenderSurfaceLayerList = adoptPtr(new LayerList()); |
295 updateLayers(*m_computedRenderSurfaceLayerList); | 293 updateLayers(*m_computedRenderSurfaceLayerList); |
296 } | 294 } |
297 | 295 |
298 void LayerRendererChromium::drawLayers() | 296 void LayerRendererChromium::drawLayers() |
299 { | 297 { |
300 ASSERT(m_hardwareCompositing); | 298 ASSERT(m_hardwareCompositing); |
301 ASSERT(m_computedRenderSurfaceLayerList); | 299 ASSERT(m_computedRenderSurfaceLayerList); |
302 // Before drawLayers: | 300 // Before drawLayers: |
303 if (hardwareCompositing() && m_contextSupportsLatch) { | 301 if (hardwareCompositing()) { |
304 // FIXME: The multithreaded compositor case will not work as long as | 302 // FIXME: The multithreaded compositor case will not work as long as |
305 // copyTexImage2D resolves to the parent texture, because the main | 303 // copyTexImage2D resolves to the parent texture, because the main |
306 // thread can execute WebGL calls on the child context at any time, | 304 // thread can execute WebGL calls on the child context at any time, |
307 // potentially clobbering the parent texture that is being renderered | 305 // potentially clobbering the parent texture that is being renderered |
308 // by the compositor thread. | 306 // by the compositor thread. |
309 Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>(m_c
ontext->getExtensions()); | |
310 // For each child context: | |
311 // glWaitLatch(Offscreen->Compositor); | |
312 ChildContextMap::iterator i = m_childContexts.begin(); | 307 ChildContextMap::iterator i = m_childContexts.begin(); |
313 for (; i != m_childContexts.end(); ++i) { | 308 for (; i != m_childContexts.end(); ++i) { |
314 Extensions3DChromium* childExt = static_cast<Extensions3DChromium*>(
i->first->getExtensions()); | 309 i->first->flush(); |
315 if (childExt->getGraphicsResetStatusARB() == GraphicsContext3D::NO_E
RROR) { | |
316 GC3Duint childToParentLatchId; | |
317 childExt->getChildToParentLatchCHROMIUM(&childToParentLatchId); | |
318 childExt->setLatchCHROMIUM(childToParentLatchId); | |
319 parentExt->waitLatchCHROMIUM(childToParentLatchId); | |
320 } | |
321 } | 310 } |
322 } | 311 } |
323 | 312 |
324 m_renderSurfaceTextureManager->setMemoryLimitBytes(textureMemoryHighLimitByt
es - m_contentsTextureManager->currentMemoryUseBytes()); | 313 m_renderSurfaceTextureManager->setMemoryLimitBytes(textureMemoryHighLimitByt
es - m_contentsTextureManager->currentMemoryUseBytes()); |
325 drawLayers(*m_computedRenderSurfaceLayerList); | 314 drawLayers(*m_computedRenderSurfaceLayerList); |
326 | 315 |
327 m_contentsTextureManager->unprotectAllTextures(); | 316 m_contentsTextureManager->unprotectAllTextures(); |
328 m_contentsTextureManager->reduceMemoryToLimit(textureMemoryReclaimLimitBytes
); | 317 m_contentsTextureManager->reduceMemoryToLimit(textureMemoryReclaimLimitBytes
); |
329 | 318 |
330 if (textureMemoryReclaimLimitBytes > m_contentsTextureManager->currentMemory
UseBytes()) | 319 if (textureMemoryReclaimLimitBytes > m_contentsTextureManager->currentMemory
UseBytes()) |
331 m_renderSurfaceTextureManager->reduceMemoryToLimit(textureMemoryReclaimL
imitBytes - m_contentsTextureManager->currentMemoryUseBytes()); | 320 m_renderSurfaceTextureManager->reduceMemoryToLimit(textureMemoryReclaimL
imitBytes - m_contentsTextureManager->currentMemoryUseBytes()); |
332 else | 321 else |
333 m_renderSurfaceTextureManager->reduceMemoryToLimit(0); | 322 m_renderSurfaceTextureManager->reduceMemoryToLimit(0); |
334 | 323 |
335 // After drawLayers: | |
336 if (hardwareCompositing() && m_contextSupportsLatch) { | |
337 Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>(m_c
ontext->getExtensions()); | |
338 // For each child context: | |
339 // glSetLatch(Compositor->Offscreen); | |
340 ChildContextMap::iterator i = m_childContexts.begin(); | |
341 for (; i != m_childContexts.end(); ++i) { | |
342 Extensions3DChromium* childExt = static_cast<Extensions3DChromium*>(
i->first->getExtensions()); | |
343 if (childExt->getGraphicsResetStatusARB() == GraphicsContext3D::NO_E
RROR) { | |
344 GC3Duint parentToChildLatchId; | |
345 childExt->getParentToChildLatchCHROMIUM(&parentToChildLatchId); | |
346 parentExt->setLatchCHROMIUM(parentToChildLatchId); | |
347 childExt->waitLatchCHROMIUM(parentToChildLatchId); | |
348 } | |
349 } | |
350 } | |
351 | |
352 if (isCompositingOffscreen()) | 324 if (isCompositingOffscreen()) |
353 copyOffscreenTextureToDisplay(); | 325 copyOffscreenTextureToDisplay(); |
354 } | 326 } |
355 | 327 |
356 void LayerRendererChromium::updateLayers(LayerList& renderSurfaceLayerList) | 328 void LayerRendererChromium::updateLayers(LayerList& renderSurfaceLayerList) |
357 { | 329 { |
358 TRACE_EVENT("LayerRendererChromium::updateLayers", this, 0); | 330 TRACE_EVENT("LayerRendererChromium::updateLayers", this, 0); |
359 CCLayerImpl* rootDrawLayer = m_rootLayer->ccLayerImpl(); | 331 CCLayerImpl* rootDrawLayer = m_rootLayer->ccLayerImpl(); |
360 | 332 |
361 if (!rootDrawLayer->renderSurface()) | 333 if (!rootDrawLayer->renderSurface()) |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 if (m_rootLayer.get()) { | 1334 if (m_rootLayer.get()) { |
1363 ts << m_rootLayer->layerTreeAsText(); | 1335 ts << m_rootLayer->layerTreeAsText(); |
1364 ts << "RenderSurfaces:\n"; | 1336 ts << "RenderSurfaces:\n"; |
1365 dumpRenderSurfaces(ts, 1, m_rootLayer.get()); | 1337 dumpRenderSurfaces(ts, 1, m_rootLayer.get()); |
1366 } | 1338 } |
1367 return ts.release(); | 1339 return ts.release(); |
1368 } | 1340 } |
1369 | 1341 |
1370 void LayerRendererChromium::addChildContext(GraphicsContext3D* ctx) | 1342 void LayerRendererChromium::addChildContext(GraphicsContext3D* ctx) |
1371 { | 1343 { |
1372 if (!ctx->getExtensions()->supports("GL_CHROMIUM_latch")) | |
1373 return; | |
1374 | |
1375 // This is a ref-counting map, because some contexts are shared by multiple | 1344 // This is a ref-counting map, because some contexts are shared by multiple |
1376 // layers (specifically, Canvas2DLayerChromium). | 1345 // layers (specifically, Canvas2DLayerChromium). |
1377 | 1346 |
1378 // Insert the ctx with a count of 1, or return the existing iterator. | 1347 // Insert the ctx with a count of 1, or return the existing iterator. |
1379 std::pair<ChildContextMap::iterator, bool> insert_result = m_childContexts.a
dd(ctx, 1); | 1348 std::pair<ChildContextMap::iterator, bool> insert_result = m_childContexts.a
dd(ctx, 1); |
1380 if (!insert_result.second) { | 1349 if (!insert_result.second) { |
1381 // Already present in map, so increment. | 1350 // Already present in map, so increment. |
1382 ++insert_result.first->second; | 1351 ++insert_result.first->second; |
1383 } else { | 1352 } else { |
1384 // FIXME(jbates): when compositor is multithreaded and copyTexImage2D bug is fix
ed, | 1353 // FIXME(jbates): when compositor is multithreaded and copyTexImage2D bug is fix
ed, |
1385 // uncomment this block: | 1354 // uncomment this block: |
1386 // // This is a new child context - set the parentToChild latch so that it | 1355 // // This is a new child context - set the parentToChild latch so that it |
1387 // // can continue past its first wait latch. | 1356 // // can continue past its first wait latch. |
1388 // Extensions3DChromium* ext = static_cast<Extensions3DChromium*>(ctx->getE
xtensions()); | 1357 // Extensions3DChromium* ext = static_cast<Extensions3DChromium*>(ctx->getE
xtensions()); |
1389 // GC3Duint latchId; | 1358 // GC3Duint latchId; |
1390 // ext->getParentToChildLatchCHROMIUM(&latchId); | 1359 // ext->getParentToChildLatchCHROMIUM(&latchId); |
1391 // ext->setLatchCHROMIUM(0, latchId); | 1360 // ext->setLatchCHROMIUM(0, latchId); |
1392 } | 1361 } |
1393 } | 1362 } |
1394 | 1363 |
1395 void LayerRendererChromium::removeChildContext(GraphicsContext3D* ctx) | 1364 void LayerRendererChromium::removeChildContext(GraphicsContext3D* ctx) |
1396 { | 1365 { |
1397 if (!ctx->getExtensions()->supports("GL_CHROMIUM_latch")) | |
1398 return; | |
1399 | |
1400 ChildContextMap::iterator i = m_childContexts.find(ctx); | 1366 ChildContextMap::iterator i = m_childContexts.find(ctx); |
1401 if (i != m_childContexts.end()) { | 1367 if (i != m_childContexts.end()) { |
1402 if (--i->second <= 0) { | 1368 if (--i->second <= 0) { |
1403 // Count reached zero, so remove from map. | 1369 // Count reached zero, so remove from map. |
1404 m_childContexts.remove(i); | 1370 m_childContexts.remove(i); |
1405 } | 1371 } |
1406 } else { | 1372 } else { |
1407 // error | 1373 // error |
1408 ASSERT(0 && "m_childContexts map has mismatched add/remove calls"); | 1374 ASSERT(0 && "m_childContexts map has mismatched add/remove calls"); |
1409 } | 1375 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 PassOwnPtr<CCLayerTreeHostImplProxy> LayerRendererChromium::createLayerTreeHostI
mplProxy() | 1453 PassOwnPtr<CCLayerTreeHostImplProxy> LayerRendererChromium::createLayerTreeHostI
mplProxy() |
1488 { | 1454 { |
1489 OwnPtr<CCLayerTreeHostImplProxy> proxy = LayerRendererChromiumImplProxy::cre
ate(this); | 1455 OwnPtr<CCLayerTreeHostImplProxy> proxy = LayerRendererChromiumImplProxy::cre
ate(this); |
1490 proxy->start(); | 1456 proxy->start(); |
1491 return proxy.release(); | 1457 return proxy.release(); |
1492 } | 1458 } |
1493 | 1459 |
1494 } // namespace WebCore | 1460 } // namespace WebCore |
1495 | 1461 |
1496 #endif // USE(ACCELERATED_COMPOSITING) | 1462 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |