diff options
author | fmalita <fmalita@chromium.org> | 2016-08-08 11:38:55 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-08 11:38:55 -0700 |
commit | 397a517d1a5774653fcdd08172f9a6b5eea67621 (patch) | |
tree | ab9c9aaa4121a8033a29f259401bcecf7d178203 /experimental/svg/model/SkSVGTypes.h | |
parent | f621ff49a288978c272d5ae069a6a1c04c74642b (diff) |
[SVGDom] Add viewBox support
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
Diffstat (limited to 'experimental/svg/model/SkSVGTypes.h')
-rw-r--r-- | experimental/svg/model/SkSVGTypes.h | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/experimental/svg/model/SkSVGTypes.h b/experimental/svg/model/SkSVGTypes.h index 6d34d9943a..ab07d7b16c 100644 --- a/experimental/svg/model/SkSVGTypes.h +++ b/experimental/svg/model/SkSVGTypes.h @@ -9,25 +9,30 @@ #define SkSVGTypes_DEFINED #include "SkColor.h" +#include "SkRect.h" #include "SkScalar.h" #include "SkTypes.h" -class SkSVGNumber { +template <typename T> +class SkSVGPrimitiveTypeWrapper { public: - constexpr SkSVGNumber() : fValue(0) {} - explicit constexpr SkSVGNumber(SkScalar v) : fValue(v) {} - SkSVGNumber(const SkSVGNumber&) = default; - SkSVGNumber& operator=(const SkSVGNumber&) = default; + SkSVGPrimitiveTypeWrapper() = default; + explicit constexpr SkSVGPrimitiveTypeWrapper(T v) : fValue(v) {} + SkSVGPrimitiveTypeWrapper(const SkSVGPrimitiveTypeWrapper&) = default; + SkSVGPrimitiveTypeWrapper& operator=(const SkSVGPrimitiveTypeWrapper&) = default; - const SkScalar& value() const { return fValue; } - - operator const SkScalar&() const { return fValue; } + const T& value() const { return fValue; } + operator const T&() const { return fValue; } private: - SkScalar fValue; + T fValue; }; +using SkSVGColorType = SkSVGPrimitiveTypeWrapper<SkColor >; +using SkSVGNumberType = SkSVGPrimitiveTypeWrapper<SkScalar>; +using SkSVGViewBoxType = SkSVGPrimitiveTypeWrapper<SkRect >; + class SkSVGLength { public: enum class Unit { @@ -58,15 +63,4 @@ private: Unit fUnit; }; -class SkSVGColor { -public: - constexpr SkSVGColor() : fValue(SK_ColorBLACK) {} - explicit constexpr SkSVGColor(SkColor c) : fValue(c) {} - - operator const SkColor&() const { return fValue; } - -private: - SkColor fValue; -}; - #endif // SkSVGTypes_DEFINED |