aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-01-04 10:26:35 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-04 16:23:14 +0000
commitfbc13f14340af13ee4c8762d26acec47819f07bc (patch)
treeda83646c263b4264234643ceecf34042ae5720d8 /experimental
parent1445da6c03c7ce6a3039bd63498e1179a320722f (diff)
[skotty] Add ellipse support
TBR= Change-Id: I48bbc6aabaab1c3ab5cc9fb19c87ad1f5606eb54 Reviewed-on: https://skia-review.googlesource.com/90900 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental')
-rw-r--r--experimental/skotty/Skotty.cpp31
-rw-r--r--experimental/skotty/SkottyProperties.cpp4
-rw-r--r--experimental/skotty/SkottyProperties.h2
3 files changed, 33 insertions, 4 deletions
diff --git a/experimental/skotty/Skotty.cpp b/experimental/skotty/Skotty.cpp
index 47ff828183..093d7f68e4 100644
--- a/experimental/skotty/Skotty.cpp
+++ b/experimental/skotty/Skotty.cpp
@@ -158,12 +158,39 @@ sk_sp<sksg::GeometryNode> AttachRRectGeometry(const Json::Value& jrect, AttachCo
auto s_attached = AttachProperty<VectorValue, SkSize>(jrect["s"], ctx, composite,
[](const sk_sp<CompositeRRect>& node, const SkSize& sz) { node->setSize(sz); });
auto r_attached = AttachProperty<ScalarValue, SkScalar>(jrect["r"], ctx, composite,
- [](const sk_sp<CompositeRRect>& node, SkScalar radius) { node->setRadius(radius); });
+ [](const sk_sp<CompositeRRect>& node, SkScalar radius) {
+ node->setRadius(SkSize::Make(radius, radius));
+ });
if (!p_attached && !s_attached && !r_attached) {
return nullptr;
}
+ LOG("** Attached (r)rect geometry\n");
+
+ return rect_node;
+}
+
+sk_sp<sksg::GeometryNode> AttachEllipseGeometry(const Json::Value& jellipse, AttachContext* ctx) {
+ SkASSERT(jellipse.isObject());
+
+ auto rect_node = sksg::RRect::Make();
+ auto composite = sk_make_sp<CompositeRRect>(rect_node);
+
+ auto p_attached = AttachProperty<VectorValue, SkPoint>(jellipse["p"], ctx, composite,
+ [](const sk_sp<CompositeRRect>& node, const SkPoint& pos) { node->setPosition(pos); });
+ auto s_attached = AttachProperty<VectorValue, SkSize>(jellipse["s"], ctx, composite,
+ [](const sk_sp<CompositeRRect>& node, const SkSize& sz) {
+ node->setSize(sz);
+ node->setRadius(SkSize::Make(sz.width() / 2, sz.height() / 2));
+ });
+
+ if (!p_attached && !s_attached) {
+ return nullptr;
+ }
+
+ LOG("** Attached ellipse geometry\n");
+
return rect_node;
}
@@ -250,6 +277,7 @@ using GeometryAttacherT = sk_sp<sksg::GeometryNode> (*)(const Json::Value&, Atta
static constexpr GeometryAttacherT gGeometryAttachers[] = {
AttachPathGeometry,
AttachRRectGeometry,
+ AttachEllipseGeometry,
};
using PaintAttacherT = sk_sp<sksg::PaintNode> (*)(const Json::Value&, AttachContext*);
@@ -293,6 +321,7 @@ struct ShapeInfo {
const ShapeInfo* FindShapeInfo(const Json::Value& shape) {
static constexpr ShapeInfo gShapeInfo[] = {
+ { "el", ShapeType::kGeometry , 2 }, // ellipse -> AttachEllipseGeometry
{ "fl", ShapeType::kPaint , 0 }, // fill -> AttachFillPaint
{ "gr", ShapeType::kGroup , 0 }, // group -> AttachShapeGroup
{ "mm", ShapeType::kGeometryEffect, 0 }, // merge -> AttachMergeGeometryEffect
diff --git a/experimental/skotty/SkottyProperties.cpp b/experimental/skotty/SkottyProperties.cpp
index 5d94d73ef6..241b659c9d 100644
--- a/experimental/skotty/SkottyProperties.cpp
+++ b/experimental/skotty/SkottyProperties.cpp
@@ -166,8 +166,8 @@ void CompositeRRect::apply() {
auto rr = SkRRect::MakeRectXY(SkRect::MakeXYWH(fPosition.x() - fSize.width() / 2,
fPosition.y() - fSize.height() / 2,
fSize.width(), fSize.height()),
- fRadius,
- fRadius);
+ fRadius.width(),
+ fRadius.height());
fRRectNode->setRRect(rr);
}
diff --git a/experimental/skotty/SkottyProperties.h b/experimental/skotty/SkottyProperties.h
index 990862f195..6147dd4d63 100644
--- a/experimental/skotty/SkottyProperties.h
+++ b/experimental/skotty/SkottyProperties.h
@@ -101,7 +101,7 @@ public:
COMPOSITE_PROPERTY(Position, SkPoint , SkPoint::Make(0, 0))
COMPOSITE_PROPERTY(Size , SkSize , SkSize::Make(0, 0))
- COMPOSITE_PROPERTY(Radius , SkScalar, 0)
+ COMPOSITE_PROPERTY(Radius , SkSize , SkSize::Make(0, 0))
private:
void apply();