void LayerRendererChromium::drawLayers() { // FIXME: use the frame begin time from the overall compositor scheduler. // This value is currently inaccessible because it is up in Chromium's // RenderWidget. m_headsUpDisplay->onFrameBegin(currentTime()); if (!rootLayer()) return; size_t contentsMemoryUseBytes = m_contentsTextureAllocator->currentMemoryUseBytes(); m_renderSurfaceTextureManager->setMemoryLimitBytes(TextureManager::highLimitBytes() - contentsMemoryUseBytes); drawLayersInternal(); if (TextureManager::reclaimLimitBytes() > contentsMemoryUseBytes) m_renderSurfaceTextureManager->reduceMemoryToLimit(TextureManager::reclaimLimitBytes() - contentsMemoryUseBytes); else m_renderSurfaceTextureManager->reduceMemoryToLimit(0); m_renderSurfaceTextureManager->deleteEvictedTextures(m_renderSurfaceTextureAllocator.get()); if (settings().compositeOffscreen) copyOffscreenTextureToDisplay(); }
void LayerRendererChromium::updateAndDrawLayers() { // FIXME: use the frame begin time from the overall compositor scheduler. // This value is currently inaccessible because it is up in Chromium's // RenderWidget. m_headsUpDisplay->onFrameBegin(currentTime()); ASSERT(m_hardwareCompositing); if (!m_rootLayer) return; updateRootLayerContents(); // Recheck that we still have a root layer. This may become null if // compositing gets turned off during a paint operation. if (!m_rootLayer) return; { TRACE_EVENT("LayerRendererChromium::synchronizeTrees", this, 0); m_rootCCLayerImpl = TreeSynchronizer::synchronizeTrees(m_rootLayer.get(), m_rootCCLayerImpl.get()); } LayerList renderSurfaceLayerList; updateLayers(renderSurfaceLayerList); // Before drawLayers: if (hardwareCompositing() && m_contextSupportsLatch) { // FIXME: The multithreaded compositor case will not work as long as // copyTexImage2D resolves to the parent texture, because the main // thread can execute WebGL calls on the child context at any time, // potentially clobbering the parent texture that is being renderered // by the compositor thread. if (m_childContextsWereCopied) { Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>(m_context->getExtensions()); // For each child context: // glWaitLatch(Offscreen->Compositor); ChildContextMap::iterator i = m_childContexts.begin(); for (; i != m_childContexts.end(); ++i) { Extensions3DChromium* childExt = static_cast<Extensions3DChromium*>(i->first->getExtensions()); GC3Duint latchId; childExt->getChildToParentLatchCHROMIUM(&latchId); parentExt->waitLatchCHROMIUM(latchId); } } // Reset to false to indicate that we have consumed the dirty child // contexts' parent textures. (This is only useful when the compositor // is multithreaded.) m_childContextsWereCopied = false; } drawLayers(renderSurfaceLayerList); m_textureManager->unprotectAllTextures(); // After drawLayers: if (hardwareCompositing() && m_contextSupportsLatch) { Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>(m_context->getExtensions()); // For each child context: // glSetLatch(Compositor->Offscreen); ChildContextMap::iterator i = m_childContexts.begin(); for (; i != m_childContexts.end(); ++i) { Extensions3DChromium* childExt = static_cast<Extensions3DChromium*>(i->first->getExtensions()); GC3Duint latchId; childExt->getParentToChildLatchCHROMIUM(&latchId); parentExt->setLatchCHROMIUM(latchId); } } if (isCompositingOffscreen()) copyOffscreenTextureToDisplay(); }