30 return viewport.
width();
46constexpr SkScalar kINMultiplier = 1.00f;
47constexpr SkScalar kPTMultiplier = kINMultiplier / 72.272f;
48constexpr SkScalar kPCMultiplier = kPTMultiplier * 12;
49constexpr SkScalar kMMMultiplier = kINMultiplier / 25.4f;
50constexpr SkScalar kCMMultiplier = kMMMultiplier * 10;
61 return l.
value() * length_size_for_type(fViewport, t) / 100;
63 return l.
value() * fDPI * kCMMultiplier;
65 return l.
value() * fDPI * kMMMultiplier;
67 return l.
value() * fDPI * kINMultiplier;
69 return l.
value() * fDPI * kPTMultiplier;
71 return l.
value() * fDPI * kPCMultiplier;
73 SkDebugf(
"unsupported unit type: <%d>\n", (
int)l.
unit());
102 switch (
join.type()) {
122 const auto count =
da.dashArray().size();
124 for (
const auto& dash :
da.dashArray()) {
131 intervals.push_back_n(
count);
135 SkASSERT((intervals.size() & 1) == 0);
158 , fTextShapingFactory(fact)
159 , fResourceProvider(rp)
161 , fLengthContext(lctx)
162 , fPresentationContext(pctx)
164 , fCanvasSaveCount(canvas->getSaveCount())
170 other.fResourceProvider,
172 *other.fLengthContext,
173 *other.fPresentationContext,
175 other.fTextShapingFactory) {}
180 other.fResourceProvider,
182 *other.fLengthContext,
183 *other.fPresentationContext,
185 other.fTextShapingFactory) {}
190 other.fResourceProvider,
192 *other.fLengthContext,
193 *other.fPresentationContext,
195 other.fTextShapingFactory) {}
203 SkDebugf(
"non-local iri references not currently supported");
212#define ApplyLazyInheritedAttribute(ATTR) \
215 SkASSERT(fPresentationContext->fInherited.f ## ATTR.isValue()); \
216 const auto& attr = attrs.f ## ATTR; \
217 if (attr.isValue() && *attr != *fPresentationContext->fInherited.f ## ATTR) { \
219 fPresentationContext.writable()->fInherited.f ## ATTR.set(*attr); \
245#undef ApplyLazyInheritedAttribute
259 this->applyMask(*attrs.
fMask);
264 this->applyFilter(*attrs.
fFilter);
277void SkSVGRenderContext::applyOpacity(
SkScalar opacity, uint32_t
flags,
bool hasFilter) {
282 const auto& props = fPresentationContext->
fInherited;
292 if ((
flags &
kLeaf) && (hasFill ^ hasStroke) && !hasFilter) {
293 fDeferredPaintOpacity *= opacity;
299 fCanvas->
saveLayer(
nullptr, &opacityPaint);
303void SkSVGRenderContext::applyFilter(
const SkSVGFuncIRI& filter) {
319 fCanvas->
saveLayer(
nullptr, &filterPaint);
357void SkSVGRenderContext::applyMask(
const SkSVGFuncIRI& mask) {
367 const auto* mask_node =
static_cast<const SkSVGMask*
>(node.get());
368 const auto mask_bounds = mask_node->
bounds(*
this);
371 fCanvas->
saveLayer(mask_bounds,
nullptr);
374 mask_node->renderMask(*
this);
379 fCanvas->
saveLayer(mask_bounds, &masking_paint);
382 fCanvas->
clipRect(mask_bounds,
true);
390 float paint_opacity)
const {
398 switch (paint_selector.
type()) {
420 fTextShapingFactory);
423 if (!node || !node->asPaint(local_ctx,
p.get())) {
432 p->setAntiAlias(
true);
438 p->setAlphaf(
SkTPin(
p->getAlphaf() * paint_opacity * fDeferredPaintOpacity, 0.0f, 1.0f));
444 const auto& props = fPresentationContext->
fInherited;
455 const auto& props = fPresentationContext->
fInherited;
465 p->setPathEffect(dash_effect(props, *fLengthContext));
473 for (
auto&& ident :
color.vars()) {
480 switch (
color.type()) {
482 return color.color();
486 SkDebugf(
"ICC color unimplemented");
495 return {{0,0},{1,1}};
500 return {{obb.
x(), obb.y()}, {obb.width(), obb.height()}};
516 obbt.scale.y * r.y() + obbt.offset.y,
517 obbt.scale.x * r.width(),
518 obbt.scale.y * r.height());
constexpr SkColor SK_ColorBLACK
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
#define ApplyLazyInheritedAttribute(ATTR)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
int saveLayer(const SkRect *bounds, const SkPaint *paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void restoreToCount(int saveCount)
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
@ kButt_Cap
no stroke extension
void setImageFilter(sk_sp< SkImageFilter > imageFilter)
@ kStroke_Style
set to stroke geometry
@ kFill_Style
set to fill geometry
@ kMiter_Join
extends to miter limit
@ kBevel_Join
connects outside edges
void setBlendMode(SkBlendMode mode)
sk_sp< SkImageFilter > buildFilterDAG(const SkSVGRenderContext &) const
const SkSVGIRI & iri() const
const SkSVGStringType & iri() const
SkRect resolveRect(const SkSVGLength &x, const SkSVGLength &y, const SkSVGLength &w, const SkSVGLength &h) const
SkScalar resolve(const SkSVGLength &, LengthType) const
const Unit & unit() const
const SkScalar & value() const
SkRect bounds(const SkSVGRenderContext &) const
SkRect objectBoundingBox(const SkSVGRenderContext &) const
const SkSVGColor & color() const
const SkSVGIRI & iri() const
SkTLazy< SkPaint > fillPaint() const
SkSVGColorType resolveSvgColor(const SkSVGColor &) const
SkRect resolveOBBRect(const SkSVGLength &x, const SkSVGLength &y, const SkSVGLength &w, const SkSVGLength &h, SkSVGObjectBoundingBoxUnits) const
OBBTransform transformForCurrentOBB(SkSVGObjectBoundingBoxUnits) const
BorrowedNode findNodeById(const SkSVGIRI &) const
SkSVGRenderContext(SkCanvas *, const sk_sp< SkFontMgr > &, const sk_sp< skresources::ResourceProvider > &, const SkSVGIDMapper &, const SkSVGLengthContext &, const SkSVGPresentationContext &, const OBBScope &, const sk_sp< SkShapers::Factory > &)
const SkPath * clipPath() const
void applyPresentationAttributes(const SkSVGPresentationAttributes &, uint32_t flags)
SkTLazy< SkPaint > strokePaint() const
V * find(const K &key) const
FlutterSemanticsFlag flags
SK_API sk_sp< SkShader > Color(SkColor)
static SkString join(const CommandLineFlags::StringArray &)
constexpr float x() const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
SkSVGProperty< SkSVGDashArray, true > fStrokeDashArray
SkSVGProperty< SkSVGNumberType, true > fStrokeMiterLimit
SkSVGProperty< SkSVGFuncIRI, false > fMask
SkSVGProperty< SkSVGLineCap, true > fStrokeLineCap
SkSVGProperty< SkSVGLength, true > fStrokeDashOffset
SkSVGProperty< SkSVGPaint, true > fFill
SkSVGProperty< SkSVGNumberType, true > fStrokeOpacity
SkSVGProperty< SkSVGFuncIRI, false > fClipPath
SkSVGProperty< SkSVGNumberType, false > fOpacity
SkSVGProperty< SkSVGNumberType, true > fFillOpacity
SkSVGProperty< SkSVGLength, true > fStrokeWidth
SkSVGProperty< SkSVGLineJoin, true > fStrokeLineJoin
SkSVGProperty< SkSVGPaint, true > fStroke
SkSVGProperty< SkSVGColorType, true > fColor
SkSVGProperty< SkSVGFuncIRI, false > fFilter
SkSVGPresentationAttributes fInherited
SkSVGPresentationContext()
const skia_private::THashMap< SkString, SkSVGColorType > * fNamedColors
const SkSVGRenderContext * fCtx