| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 LayerRendererChromium::LayerRendererChromium(PassRefPtr<GraphicsContext3D> conte
xt, | 113 LayerRendererChromium::LayerRendererChromium(PassRefPtr<GraphicsContext3D> conte
xt, |
| 114 PassOwnPtr<LayerPainterChromium> co
ntentPaint, | 114 PassOwnPtr<LayerPainterChromium> co
ntentPaint, |
| 115 bool accelerateDrawing) | 115 bool accelerateDrawing) |
| 116 : m_viewportScrollPosition(IntPoint(-1, -1)) | 116 : m_viewportScrollPosition(IntPoint(-1, -1)) |
| 117 , m_rootLayer(0) | 117 , m_rootLayer(0) |
| 118 , m_accelerateDrawing(accelerateDrawing) | 118 , m_accelerateDrawing(accelerateDrawing) |
| 119 , m_currentRenderSurface(0) | 119 , m_currentRenderSurface(0) |
| 120 , m_offscreenFramebufferId(0) | 120 , m_offscreenFramebufferId(0) |
| 121 , m_compositeOffscreen(false) | 121 , m_compositeOffscreen(false) |
| 122 , m_context(context) | 122 , m_context(context) |
| 123 , m_childContextsWereCopied(false) | |
| 124 , m_contextSupportsLatch(false) | 123 , m_contextSupportsLatch(false) |
| 125 , m_animating(false) | 124 , m_animating(false) |
| 126 , m_defaultRenderSurface(0) | 125 , m_defaultRenderSurface(0) |
| 127 { | 126 { |
| 128 m_contextSupportsLatch = m_context->getExtensions()->supports("GL_CHROMIUM_l
atch"); | 127 m_contextSupportsLatch = m_context->getExtensions()->supports("GL_CHROMIUM_l
atch"); |
| 129 m_contextSupportsMapSub = m_context->getExtensions()->supports("GL_CHROMIUM_
map_sub"); | 128 m_contextSupportsMapSub = m_context->getExtensions()->supports("GL_CHROMIUM_
map_sub"); |
| 130 if (m_contextSupportsMapSub) | 129 if (m_contextSupportsMapSub) |
| 131 m_context->getExtensions()->ensureEnabled("GL_CHROMIUM_map_sub"); | 130 m_context->getExtensions()->ensureEnabled("GL_CHROMIUM_map_sub"); |
| 132 m_hardwareCompositing = initializeSharedObjects(); | 131 m_hardwareCompositing = initializeSharedObjects(); |
| 133 | 132 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 LayerList renderSurfaceLayerList; | 237 LayerList renderSurfaceLayerList; |
| 239 updateLayers(renderSurfaceLayerList); | 238 updateLayers(renderSurfaceLayerList); |
| 240 | 239 |
| 241 // Before drawLayers: | 240 // Before drawLayers: |
| 242 if (hardwareCompositing() && m_contextSupportsLatch) { | 241 if (hardwareCompositing() && m_contextSupportsLatch) { |
| 243 // FIXME: The multithreaded compositor case will not work as long as | 242 // FIXME: The multithreaded compositor case will not work as long as |
| 244 // copyTexImage2D resolves to the parent texture, because the main | 243 // copyTexImage2D resolves to the parent texture, because the main |
| 245 // thread can execute WebGL calls on the child context at any time, | 244 // thread can execute WebGL calls on the child context at any time, |
| 246 // potentially clobbering the parent texture that is being renderered | 245 // potentially clobbering the parent texture that is being renderered |
| 247 // by the compositor thread. | 246 // by the compositor thread. |
| 248 if (m_childContextsWereCopied) { | 247 Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>(m_c
ontext->getExtensions()); |
| 249 Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>
(m_context->getExtensions()); | 248 // For each child context: |
| 250 // For each child context: | 249 // glWaitLatch(Offscreen->Compositor); |
| 251 // glWaitLatch(Offscreen->Compositor); | 250 ChildContextMap::iterator i = m_childContexts.begin(); |
| 252 ChildContextMap::iterator i = m_childContexts.begin(); | 251 for (; i != m_childContexts.end(); ++i) { |
| 253 for (; i != m_childContexts.end(); ++i) { | 252 Extensions3DChromium* childExt = static_cast<Extensions3DChromium*>(
i->first->getExtensions()); |
| 254 Extensions3DChromium* childExt = static_cast<Extensions3DChromiu
m*>(i->first->getExtensions()); | 253 if (childExt->getGraphicsResetStatusARB() == GraphicsContext3D::NO_E
RROR) { |
| 255 GC3Duint latchId; | 254 GC3Duint childToParentLatchId; |
| 256 childExt->getChildToParentLatchCHROMIUM(&latchId); | 255 childExt->getChildToParentLatchCHROMIUM(&childToParentLatchId); |
| 257 parentExt->waitLatchCHROMIUM(latchId); | 256 childExt->setLatchCHROMIUM(childToParentLatchId); |
| 257 parentExt->waitLatchCHROMIUM(childToParentLatchId); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 // Reset to false to indicate that we have consumed the dirty child | |
| 261 // contexts' parent textures. (This is only useful when the compositor | |
| 262 // is multithreaded.) | |
| 263 m_childContextsWereCopied = false; | |
| 264 } | 260 } |
| 265 | 261 |
| 266 drawLayers(renderSurfaceLayerList); | 262 drawLayers(renderSurfaceLayerList); |
| 267 | 263 |
| 268 m_textureManager->unprotectAllTextures(); | 264 m_textureManager->unprotectAllTextures(); |
| 269 | 265 |
| 270 // After drawLayers: | 266 // After drawLayers: |
| 271 if (hardwareCompositing() && m_contextSupportsLatch) { | 267 if (hardwareCompositing() && m_contextSupportsLatch) { |
| 272 Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>(m_c
ontext->getExtensions()); | 268 Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>(m_c
ontext->getExtensions()); |
| 273 // For each child context: | 269 // For each child context: |
| 274 // glSetLatch(Compositor->Offscreen); | 270 // glSetLatch(Compositor->Offscreen); |
| 275 ChildContextMap::iterator i = m_childContexts.begin(); | 271 ChildContextMap::iterator i = m_childContexts.begin(); |
| 276 for (; i != m_childContexts.end(); ++i) { | 272 for (; i != m_childContexts.end(); ++i) { |
| 277 Extensions3DChromium* childExt = static_cast<Extensions3DChromium*>(
i->first->getExtensions()); | 273 Extensions3DChromium* childExt = static_cast<Extensions3DChromium*>(
i->first->getExtensions()); |
| 278 GC3Duint latchId; | 274 if (childExt->getGraphicsResetStatusARB() == GraphicsContext3D::NO_E
RROR) { |
| 279 childExt->getParentToChildLatchCHROMIUM(&latchId); | 275 GC3Duint parentToChildLatchId; |
| 280 parentExt->setLatchCHROMIUM(latchId); | 276 childExt->getParentToChildLatchCHROMIUM(&parentToChildLatchId); |
| 277 parentExt->setLatchCHROMIUM(parentToChildLatchId); |
| 278 childExt->waitLatchCHROMIUM(parentToChildLatchId); |
| 279 } |
| 281 } | 280 } |
| 282 } | 281 } |
| 283 | 282 |
| 284 if (isCompositingOffscreen()) | 283 if (isCompositingOffscreen()) |
| 285 copyOffscreenTextureToDisplay(); | 284 copyOffscreenTextureToDisplay(); |
| 286 } | 285 } |
| 287 | 286 |
| 288 PassOwnPtr<LayerTextureUpdater> LayerRendererChromium::createRootLayerTextureUpd
ater(PassOwnPtr<LayerPainterChromium> painter) | 287 PassOwnPtr<LayerTextureUpdater> LayerRendererChromium::createRootLayerTextureUpd
ater(PassOwnPtr<LayerPainterChromium> painter) |
| 289 { | 288 { |
| 290 #if USE(SKIA) | 289 #if USE(SKIA) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 updatePropertiesAndRenderSurfaces(rootDrawLayer, identityMatrix, renderSurfa
ceLayerList, m_defaultRenderSurface->m_layerList); | 322 updatePropertiesAndRenderSurfaces(rootDrawLayer, identityMatrix, renderSurfa
ceLayerList, m_defaultRenderSurface->m_layerList); |
| 324 | 323 |
| 325 #ifndef NDEBUG | 324 #ifndef NDEBUG |
| 326 s_inPaintLayerContents = true; | 325 s_inPaintLayerContents = true; |
| 327 #endif | 326 #endif |
| 328 paintLayerContents(renderSurfaceLayerList); | 327 paintLayerContents(renderSurfaceLayerList); |
| 329 #ifndef NDEBUG | 328 #ifndef NDEBUG |
| 330 s_inPaintLayerContents = false; | 329 s_inPaintLayerContents = false; |
| 331 #endif | 330 #endif |
| 332 | 331 |
| 333 // FIXME: Before updateCompositorResources, when the compositor runs in | |
| 334 // its own thread, and when the copyTexImage2D bug is fixed, insert | |
| 335 // a glWaitLatch(Compositor->Offscreen) on all child contexts here instead | |
| 336 // of after updateCompositorResources. | |
| 337 // Also uncomment the glSetLatch(Compositor->Offscreen) code in addChildCont
ext. | |
| 338 // if (hardwareCompositing() && m_contextSupportsLatch) { | |
| 339 // // For each child context: | |
| 340 // // glWaitLatch(Compositor->Offscreen); | |
| 341 // ChildContextMap::iterator i = m_childContexts.begin(); | |
| 342 // for (; i != m_childContexts.end(); ++i) { | |
| 343 // Extensions3DChromium* ext = static_cast<Extensions3DChromium*>(i->fi
rst->getExtensions()); | |
| 344 // GC3Duint childToParentLatchId, parentToChildLatchId; | |
| 345 // ext->getParentToChildLatchCHROMIUM(&parentToChildLatchId); | |
| 346 // ext->waitLatchCHROMIUM(parentToChildLatchId); | |
| 347 // } | |
| 348 // } | |
| 349 | |
| 350 updateCompositorResources(renderSurfaceLayerList); | 332 updateCompositorResources(renderSurfaceLayerList); |
| 351 // Update compositor resources for root layer. | 333 // Update compositor resources for root layer. |
| 352 m_rootLayerContentTiler->updateRect(); | 334 m_rootLayerContentTiler->updateRect(); |
| 353 | |
| 354 // After updateCompositorResources, set/wait latches for all child | |
| 355 // contexts. This will prevent the compositor from using any of the child | |
| 356 // parent textures while WebGL commands are executing from javascript *and* | |
| 357 // while the final parent texture is being blit'd. copyTexImage2D | |
| 358 // uses the parent texture as a temporary resolve buffer, so that's why the | |
| 359 // waitLatch is below, to block the compositor from using the parent texture | |
| 360 // until the next WebGL SwapBuffers (or copyTextureToParentTexture for | |
| 361 // Canvas2D). | |
| 362 if (hardwareCompositing() && m_contextSupportsLatch) { | |
| 363 m_childContextsWereCopied = true; | |
| 364 // For each child context: | |
| 365 // glSetLatch(Offscreen->Compositor); | |
| 366 // glWaitLatch(Compositor->Offscreen); | |
| 367 ChildContextMap::iterator i = m_childContexts.begin(); | |
| 368 for (; i != m_childContexts.end(); ++i) { | |
| 369 Extensions3DChromium* ext = static_cast<Extensions3DChromium*>(i->fi
rst->getExtensions()); | |
| 370 GC3Duint childToParentLatchId, parentToChildLatchId; | |
| 371 ext->getParentToChildLatchCHROMIUM(&parentToChildLatchId); | |
| 372 ext->getChildToParentLatchCHROMIUM(&childToParentLatchId); | |
| 373 ext->setLatchCHROMIUM(childToParentLatchId); | |
| 374 ext->waitLatchCHROMIUM(parentToChildLatchId); | |
| 375 } | |
| 376 } | |
| 377 } | 335 } |
| 378 | 336 |
| 379 void LayerRendererChromium::paintLayerContents(const LayerList& renderSurfaceLay
erList) | 337 void LayerRendererChromium::paintLayerContents(const LayerList& renderSurfaceLay
erList) |
| 380 { | 338 { |
| 381 for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0
; --surfaceIndex) { | 339 for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0
; --surfaceIndex) { |
| 382 CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].g
et(); | 340 CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].g
et(); |
| 383 RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface
(); | 341 RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface
(); |
| 384 ASSERT(renderSurface); | 342 ASSERT(renderSurface); |
| 385 | 343 |
| 386 // Make sure any renderSurfaceLayer is associated with this layerRendere
r. | 344 // Make sure any renderSurfaceLayer is associated with this layerRendere
r. |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 if (--i->second <= 0) { | 1136 if (--i->second <= 0) { |
| 1179 // Count reached zero, so remove from map. | 1137 // Count reached zero, so remove from map. |
| 1180 m_childContexts.remove(i); | 1138 m_childContexts.remove(i); |
| 1181 } | 1139 } |
| 1182 } else { | 1140 } else { |
| 1183 // error | 1141 // error |
| 1184 ASSERT(0 && "m_childContexts map has mismatched add/remove calls"); | 1142 ASSERT(0 && "m_childContexts map has mismatched add/remove calls"); |
| 1185 } | 1143 } |
| 1186 } | 1144 } |
| 1187 | 1145 |
| 1146 bool LayerRendererChromium::isCompositorContextLost() |
| 1147 { |
| 1148 return (m_context.get()->getExtensions()->getGraphicsResetStatusARB() != Gra
phicsContext3D::NO_ERROR); |
| 1149 } |
| 1150 |
| 1188 void LayerRendererChromium::dumpRenderSurfaces(TextStream& ts, int indent, Layer
Chromium* layer) const | 1151 void LayerRendererChromium::dumpRenderSurfaces(TextStream& ts, int indent, Layer
Chromium* layer) const |
| 1189 { | 1152 { |
| 1190 if (layer->ccLayerImpl()->renderSurface()) | 1153 if (layer->ccLayerImpl()->renderSurface()) |
| 1191 layer->ccLayerImpl()->renderSurface()->dumpSurface(ts, indent); | 1154 layer->ccLayerImpl()->renderSurface()->dumpSurface(ts, indent); |
| 1192 | 1155 |
| 1193 for (size_t i = 0; i < layer->children().size(); ++i) | 1156 for (size_t i = 0; i < layer->children().size(); ++i) |
| 1194 dumpRenderSurfaces(ts, indent, layer->children()[i].get()); | 1157 dumpRenderSurfaces(ts, indent, layer->children()[i].get()); |
| 1195 } | 1158 } |
| 1196 | 1159 |
| 1197 } // namespace WebCore | 1160 } // namespace WebCore |
| 1198 | 1161 |
| 1199 #endif // USE(ACCELERATED_COMPOSITING) | 1162 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |