Esempio n. 1
0
void RenderSVGImage::paint(PaintInfo& paintInfo, const LayoutPoint&)
{
    if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || !m_imageResource->hasImage())
        return;

    FloatRect boundingBox = repaintRectInLocalCoordinates();
    if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTransform, paintInfo))
        return;

    PaintInfo childPaintInfo(paintInfo);
    bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == PaintPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline);
    if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) {
        GraphicsContextStateSaver stateSaver(*childPaintInfo.context);
        childPaintInfo.applyTransform(m_localTransform);

        if (childPaintInfo.phase == PaintPhaseForeground) {
            SVGRenderingContext renderingContext(this, childPaintInfo);

            if (renderingContext.isRenderingPrepared()) {
                RefPtr<Image> image = m_imageResource->image();
                FloatRect destRect = m_objectBoundingBox;
                FloatRect srcRect(0, 0, image->width(), image->height());

                SVGImageElement* imageElement = static_cast<SVGImageElement*>(node());
                imageElement->preserveAspectRatio().transformRect(destRect, srcRect);

                childPaintInfo.context->drawImage(image.get(), ColorSpaceDeviceRGB, destRect, srcRect);
            }
        }

        if (drawsOutline)
            paintOutline(childPaintInfo.context, IntRect(boundingBox));
    }
}
Esempio n. 2
0
void SVGRootInlineBox::paint(PaintInfo& paintInfo, const LayoutPoint&, LayoutUnit, LayoutUnit)
{
    ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
    ASSERT(!paintInfo.context->paintingDisabled());

    bool isPrinting = renderSVGText().document().printing();
    bool hasSelection = !isPrinting && selectionState() != RenderObject::SelectionNone;

    PaintInfo childPaintInfo(paintInfo);
    if (hasSelection) {
        for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
            if (child->isSVGInlineTextBox())
                toSVGInlineTextBox(child)->paintSelectionBackground(childPaintInfo);
            else if (child->isSVGInlineFlowBox())
                toSVGInlineFlowBox(child)->paintSelectionBackground(childPaintInfo);
        }
    }

    SVGRenderingContext renderingContext(renderSVGText(), paintInfo, SVGRenderingContext::SaveGraphicsContext);
    if (renderingContext.isRenderingPrepared()) {
        for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
            if (child->isSVGInlineTextBox())
                SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer(&toSVGInlineTextBox(child)->renderer());

            child->paint(paintInfo, LayoutPoint(), 0, 0);
        }
    }
}
Esempio n. 3
0
void SVGImagePainter::paint(PaintInfo& paintInfo)
{
    ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderSVGImage);

    if (paintInfo.phase != PaintPhaseForeground
        || m_renderSVGImage.style()->visibility() == HIDDEN
        || !m_renderSVGImage.imageResource()->hasImage())
        return;

    FloatRect boundingBox = m_renderSVGImage.paintInvalidationRectInLocalCoordinates();
    if (!SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(boundingBox, m_renderSVGImage.localToParentTransform(), paintInfo))
        return;

    PaintInfo childPaintInfo(paintInfo);
    GraphicsContextStateSaver stateSaver(*childPaintInfo.context, false);

    childPaintInfo.applyTransform(m_renderSVGImage.localToParentTransform(), &stateSaver);

    if (!m_renderSVGImage.objectBoundingBox().isEmpty()) {
        // SVGRenderingContext may taint the state - make sure we're always saving.
        stateSaver.saveIfNeeded();

        SVGRenderingContext renderingContext(&m_renderSVGImage, childPaintInfo);
        if (renderingContext.isRenderingPrepared()) {
            if (m_renderSVGImage.style()->svgStyle().bufferedRendering() == BR_STATIC && renderingContext.bufferForeground(m_renderSVGImage.bufferedForeground()))
                return;

            paintForeground(m_renderSVGImage, childPaintInfo);
        }
    }

    if (m_renderSVGImage.style()->outlineWidth())
        ObjectPainter(m_renderSVGImage).paintOutline(childPaintInfo, IntRect(boundingBox));
}
void RenderSVGImage::paint(PaintInfo& paintInfo, const LayoutPoint&)
{
    if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || !m_imageResource->hasImage())
        return;

    FloatRect boundingBox = repaintRectInLocalCoordinates();
    if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTransform, paintInfo))
        return;

    PaintInfo childPaintInfo(paintInfo);
    bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == PaintPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline);
    if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) {
        GraphicsContextStateSaver stateSaver(*childPaintInfo.context);
        childPaintInfo.applyTransform(m_localTransform);

        if (childPaintInfo.phase == PaintPhaseForeground) {
            SVGRenderingContext renderingContext(this, childPaintInfo);

            if (renderingContext.isRenderingPrepared()) {
                if (style()->svgStyle()->bufferedRendering() == BR_STATIC  && renderingContext.bufferForeground(m_bufferedForeground))
                    return;

                paintForeground(childPaintInfo);
            }
        }

        if (drawsOutline)
            paintOutline(childPaintInfo, IntRect(boundingBox));
    }
}
Esempio n. 5
0
void RenderSVGShape::paint(PaintInfo& paintInfo, const LayoutPoint&)
{
    if (paintInfo.context().paintingDisabled() || paintInfo.phase != PaintPhaseForeground
        || style().visibility() == HIDDEN || isEmpty())
        return;
    FloatRect boundingBox = repaintRectInLocalCoordinates();
    if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTransform, paintInfo))
        return;

    PaintInfo childPaintInfo(paintInfo);
    GraphicsContextStateSaver stateSaver(childPaintInfo.context());
    childPaintInfo.applyTransform(m_localTransform);

    if (childPaintInfo.phase == PaintPhaseForeground) {
        SVGRenderingContext renderingContext(*this, childPaintInfo);

        if (renderingContext.isRenderingPrepared()) {
            const SVGRenderStyle& svgStyle = style().svgStyle();
            if (svgStyle.shapeRendering() == SR_CRISPEDGES)
                childPaintInfo.context().setShouldAntialias(false);

            fillStrokeMarkers(childPaintInfo);
        }
    }

    if (style().outlineWidth())
        paintOutline(childPaintInfo, IntRect(boundingBox));
}
Esempio n. 6
0
void SVGInlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit, LayoutUnit)
{
    ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);

    GraphicsContextStateSaver stateSaver(*paintInfo.context);
    SVGRenderingContext renderingContext(&renderer(), paintInfo);
    if (renderingContext.isRenderingPrepared()) {
        for (InlineBox* child = firstChild(); child; child = child->nextOnLine())
            child->paint(paintInfo, paintOffset, 0, 0);
    }
}
Esempio n. 7
0
void Text::updateTextRenderer(unsigned offsetOfReplacedData, unsigned lengthOfReplacedData)
{
    if (!attached())
        return;
    RenderText* textRenderer = toRenderText(renderer());
    if (!textRenderer) {
        reattach();
        return;
    }
    NodeRenderingContext renderingContext(this, textRenderer->style());
    if (!textRendererIsNeeded(renderingContext)) {
        reattach();
        return;
    }
    textRenderer->setTextWithOffset(dataImpl(), offsetOfReplacedData, lengthOfReplacedData);
}
	bool RenderingThread::Init(GLFWwindow* window)
	{
		m_shouldExit = false;
		m_windowHandle = window;

		m_thread = std::thread([this]
		{
			// Take context
			glfwMakeContextCurrent(m_windowHandle);

			{
				std::unique_ptr<Graphics::Context> renderingContext(new Graphics::Context);
				renderingContext->Init();

				printf("---RENDERING_THREAD---\n");
				printf("OpenGL %s\n", glGetString(GL_VERSION));
				printf("GLSL %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
				printf("----------------------\n");

				m_threadIsReady.notify();

				while (!m_shouldExit)
				{
					m_threadStart.wait();

					if (m_shouldExit)
						break;

					if (m_commandBuffer)
					{
						renderingContext->ExecuteCommandBuffer(m_commandBuffer);
						glfwSwapBuffers(m_windowHandle);
						m_commandBuffer = nullptr;
					}

					m_threadIsReady.notify();
				}
			}

			// Release context when exiting
			glfwMakeContextCurrent(NULL);
		});

		return true;
	}
Esempio n. 9
0
void SVGInlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint&, LayoutUnit, LayoutUnit)
{
    ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
    ASSERT(!paintInfo.context->paintingDisabled());

    RenderObject* boxRenderer = renderer();
    ASSERT(boxRenderer);

    SVGRenderingContext renderingContext(boxRenderer, paintInfo, SVGRenderingContext::SaveGraphicsContext);
    if (renderingContext.isRenderingPrepared()) {
        for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
            if (child->isSVGInlineTextBox())
                computeTextMatchMarkerRectForRenderer(toRenderSVGInlineText(static_cast<SVGInlineTextBox*>(child)->textRenderer()));

            child->paint(paintInfo, LayoutPoint(), 0, 0);
        }
    }
}
void RemoteWindowDataSoftware::prepareSceneTransition(CardWebApp* cardWebApp)
{
	if (m_transitionIpcBuffer) {
		// in case prepare gets called twice in a row
		delete m_transitionIpcBuffer;
	}

	m_transitionIpcBuffer = PIpcBuffer::create(m_width * m_height * sizeof(uint32_t));
	memset((uint32_t*) m_transitionIpcBuffer->data(), 0xFF, m_width * m_height * sizeof(uint32_t));

	PGSurface* surf = NativeGraphicsSurface::wrap(m_width,
												  m_height,
												  (unsigned char*) m_transitionIpcBuffer->data(),
												  false);
	PGContext* gc = renderingContext();
	int tx = 0;
	int ty = 0;
	int tw = m_width;
	int th = m_height;

	// Make sure to update the window surface
	lock();
	cardWebApp->paint(gc, m_surface, tx, ty, tw, th, tx, ty, tw, th);
	unlock();

	gc->setSurface(surf);
	cardWebApp->paint(gc, surf, tx, ty, tw, th, tx, ty, tw, th);

	gc->setSurface(m_surface);
	surf->releaseRef();

	WindowMetaData* metaData = (WindowMetaData*) m_metaDataBuffer->data();
	m_metaDataBuffer->lock();
	metaData->transitionBufferKey = m_transitionIpcBuffer->key();
	m_metaDataBuffer->unlock();

	m_channel->sendAsyncMessage(new ViewHost_SceneTransitionPrepare(key(), m_width, m_height));
}
Esempio n. 11
0
void SVGImagePainter::paint(const PaintInfo& paintInfo)
{
    ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderSVGImage);

    if (paintInfo.phase != PaintPhaseForeground
        || m_renderSVGImage.style()->visibility() == HIDDEN
        || !m_renderSVGImage.imageResource()->hasImage())
        return;

    FloatRect boundingBox = m_renderSVGImage.paintInvalidationRectInLocalCoordinates();

    PaintInfo childPaintInfo(paintInfo);
    GraphicsContextStateSaver stateSaver(*childPaintInfo.context);
    TransformRecorder transformRecorder(*childPaintInfo.context, m_renderSVGImage.displayItemClient(), m_renderSVGImage.localToParentTransform());
    SVGRenderingContext renderingContext(&m_renderSVGImage, childPaintInfo);
    if (renderingContext.isRenderingPrepared()) {
        RenderDrawingRecorder recorder(childPaintInfo.context, m_renderSVGImage, childPaintInfo.phase, boundingBox);
        if (!recorder.canUseCachedDrawing()) {
            if (m_renderSVGImage.style()->svgStyle().bufferedRendering() != BR_STATIC) {
                paintForeground(childPaintInfo);
            } else {
                RefPtr<const SkPicture>& bufferedForeground = m_renderSVGImage.bufferedForeground();
                if (!bufferedForeground) {
                    childPaintInfo.context->beginRecording(m_renderSVGImage.objectBoundingBox());
                    paintForeground(childPaintInfo);
                    bufferedForeground = childPaintInfo.context->endRecording();
                }

                childPaintInfo.context->drawPicture(bufferedForeground.get());
            }
        }
    }

    if (m_renderSVGImage.style()->outlineWidth())
        ObjectPainter(m_renderSVGImage).paintOutline(childPaintInfo, IntRect(boundingBox));
}
Esempio n. 12
0
void RenderSVGImage::paint(PaintInfo& paintInfo, const LayoutPoint&)
{
    ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this);

    if (paintInfo.phase != PaintPhaseForeground
        || style()->visibility() == HIDDEN
        || !m_imageResource->hasImage())
        return;

    FloatRect boundingBox = paintInvalidationRectInLocalCoordinates();
    if (!SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(boundingBox, m_localTransform, paintInfo))
        return;

    PaintInfo childPaintInfo(paintInfo);
    GraphicsContextStateSaver stateSaver(*childPaintInfo.context, false);

    if (!m_localTransform.isIdentity()) {
        stateSaver.save();
        childPaintInfo.applyTransform(m_localTransform, false);
    }
    if (!m_objectBoundingBox.isEmpty()) {
        // SVGRenderingContext may taint the state - make sure we're always saving.
        SVGRenderingContext renderingContext(this, childPaintInfo, stateSaver.saved() ?
            SVGRenderingContext::DontSaveGraphicsContext : SVGRenderingContext::SaveGraphicsContext);

        if (renderingContext.isRenderingPrepared()) {
            if (style()->svgStyle().bufferedRendering() == BR_STATIC && renderingContext.bufferForeground(m_bufferedForeground))
                return;

            paintForeground(childPaintInfo);
        }
    }

    if (style()->outlineWidth())
        paintOutline(childPaintInfo, IntRect(boundingBox));
}
Esempio n. 13
0
void SVGRootInlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit, LayoutUnit)
{
    ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
    ASSERT(!paintInfo.context().paintingDisabled());

    bool isPrinting = renderSVGText().document().printing();
    bool hasSelection = !isPrinting && selectionState() != RenderObject::SelectionNone;

    PaintInfo childPaintInfo(paintInfo);
    if (hasSelection) {
        for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
            if (is<SVGInlineTextBox>(*child))
                downcast<SVGInlineTextBox>(*child).paintSelectionBackground(childPaintInfo);
            else if (is<SVGInlineFlowBox>(*child))
                downcast<SVGInlineFlowBox>(*child).paintSelectionBackground(childPaintInfo);
        }
    }

    SVGRenderingContext renderingContext(renderSVGText(), paintInfo, SVGRenderingContext::SaveGraphicsContext);
    if (renderingContext.isRenderingPrepared()) {
        for (InlineBox* child = firstChild(); child; child = child->nextOnLine())
            child->paint(paintInfo, paintOffset, 0, 0);
    }
}