void CoordinatedGraphicsScene::paintToGraphicsContext(PlatformGraphicsContext* platformContext, const Color& backgroundColor, bool drawsBackground) { if (!m_textureMapper) m_textureMapper = TextureMapper::create(); ASSERT(m_textureMapper->accelerationMode() == TextureMapper::SoftwareMode); syncRemoteContent(); TextureMapperLayer* layer = rootLayer(); if (!layer) return; GraphicsContext graphicsContext(platformContext); m_textureMapper->setGraphicsContext(&graphicsContext); m_textureMapper->beginPainting(); IntRect clipRect = graphicsContext.clipBounds(); if (drawsBackground) m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), backgroundColor); else m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), m_viewBackgroundColor); layer->paint(); m_fpsCounter.updateFPSAndDisplay(m_textureMapper.get(), clipRect.location()); m_textureMapper->endPainting(); m_textureMapper->setGraphicsContext(0); }
void LayerTreeRenderer::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, TextureMapper::PaintFlags PaintFlags) { if (!m_textureMapper) m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode); ASSERT(m_textureMapper->accelerationMode() == TextureMapper::OpenGLMode); adjustPositionForFixedLayers(); GraphicsLayer* currentRootLayer = rootLayer(); if (!currentRootLayer) return; TextureMapperLayer* layer = toTextureMapperLayer(currentRootLayer); if (!layer) return; layer->setTextureMapper(m_textureMapper.get()); m_textureMapper->beginPainting(PaintFlags); m_textureMapper->beginClip(TransformationMatrix(), clipRect); if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) { currentRootLayer->setOpacity(opacity); currentRootLayer->setTransform(matrix); currentRootLayer->syncCompositingStateForThisLayerOnly(); } layer->paint(); m_textureMapper->endClip(); m_textureMapper->endPainting(); }
void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, TextureMapper::PaintFlags PaintFlags) { if (!m_textureMapper) { m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode); static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true); } ASSERT(m_textureMapper->accelerationMode() == TextureMapper::OpenGLMode); syncRemoteContent(); adjustPositionForFixedLayers(); GraphicsLayer* currentRootLayer = rootLayer(); if (!currentRootLayer) return; TextureMapperLayer* layer = toTextureMapperLayer(currentRootLayer); if (!layer) return; layer->setTextureMapper(m_textureMapper.get()); if (!m_animationsLocked) layer->applyAnimationsRecursively(); m_textureMapper->beginPainting(PaintFlags); m_textureMapper->beginClip(TransformationMatrix(), clipRect); if (m_setDrawsBackground) { RGBA32 rgba = makeRGBA32FromFloats(m_backgroundColor.red(), m_backgroundColor.green(), m_backgroundColor.blue(), m_backgroundColor.alpha() * opacity); m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), Color(rgba)); } if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) { currentRootLayer->setOpacity(opacity); currentRootLayer->setTransform(matrix); currentRootLayer->flushCompositingStateForThisLayerOnly(); } layer->paint(); m_fpsCounter.updateFPSAndDisplay(m_textureMapper.get(), clipRect.location(), matrix); m_textureMapper->endClip(); m_textureMapper->endPainting(); if (layer->descendantsOrSelfHaveRunningAnimations()) dispatchOnMainThread(bind(&CoordinatedGraphicsScene::updateViewport, this)); #if ENABLE(REQUEST_ANIMATION_FRAME) if (m_animationFrameRequested) { m_animationFrameRequested = false; dispatchOnMainThread(bind(&CoordinatedGraphicsScene::animationFrameReady, this)); } #endif }
void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, const Color& backgroundColor, bool drawsBackground, const FloatPoint& contentPosition, TextureMapper::PaintFlags PaintFlags) { if (!m_textureMapper) { m_textureMapper = TextureMapper::create(); static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true); } syncRemoteContent(); adjustPositionForFixedLayers(contentPosition); TextureMapperLayer* currentRootLayer = rootLayer(); if (!currentRootLayer) return; #if USE(COORDINATED_GRAPHICS_THREADED) for (auto& proxy : m_platformLayerProxies.values()) proxy->swapBuffer(); #endif currentRootLayer->setTextureMapper(m_textureMapper.get()); currentRootLayer->applyAnimationsRecursively(); m_textureMapper->beginPainting(PaintFlags); m_textureMapper->beginClip(TransformationMatrix(), clipRect); if (drawsBackground) { RGBA32 rgba = makeRGBA32FromFloats(backgroundColor.red(), backgroundColor.green(), backgroundColor.blue(), backgroundColor.alpha() * opacity); m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), Color(rgba)); } else { GraphicsContext3D* context = static_cast<TextureMapperGL*>(m_textureMapper.get())->graphicsContext3D(); context->clearColor(m_viewBackgroundColor.red() / 255.0f, m_viewBackgroundColor.green() / 255.0f, m_viewBackgroundColor.blue() / 255.0f, m_viewBackgroundColor.alpha() / 255.0f); context->clear(GraphicsContext3D::COLOR_BUFFER_BIT); } if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) { currentRootLayer->setOpacity(opacity); currentRootLayer->setTransform(matrix); } currentRootLayer->paint(); m_fpsCounter.updateFPSAndDisplay(*m_textureMapper, clipRect.location(), matrix); m_textureMapper->endClip(); m_textureMapper->endPainting(); if (currentRootLayer->descendantsOrSelfHaveRunningAnimations()) { RefPtr<CoordinatedGraphicsScene> protector(this); dispatchOnClientRunLoop([=] { protector->updateViewport(); }); } }
void LayerTreeRenderer::paintToGraphicsContext(BackingStore::PlatformGraphicsContext painter) { if (!m_textureMapper) m_textureMapper = TextureMapper::create(); ASSERT(m_textureMapper->accelerationMode() == TextureMapper::SoftwareMode); syncRemoteContent(); TextureMapperLayer* layer = toTextureMapperLayer(rootLayer()); if (!layer) return; GraphicsContext graphicsContext(painter); m_textureMapper->setGraphicsContext(&graphicsContext); m_textureMapper->beginPainting(); layer->paint(); m_textureMapper->endPainting(); m_textureMapper->setGraphicsContext(0); }
void LayerTreeHostProxy::paintToGraphicsContext(QPainter* painter) { if (!m_textureMapper) m_textureMapper = TextureMapper::create(); ASSERT(m_textureMapper->accelerationMode() == TextureMapper::SoftwareMode); syncRemoteContent(); TextureMapperLayer* layer = toTextureMapperLayer(rootLayer()); if (!layer) return; GraphicsContext graphicsContext(painter); m_textureMapper->setGraphicsContext(&graphicsContext); m_textureMapper->beginPainting(); m_textureMapper->bindSurface(0); layer->paint(); m_textureMapper->endPainting(); m_textureMapper->setGraphicsContext(0); }
void LayerTreeRenderer::paintToGraphicsContext(BackingStore::PlatformGraphicsContext painter) { if (!m_textureMapper) m_textureMapper = TextureMapper::create(); ASSERT(m_textureMapper->accelerationMode() == TextureMapper::SoftwareMode); syncRemoteContent(); TextureMapperLayer* layer = toTextureMapperLayer(rootLayer()); if (!layer) return; GraphicsContext graphicsContext(painter); m_textureMapper->setGraphicsContext(&graphicsContext); m_textureMapper->beginPainting(); if (m_setDrawsBackground) m_textureMapper->drawSolidColor(graphicsContext.clipBounds(), TransformationMatrix(), m_backgroundColor); layer->paint(); m_textureMapper->endPainting(); m_textureMapper->setGraphicsContext(0); }
void WebLayerTreeRenderer::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, TextureMapper::PaintFlags PaintFlags) { if (!m_textureMapper) m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode); ASSERT(m_textureMapper->accelerationMode() == TextureMapper::OpenGLMode); // We need to compensate for the rounding error that happens due to m_visibleContentsRect being // int and not float. We do that by moving the TransformationMatrix by the delta between the // position of m_visibleContentsRect and the position it would have if it wasn't rounded. TransformationMatrix newMatrix = matrix; newMatrix.translate(m_accurateVisibleContentsPosition.x() / m_contentsScale - m_visibleContentsRect.x(), m_accurateVisibleContentsPosition.y() / m_contentsScale - m_visibleContentsRect.y()); adjustPositionForFixedLayers(); GraphicsLayer* currentRootLayer = rootLayer(); if (!currentRootLayer) return; TextureMapperLayer* layer = toTextureMapperLayer(currentRootLayer); if (!layer) return; layer->setTextureMapper(m_textureMapper.get()); m_textureMapper->beginPainting(PaintFlags); m_textureMapper->beginClip(TransformationMatrix(), clipRect); if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != newMatrix) { currentRootLayer->setOpacity(opacity); currentRootLayer->setTransform(newMatrix); currentRootLayer->syncCompositingStateForThisLayerOnly(); } layer->paint(); m_textureMapper->endClip(); m_textureMapper->endPainting(); }