void CCRenderPass::appendQuadsForRenderSurfaceLayer(CCLayerImpl* layer) { // FIXME: render surface layers should be a CCLayerImpl-derived class and // not be handled specially here. CCRenderSurface* surface = layer->renderSurface(); bool isOpaque = false; OwnPtr<CCSharedQuadState> sharedQuadState = CCSharedQuadState::create(surface->drawTransform(), surface->drawTransform(), surface->contentRect(), surface->clipRect(), surface->drawOpacity(), isOpaque); m_quadList.append(CCRenderSurfaceDrawQuad::create(sharedQuadState.get(), surface->contentRect(), layer, surfaceDamageRect())); m_sharedQuadStateList.append(sharedQuadState.release()); }
void LayerRendererChromium::drawLayersInternal() { if (viewportSize().isEmpty() || !rootLayer()) return; TRACE_EVENT("LayerRendererChromium::drawLayers", this, 0); CCLayerImpl* rootDrawLayer = rootLayer(); makeContextCurrent(); if (!rootDrawLayer->renderSurface()) rootDrawLayer->createRenderSurface(); rootDrawLayer->renderSurface()->setContentRect(IntRect(IntPoint(), viewportSize())); rootDrawLayer->setScissorRect(IntRect(IntPoint(), viewportSize())); CCLayerList renderSurfaceLayerList; renderSurfaceLayerList.append(rootDrawLayer); m_defaultRenderSurface = rootDrawLayer->renderSurface(); m_defaultRenderSurface->clearLayerList(); { TRACE_EVENT("LayerRendererChromium::drawLayersInternal::calcDrawEtc", this, 0); CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootDrawLayer, rootDrawLayer, m_zoomAnimatorTransform, m_zoomAnimatorTransform, renderSurfaceLayerList, m_defaultRenderSurface->layerList(), &m_layerSorter, m_capabilities.maxTextureSize); } // The GL viewport covers the entire visible area, including the scrollbars. GLC(m_context.get(), m_context->viewport(0, 0, viewportWidth(), viewportHeight())); m_windowMatrix = screenMatrix(0, 0, viewportWidth(), viewportHeight()); // Bind the common vertex attributes used for drawing all the layers. m_sharedGeometry->prepareForDraw(); GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST)); GLC(m_context.get(), m_context->disable(GraphicsContext3D::DEPTH_TEST)); GLC(m_context.get(), m_context->disable(GraphicsContext3D::CULL_FACE)); useRenderSurface(m_defaultRenderSurface); if (m_zoomAnimatorTransform.isIdentity()) // Clear to blue to make it easier to spot unrendered regions. m_context->clearColor(0, 0, 1, 1); else // Clear to grey, as zoom animation may leave unrendered regions. // FIXME(wjmaclean): Render some interesting texture in unrendered regions. m_context->clearColor(0.25, 0.25, 0.25, 1); m_context->colorMask(true, true, true, true); m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT); GLC(m_context.get(), m_context->enable(GraphicsContext3D::BLEND)); GLC(m_context.get(), m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA)); GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST)); // Update the contents of the render surfaces. We traverse the array from // back to front to guarantee that nested render surfaces get rendered in the // correct order. for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) { CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get(); CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface(); ASSERT(renderSurface); renderSurface->setSkipsDraw(true); // Render surfaces whose drawable area has zero width or height // will have no layers associated with them and should be skipped. if (!renderSurface->layerList().size()) continue; // Skip completely transparent render surfaces. if (!renderSurface->drawOpacity()) continue; if (useRenderSurface(renderSurface)) { renderSurface->setSkipsDraw(false); if (renderSurfaceLayer != rootDrawLayer) { GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST)); GLC(m_context.get(), m_context->clearColor(0, 0, 0, 0)); GLC(m_context.get(), m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT)); GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST)); } const CCLayerList& layerList = renderSurface->layerList(); for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) drawLayer(layerList[layerIndex].get(), renderSurface); } } if (m_headsUpDisplay->enabled()) { GLC(m_context.get(), m_context->enable(GraphicsContext3D::BLEND)); GLC(m_context.get(), m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA)); GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST)); useRenderSurface(m_defaultRenderSurface); m_headsUpDisplay->draw(); } GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST)); GLC(m_context.get(), m_context->disable(GraphicsContext3D::BLEND)); }