The canvas only needs to be saved once, per local SkSVGRenderContext.
Add a helper (saveOnce) to implement this optimization.
Change-Id: I0c21fa78ad9fd5d3d11de0a29f8441620488d676
Reviewed-on: https://skia-review.googlesource.com/58340
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Robert Phillips <robertphillips@google.com>
The method is used for clip path resolution, and is supposed to transform the path
into parent node coords -- so it should use the forward matrix, not the inverse.
Change-Id: Id6eb9fbaf024b083e19f56eddb1c293becea48fc
Reviewed-on: https://skia-review.googlesource.com/58280
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Currently we use 'fill-rule' when emitting clip paths. This is wrong:
per spec [1], clip paths observe 'clip-rule', not 'fill-rule'.
[1] https://www.w3.org/TR/SVG/masking.html#ClipRuleProperty
Change-Id: Idf81de05e9601663c8dbc9856900ffa679daf4a5
Reviewed-on: https://skia-review.googlesource.com/57661
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Stephan Altmueller <stephana@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
https://www.w3.org/TR/SVG/linking.html#AElement
The Skia SVG DOM is not a user agent, so link semantics are not
particularly interesting. But since <a> can wrap actual content, it is
important to not drop it on the floor.
The simplest thing to do is turn it into a <g> node and run with it.
Change-Id: I4e103553354746ceb49bc1038680a1c477a1320a
Reviewed-on: https://skia-review.googlesource.com/57620
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
In preparation of radial gradient support, move common logic into an
abstract base class (SkSVGGradient).
Change-Id: Ie5361048ca8fddd9070c573c8daef0d0f57dc95e
Reviewed-on: https://skia-review.googlesource.com/57108
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This silences a new warning in clang 5.0
Change-Id: Ieb5b75a6ffed60107c3fd16075d2ecfd515b55e8
Reviewed-on: https://skia-review.googlesource.com/10006
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
ClipPaths can be clipped too, e.g.:
<clipPath id="clip1" clip-path="url(#clip2)">...</clipPath>
Since we're not really drawing clips but resolving their geometry,
asPath() needs to take composed clipping into account (and intersect as
needed).
R=reed@google.com,robertphillips@google.com,stephana@google.com
Change-Id: I25959e22fe50f72042147cfe6b416b6b9ac20cd4
Reviewed-on: https://skia-review.googlesource.com/5720
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
There's a bit of friction with this attribute, because per spec it is
an inherited presentation attribute, but in Skia it is part of the
actual SkPath state.
So we must add some plumbing to SkSVGShape & friends to allow overriding
the fill type at render-time.
R=robertphillips@google.com,stephana@google.com
Change-Id: I9c926d653c6211beb3914bffac50d4349dbdd2c0
Reviewed-on: https://skia-review.googlesource.com/5415
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Kind of a big change, to connect several new bits into something useful:
* ID tracking & lookup
* new asPaint() node virtual to support shader (and in the future filter) based paint servers
* <defs>, <linearGradient> and <stop> element support
* 'href', 'offset', 'stop-color', 'stop-opacity' attribute support
* IRI/FuncIRI and rgb(...) parsing
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2327233003
Review-Url: https://codereview.chromium.org/2327233003
The main feature is <svg> viewBox and proper viewport support, but the CL
touches a few other things:
* refactor SkSVGRenderContext to auto-restore canvas state, and split the
presentation bits into a separate CoW SkSVGPresentationContext
* introduce SkSVGNode::onPrepareToRender(), as a way for nodes to push their
custom state before the actual onRender() call (instead of relying on
non-virtual SkSVGNode to know about all possible state bits)
* add a "Type" suffix to SVG types, to disambiguate (e.g. SkSVGRectType vs.
SkSVGRect)
R=robertphillips@google.com,stephana@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2222793002
Review-Url: https://codereview.chromium.org/2222793002