void CCLayerTreeHostImpl::drawLayers() { TRACE_EVENT("CCLayerTreeHostImpl::drawLayers", this, 0); ASSERT(m_layerRenderer); if (!rootLayer()) return; CCRenderPassList passes; CCLayerList renderSurfaceLayerList; calculateRenderPasses(passes, renderSurfaceLayerList); optimizeRenderPasses(passes); m_layerRenderer->beginDrawingFrame(); for (size_t i = 0; i < passes.size(); ++i) m_layerRenderer->drawRenderPass(passes[i].get()); typedef CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, CCLayerIteratorActions::BackToFront> CCLayerIteratorType; CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList); for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) { if (it.representsItself() && !it->visibleLayerRect().isEmpty()) it->didDraw(); } m_layerRenderer->finishDrawingFrame(); ++m_frameNumber; // The next frame should start by assuming nothing has changed, and changes are noted as they occur. rootLayer()->resetAllChangeTrackingForSubtree(); }
void CCLayerTreeHost::reserveTextures(const LayerList& updateList) { // Use BackToFront since it's cheap and this isn't order-dependent. typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> CCLayerIteratorType; CCLayerIteratorType end = CCLayerIteratorType::end(&updateList); for (CCLayerIteratorType it = CCLayerIteratorType::begin(&updateList); it != end; ++it) { if (!it.representsItself() || !it->alwaysReserveTextures()) continue; it->reserveTextures(); } }
bool CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, CCTextureUpdateQueue& queue) { // Use FrontToBack to allow for testing occlusion and performing culling during the tree walk. typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType; bool needMoreUpdates = false; bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off. CCOcclusionTracker occlusionTracker(m_rootLayer->renderSurface()->contentRect(), recordMetricsForFrame); occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingSize); prioritizeTextures(renderSurfaceLayerList, occlusionTracker.overdrawMetrics()); CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList); for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) { occlusionTracker.enterLayer(it); if (it.representsTargetRenderSurface()) { ASSERT(it->renderSurface()->drawOpacity() || it->renderSurface()->drawOpacityIsAnimating()); needMoreUpdates |= paintMasksForRenderSurface(*it, queue); } else if (it.representsItself()) { ASSERT(!it->bounds().isEmpty()); it->update(queue, &occlusionTracker, m_renderingStats); needMoreUpdates |= it->needMoreUpdates(); } occlusionTracker.leaveLayer(it); } occlusionTracker.overdrawMetrics().recordMetrics(this); return needMoreUpdates; }
bool CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, CCTextureUpdater& updater) { // Use FrontToBack to allow for testing occlusion and performing culling during the tree walk. typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType; bool needMoreUpdates = false; bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off. CCOcclusionTracker occlusionTracker(IntRect(IntPoint(), deviceViewportSize()), recordMetricsForFrame); occlusionTracker.setMinimumTrackingSize(CCOcclusionTracker::preferredMinimumTrackingSize()); CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList); for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) { occlusionTracker.enterLayer(it); if (it.representsTargetRenderSurface()) { ASSERT(it->renderSurface()->drawOpacity() || it->renderSurface()->drawOpacityIsAnimating()); needMoreUpdates |= paintMasksForRenderSurface(*it, updater); } else if (it.representsItself()) { ASSERT(!it->bounds().isEmpty()); it->update(updater, &occlusionTracker); needMoreUpdates |= it->needMoreUpdates(); } occlusionTracker.leaveLayer(it); } occlusionTracker.overdrawMetrics().didUseContentsTextureMemoryBytes(m_contentsTextureManager->memoryAboveCutoffBytes()); occlusionTracker.overdrawMetrics().didUseRenderSurfaceTextureMemoryBytes(m_contentsTextureManager->memoryForRenderSurfacesBytes()); occlusionTracker.overdrawMetrics().recordMetrics(this); return needMoreUpdates; }
void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, PaintType paintType, CCTextureUpdater& updater) { // Use FrontToBack to allow for testing occlusion and performing culling during the tree walk. typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType; bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off. CCOcclusionTracker occlusionTracker(IntRect(IntPoint(), viewportSize()), recordMetricsForFrame); occlusionTracker.setUsePaintTracking(true); // FIXME: Remove this after m19 branch. CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList); for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) { occlusionTracker.enterLayer(it); if (it.representsTargetRenderSurface()) { ASSERT(it->renderSurface()->drawOpacity() || it->renderSurface()->drawOpacityIsAnimating()); paintMasksForRenderSurface(*it, paintType, updater); } else if (it.representsItself()) { ASSERT(!it->bounds().isEmpty()); update(*it, paintType, updater, &occlusionTracker); } occlusionTracker.leaveLayer(it); } occlusionTracker.overdrawMetrics().recordMetrics(this); }
void CCLayerTreeHost::setPrioritiesForLayers(const LayerList& updateList) { // Use BackToFront since it's cheap and this isn't order-dependent. typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> CCLayerIteratorType; CCPriorityCalculator calculator; CCLayerIteratorType end = CCLayerIteratorType::end(&updateList); for (CCLayerIteratorType it = CCLayerIteratorType::begin(&updateList); it != end; ++it) { if (it.representsItself()) it->setTexturePriorities(calculator); else if (it.representsTargetRenderSurface()) { if (it->maskLayer()) it->maskLayer()->setTexturePriorities(calculator); if (it->replicaLayer() && it->replicaLayer()->maskLayer()) it->replicaLayer()->maskLayer()->setTexturePriorities(calculator); } } }
void CCLayerTreeHost::prioritizeTextures(const LayerList& updateList) { // Use BackToFront since it's cheap and this isn't order-dependent. typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> CCLayerIteratorType; m_contentsTextureManager->clearPriorities(); CCPriorityCalculator calculator; CCLayerIteratorType end = CCLayerIteratorType::end(&updateList); for (CCLayerIteratorType it = CCLayerIteratorType::begin(&updateList); it != end; ++it) { if (it.representsItself()) it->setTexturePriorities(calculator); else if (it.representsTargetRenderSurface()) { if (it->maskLayer()) it->maskLayer()->setTexturePriorities(calculator); if (it->replicaLayer() && it->replicaLayer()->maskLayer()) it->replicaLayer()->maskLayer()->setTexturePriorities(calculator); } } size_t readbackBytes = 0; size_t maxBackgroundTextureBytes = 0; size_t contentsTextureBytes = 0; // Start iteration at 1 to skip the root surface as it does not have a texture cost. for (size_t i = 1; i < updateList.size(); ++i) { LayerChromium* renderSurfaceLayer = updateList[i].get(); RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface(); size_t bytes = TextureManager::memoryUseBytes(renderSurface->contentRect().size(), GraphicsContext3D::RGBA); contentsTextureBytes += bytes; if (renderSurface->backgroundFilters().isEmpty()) continue; if (bytes > maxBackgroundTextureBytes) maxBackgroundTextureBytes = bytes; if (!readbackBytes) readbackBytes = TextureManager::memoryUseBytes(m_deviceViewportSize, GraphicsContext3D::RGBA); } size_t renderSurfacesBytes = readbackBytes + maxBackgroundTextureBytes + contentsTextureBytes; m_contentsTextureManager->prioritizeTextures(renderSurfacesBytes); }