Exemplo n.º 1
0
bool SVGLayoutSupport::updateGraphicsContext(const PaintInfo& paintInfo, GraphicsContextStateSaver& stateSaver, const ComputedStyle& style, LayoutObject& layoutObject, LayoutSVGResourceMode resourceMode, const AffineTransform* additionalPaintServerTransform)
{
    ASSERT(paintInfo.context == stateSaver.context());

    GraphicsContext& context = *paintInfo.context;
    if (paintInfo.isRenderingClipPathAsMaskImage()) {
        if (resourceMode == ApplyToStrokeMode)
            return false;
        context.setFillColor(SVGComputedStyle::initialFillPaintColor());
        return true;
    }

    SVGPaintServer paintServer = SVGPaintServer::requestForLayoutObject(layoutObject, style, resourceMode);
    if (!paintServer.isValid())
        return false;

    if (additionalPaintServerTransform && paintServer.isTransformDependent())
        paintServer.prependTransform(*additionalPaintServerTransform);

    const SVGComputedStyle& svgStyle = style.svgStyle();
    float paintAlpha = resourceMode == ApplyToFillMode ? svgStyle.fillOpacity() : svgStyle.strokeOpacity();
    paintServer.apply(context, resourceMode, paintAlpha, stateSaver);

    if (resourceMode == ApplyToFillMode)
        context.setFillRule(svgStyle.fillRule());
    else
        applyStrokeStyleToContext(context, style, layoutObject);

    return true;
}
Exemplo n.º 2
0
bool SVGRenderSupport::updateGraphicsContext(const PaintInfo& paintInfo, GraphicsContextStateSaver& stateSaver, RenderStyle* style, RenderObject& renderer, RenderSVGResourceMode resourceMode, const AffineTransform* additionalPaintServerTransform)
{
    ASSERT(style);
    ASSERT(paintInfo.context == stateSaver.context());

    GraphicsContext* context = paintInfo.context;
    if (paintInfo.isRenderingClipPathAsMaskImage()) {
        if (resourceMode == ApplyToStrokeMode)
            return false;
        context->setAlphaAsFloat(1);
        context->setFillColor(SVGRenderStyle::initialFillPaintColor());
        return true;
    }

    SVGPaintServer paintServer = SVGPaintServer::requestForRenderer(renderer, style, resourceMode);
    if (!paintServer.isValid())
        return false;

    if (additionalPaintServerTransform && paintServer.isTransformDependent())
        paintServer.prependTransform(*additionalPaintServerTransform);

    paintServer.apply(*context, resourceMode, &stateSaver);

    const SVGRenderStyle& svgStyle = style->svgStyle();

    if (resourceMode == ApplyToFillMode) {
        context->setAlphaAsFloat(svgStyle.fillOpacity());
        context->setFillRule(svgStyle.fillRule());
    } else {
        context->setAlphaAsFloat(svgStyle.strokeOpacity());
        applyStrokeStyleToContext(context, style, &renderer);
    }
    return true;
}
Exemplo n.º 3
0
bool SVGPaintContext::paintForLayoutObject(
    const PaintInfo& paintInfo,
    const ComputedStyle& style,
    const LayoutObject& layoutObject,
    LayoutSVGResourceMode resourceMode,
    SkPaint& paint,
    const AffineTransform* additionalPaintServerTransform) {
  if (paintInfo.isRenderingClipPathAsMaskImage()) {
    if (resourceMode == ApplyToStrokeMode)
      return false;
    paint.setColor(SVGComputedStyle::initialFillPaintColor().rgb());
    paint.setShader(nullptr);
    return true;
  }

  SVGPaintServer paintServer =
      SVGPaintServer::requestForLayoutObject(layoutObject, style, resourceMode);
  if (!paintServer.isValid())
    return false;

  if (additionalPaintServerTransform && paintServer.isTransformDependent())
    paintServer.prependTransform(*additionalPaintServerTransform);

  const SVGComputedStyle& svgStyle = style.svgStyle();
  float paintAlpha = resourceMode == ApplyToFillMode ? svgStyle.fillOpacity()
                                                     : svgStyle.strokeOpacity();
  paintServer.applyToSkPaint(paint, paintAlpha);

  // We always set filter quality to 'low' here. This value will only have an
  // effect for patterns, which are SkPictures, so using high-order filter
  // should have little effect on the overall quality.
  paint.setFilterQuality(kLow_SkFilterQuality);

  // TODO(fs): The color filter can set when generating a picture for a mask -
  // due to color-interpolation. We could also just apply the
  // color-interpolation property from the the shape itself (which could mean
  // the paintserver if it has it specified), since that would be more in line
  // with the spec for color-interpolation. For now, just steal it from the GC
  // though.
  // Additionally, it's not really safe/guaranteed to be correct, as
  // something down the paint pipe may want to farther tweak the color
  // filter, which could yield incorrect results. (Consider just using
  // saveLayer() w/ this color filter explicitly instead.)
  paint.setColorFilter(sk_ref_sp(paintInfo.context.getColorFilter()));
  return true;
}