aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/svg/model/SkSVGValue.h
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-08-08 11:38:55 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-08 11:38:55 -0700
commit397a517d1a5774653fcdd08172f9a6b5eea67621 (patch)
treeab9c9aaa4121a8033a29f259401bcecf7d178203 /experimental/svg/model/SkSVGValue.h
parentf621ff49a288978c272d5ae069a6a1c04c74642b (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/SkSVGValue.h')
-rw-r--r--experimental/svg/model/SkSVGValue.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/experimental/svg/model/SkSVGValue.h b/experimental/svg/model/SkSVGValue.h
index a83c4fe07f..77619c2241 100644
--- a/experimental/svg/model/SkSVGValue.h
+++ b/experimental/svg/model/SkSVGValue.h
@@ -21,6 +21,7 @@ public:
kLength,
kPath,
kTransform,
+ kViewBox,
};
Type type() const { return fType; }
@@ -39,26 +40,31 @@ private:
typedef SkNoncopyable INHERITED;
};
-template <typename SkiaType, SkSVGValue::Type ValueType>
+template <typename T, SkSVGValue::Type ValueType>
class SkSVGWrapperValue final : public SkSVGValue {
public:
static constexpr Type TYPE = ValueType;
- explicit SkSVGWrapperValue(const SkiaType& v)
+ explicit SkSVGWrapperValue(const T& v)
: INHERITED(ValueType)
, fWrappedValue(v) { }
- operator const SkiaType&() const { return fWrappedValue; }
+ operator const T&() const { return fWrappedValue; }
private:
- SkiaType fWrappedValue;
+ // Stack-only
+ void* operator new(size_t) = delete;
+ void* operator new(size_t, void*) = delete;
+
+ const T& fWrappedValue;
typedef SkSVGValue INHERITED;
};
-using SkSVGColorValue = SkSVGWrapperValue<SkSVGColor , SkSVGValue::Type::kColor >;
-using SkSVGLengthValue = SkSVGWrapperValue<SkSVGLength, SkSVGValue::Type::kLength >;
-using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue::Type::kPath >;
-using SkSVGTransformValue = SkSVGWrapperValue<SkMatrix , SkSVGValue::Type::kTransform>;
+using SkSVGColorValue = SkSVGWrapperValue<SkSVGColorType , SkSVGValue::Type::kColor >;
+using SkSVGLengthValue = SkSVGWrapperValue<SkSVGLength , SkSVGValue::Type::kLength >;
+using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue::Type::kPath >;
+using SkSVGTransformValue = SkSVGWrapperValue<SkMatrix , SkSVGValue::Type::kTransform>;
+using SkSVGViewBoxValue = SkSVGWrapperValue<SkSVGViewBoxType, SkSVGValue::Type::kViewBox >;
#endif // SkSVGValue_DEFINED