AffineTransform RenderSVGResourceMarker::viewportTransform() const
{
    SVGMarkerElement* marker = toSVGMarkerElement(element());
    ASSERT(marker);

    return marker->viewBoxToViewTransform(m_viewport.width(), m_viewport.height());
}
예제 #2
0
void SVGShapePainter::paintMarker(const PaintInfo& paintInfo, RenderSVGResourceMarker& marker, const MarkerPosition& position, float strokeWidth)
{
    // An empty viewBox disables rendering.
    SVGMarkerElement* markerElement = toSVGMarkerElement(marker.element());
    ASSERT(markerElement);
    if (markerElement->hasAttribute(SVGNames::viewBoxAttr) && markerElement->viewBox()->currentValue()->isValid() && markerElement->viewBox()->currentValue()->value().isEmpty())
        return;

    OwnPtr<DisplayItemList> displayItemList;
    if (RuntimeEnabledFeatures::slimmingPaintEnabled())
        displayItemList = DisplayItemList::create();
    GraphicsContext recordingContext(nullptr, displayItemList.get());
    recordingContext.beginRecording(m_renderSVGShape.paintInvalidationRectInLocalCoordinates());

    PaintInfo markerPaintInfo(paintInfo);
    markerPaintInfo.context = &recordingContext;
    {
        TransformRecorder transformRecorder(*markerPaintInfo.context, marker.displayItemClient(), marker.markerTransformation(position.origin, position.angle, strokeWidth));
        OwnPtr<FloatClipRecorder> clipRecorder;
        if (SVGRenderSupport::isOverflowHidden(&marker))
            clipRecorder = adoptPtr(new FloatClipRecorder(recordingContext, marker.displayItemClient(), markerPaintInfo.phase, marker.viewport()));

        SVGContainerPainter(marker).paint(markerPaintInfo);
    }

    if (displayItemList)
        displayItemList->replay(&recordingContext);
    RefPtr<const SkPicture> recording = recordingContext.endRecording();
    paintInfo.context->drawPicture(recording.get());
}
FloatPoint RenderSVGResourceMarker::referencePoint() const
{
    SVGMarkerElement* marker = toSVGMarkerElement(element());
    ASSERT(marker);

    SVGLengthContext lengthContext(marker);
    return FloatPoint(marker->refXCurrentValue().value(lengthContext), marker->refYCurrentValue().value(lengthContext));
}
예제 #4
0
FloatPoint LayoutSVGResourceMarker::referencePoint() const
{
    SVGMarkerElement* marker = toSVGMarkerElement(element());
    ASSERT(marker);

    SVGLengthContext lengthContext(marker);
    return FloatPoint(marker->refX()->currentValue()->value(lengthContext), marker->refY()->currentValue()->value(lengthContext));
}
예제 #5
0
bool LayoutSVGResourceMarker::shouldPaint() const {
  // An empty viewBox disables rendering.
  SVGMarkerElement* marker = toSVGMarkerElement(element());
  ASSERT(marker);
  return !marker->viewBox()->isSpecified() ||
         !marker->viewBox()->currentValue()->isValid() ||
         !marker->viewBox()->currentValue()->value().isEmpty();
}
float RenderSVGResourceMarker::angle() const
{
    SVGMarkerElement* marker = toSVGMarkerElement(element());
    ASSERT(marker);

    float angle = -1;
    if (marker->orientTypeCurrentValue() == SVGMarkerOrientAngle)
        angle = marker->orientAngleCurrentValue().value();

    return angle;
}
예제 #7
0
float LayoutSVGResourceMarker::angle() const
{
    SVGMarkerElement* marker = toSVGMarkerElement(element());
    ASSERT(marker);

    float angle = -1;
    if (marker->orientType()->currentValue()->enumValue() == SVGMarkerOrientAngle)
        angle = marker->orientAngle()->currentValue()->value();

    return angle;
}
예제 #8
0
void LayoutSVGResourceMarker::calcViewport() {
  if (!selfNeedsLayout())
    return;

  SVGMarkerElement* marker = toSVGMarkerElement(element());
  ASSERT(marker);

  SVGLengthContext lengthContext(marker);
  float w = marker->markerWidth()->currentValue()->value(lengthContext);
  float h = marker->markerHeight()->currentValue()->value(lengthContext);
  m_viewport = FloatRect(0, 0, w, h);
}
void RenderSVGResourceMarker::draw(PaintInfo& paintInfo, const AffineTransform& transform)
{
    // An empty viewBox disables rendering.
    SVGMarkerElement* marker = toSVGMarkerElement(element());
    ASSERT(marker);
    if (marker->hasAttribute(SVGNames::viewBoxAttr) && marker->viewBoxCurrentValue().isValid() && marker->viewBoxCurrentValue().isEmpty())
        return;

    PaintInfo info(paintInfo);
    GraphicsContextStateSaver stateSaver(*info.context);
    info.applyTransform(transform);
    RenderSVGContainer::paint(info, IntPoint());
}
void SVGShapePainter::paintMarker(const PaintInfo& paintInfo, LayoutSVGResourceMarker& marker, const MarkerPosition& position, float strokeWidth)
{
    // An empty viewBox disables rendering.
    SVGMarkerElement* markerElement = toSVGMarkerElement(marker.element());
    ASSERT(markerElement);
    if (markerElement->hasAttribute(SVGNames::viewBoxAttr) && markerElement->viewBox()->currentValue()->isValid() && markerElement->viewBox()->currentValue()->value().isEmpty())
        return;

    TransformRecorder transformRecorder(paintInfo.context, marker, marker.markerTransformation(position.origin, position.angle, strokeWidth));
    Optional<FloatClipRecorder> clipRecorder;
    if (SVGLayoutSupport::isOverflowHidden(&marker))
        clipRecorder.emplace(paintInfo.context, marker, paintInfo.phase, marker.viewport());
    SVGContainerPainter(marker).paint(paintInfo);
}
AffineTransform RenderSVGResourceMarker::markerTransformation(const FloatPoint& origin, float autoAngle, float strokeWidth) const
{
    SVGMarkerElement* marker = toSVGMarkerElement(element());
    ASSERT(marker);

    float markerAngle = angle();
    bool useStrokeWidth = marker->markerUnitsCurrentValue() == SVGMarkerUnitsStrokeWidth;

    AffineTransform transform;
    transform.translate(origin.x(), origin.y());
    transform.rotate(markerAngle == -1 ? autoAngle : markerAngle);
    transform = markerContentTransformation(transform, referencePoint(), useStrokeWidth ? strokeWidth : -1);
    return transform;
}
void RenderSVGResourceMarker::draw(PaintInfo& paintInfo, const AffineTransform& transform)
{
    clearInvalidationMask();

    // An empty viewBox disables rendering.
    SVGMarkerElement* marker = toSVGMarkerElement(element());
    ASSERT(marker);
    if (marker->hasAttribute(SVGNames::viewBoxAttr) && marker->viewBox()->currentValue()->isValid() && marker->viewBox()->currentValue()->value().isEmpty())
        return;

    PaintInfo info(paintInfo);
    GraphicsContextStateSaver stateSaver(*info.context, false);
    if (!transform.isIdentity()) {
        stateSaver.save();
        info.applyTransform(transform, false);
    }
    RenderSVGContainer::paint(info, IntPoint());
}
예제 #13
0
void SVGMarkerPainter::paint(PaintInfo& paintInfo, const MarkerPosition& position, float strokeWidth)
{
    // An empty viewBox disables rendering.
    SVGMarkerElement* marker = toSVGMarkerElement(m_renderSVGMarker.element());
    ASSERT(marker);
    if (marker->hasAttribute(SVGNames::viewBoxAttr) && marker->viewBox()->currentValue()->isValid() && marker->viewBox()->currentValue()->value().isEmpty())
        return;

    PaintInfo info(paintInfo);
    GraphicsContextStateSaver stateSaver(*info.context, false);
    info.applyTransform(m_renderSVGMarker.markerTransformation(position.origin, position.angle, strokeWidth), &stateSaver);

    if (SVGRenderSupport::isOverflowHidden(&m_renderSVGMarker)) {
        stateSaver.saveIfNeeded();
        info.context->clip(m_renderSVGMarker.viewport());
    }

    SVGContainerPainter(m_renderSVGMarker).paint(info);
}
예제 #14
0
SVGMarkerUnitsType LayoutSVGResourceMarker::markerUnits() const {
  return toSVGMarkerElement(element())
      ->markerUnits()
      ->currentValue()
      ->enumValue();
}
예제 #15
0
float LayoutSVGResourceMarker::angle() const {
  return toSVGMarkerElement(element())->orientAngle()->currentValue()->value();
}
예제 #16
0
SVGMarkerOrientType LayoutSVGResourceMarker::orientType() const {
  return toSVGMarkerElement(element())
      ->orientType()
      ->currentValue()
      ->enumValue();
}