void CCLayerTreeHostImpl::calculateRenderPasses(CCRenderPassList& passes, CCLayerList& renderSurfaceLayerList) { renderSurfaceLayerList.append(rootLayer()); if (!rootLayer()->renderSurface()) rootLayer()->createRenderSurface(); rootLayer()->renderSurface()->clearLayerList(); rootLayer()->renderSurface()->setContentRect(IntRect(IntPoint(), viewportSize())); rootLayer()->setClipRect(IntRect(IntPoint(), viewportSize())); { TransformationMatrix identityMatrix; TRACE_EVENT("CCLayerTreeHostImpl::calcDrawEtc", this, 0); CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer(), rootLayer(), identityMatrix, identityMatrix, renderSurfaceLayerList, rootLayer()->renderSurface()->layerList(), &m_layerSorter, layerRendererCapabilities().maxTextureSize); } if (layerRendererCapabilities().usingPartialSwap) trackDamageForAllSurfaces(rootLayer(), renderSurfaceLayerList); m_rootDamageRect = rootLayer()->renderSurface()->damageTracker()->currentDamageRect(); for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) { CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex]; CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface(); OwnPtr<CCRenderPass> pass = CCRenderPass::create(renderSurface); FloatRect surfaceDamageRect; if (layerRendererCapabilities().usingPartialSwap) surfaceDamageRect = damageInSurfaceSpace(renderSurfaceLayer, m_rootDamageRect); pass->setSurfaceDamageRect(surfaceDamageRect); const CCLayerList& layerList = renderSurface->layerList(); for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { CCLayerImpl* layer = layerList[layerIndex]; if (layer->visibleLayerRect().isEmpty()) continue; if (CCLayerTreeHostCommon::renderSurfaceContributesToTarget(layer, renderSurfaceLayer->id())) { pass->appendQuadsForRenderSurfaceLayer(layer); continue; } layer->willDraw(m_layerRenderer.get()); pass->appendQuadsForLayer(layer); } passes.append(pass.release()); } }
void CCLayerTreeHostImpl::optimizeRenderPasses(CCRenderPassList& passes) { TRACE_EVENT1("webkit", "CCLayerTreeHostImpl::optimizeRenderPasses", "passes.size()", static_cast<long long unsigned>(passes.size())); bool haveDamageRect = layerRendererCapabilities().usingPartialSwap; // FIXME: compute overdraw metrics only occasionally, not every frame. CCOverdrawCounts overdrawCounts; for (unsigned i = 0; i < passes.size(); ++i) { FloatRect damageRect = passes[i]->targetSurface()->damageTracker()->currentDamageRect(); passes[i]->optimizeQuads(haveDamageRect, damageRect, &overdrawCounts); } float normalization = 1000.f / (m_layerRenderer->viewportWidth() * m_layerRenderer->viewportHeight()); PlatformSupport::histogramCustomCounts("Renderer4.pixelOverdrawOpaque", static_cast<int>(normalization * overdrawCounts.m_pixelsDrawnOpaque), 100, 1000000, 50); PlatformSupport::histogramCustomCounts("Renderer4.pixelOverdrawTransparent", static_cast<int>(normalization * overdrawCounts.m_pixelsDrawnTransparent), 100, 1000000, 50); PlatformSupport::histogramCustomCounts("Renderer4.pixelOverdrawCulled", static_cast<int>(normalization * overdrawCounts.m_pixelsCulled), 100, 1000000, 50); }
void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdater& updater) { TRACE_EVENT("CCLayerTreeHost::updateLayers", this, 0); if (!rootLayer->renderSurface()) rootLayer->createRenderSurface(); rootLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), viewportSize())); IntRect rootClipRect(IntPoint(), viewportSize()); rootLayer->setClipRect(rootClipRect); LayerList updateList; updateList.append(rootLayer); RenderSurfaceChromium* rootRenderSurface = rootLayer->renderSurface(); rootRenderSurface->clearLayerList(); TransformationMatrix identityMatrix; { TRACE_EVENT("CCLayerTreeHost::updateLayers::calcDrawEtc", this, 0); CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer, rootLayer, identityMatrix, identityMatrix, updateList, rootRenderSurface->layerList(), layerRendererCapabilities().maxTextureSize); } // Reset partial texture update requests. m_partialTextureUpdateRequests = 0; reserveTextures(updateList); paintLayerContents(updateList, PaintVisible, updater); if (!m_triggerIdlePaints) return; size_t preferredLimitBytes = m_contentsTextureManager->preferredMemoryLimitBytes(); size_t maxLimitBytes = m_contentsTextureManager->maxMemoryLimitBytes(); m_contentsTextureManager->reduceMemoryToLimit(preferredLimitBytes); if (m_contentsTextureManager->currentMemoryUseBytes() >= preferredLimitBytes) return; // Idle painting should fail when we hit the preferred memory limit, // otherwise it will always push us towards the maximum limit. m_contentsTextureManager->setMaxMemoryLimitBytes(preferredLimitBytes); // The second (idle) paint will be a no-op in layers where painting already occured above. paintLayerContents(updateList, PaintIdle, updater); m_contentsTextureManager->setMaxMemoryLimitBytes(maxLimitBytes); for (size_t i = 0; i < updateList.size(); ++i) updateList[i]->clearRenderSurface(); }
void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdater& updater) { TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers"); if (!rootLayer->renderSurface()) rootLayer->createRenderSurface(); rootLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), deviceViewportSize())); IntRect rootClipRect(IntPoint(), deviceViewportSize()); rootLayer->setClipRect(rootClipRect); LayerList updateList; updateList.append(rootLayer); RenderSurfaceChromium* rootRenderSurface = rootLayer->renderSurface(); rootRenderSurface->clearLayerList(); { TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers::calcDrawEtc"); WebTransformationMatrix identityMatrix; WebTransformationMatrix deviceScaleTransform; deviceScaleTransform.scale(m_deviceScaleFactor); CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, rootLayer, deviceScaleTransform, identityMatrix, updateList, rootRenderSurface->layerList(), layerRendererCapabilities().maxTextureSize); FloatRect rootScissorRect(FloatPoint(0, 0), viewportSize()); CCLayerTreeHostCommon::calculateVisibleAndScissorRects(updateList, rootScissorRect); } // Reset partial texture update requests. m_partialTextureUpdateRequests = 0; prioritizeTextures(updateList); bool needMoreUpdates = paintLayerContents(updateList, updater); if (m_triggerIdleUpdates && needMoreUpdates) setNeedsCommit(); for (size_t i = 0; i < updateList.size(); ++i) updateList[i]->clearRenderSurface(); }