aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-01-09 17:10:18 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-09 23:08:18 +0000
commit0e66fbab101d4e31f98efd05b80c73654341142b (patch)
tree7582529b9091f9578771dfe1b3d7e9acb450d4a6 /experimental
parent7195faccb94fd3415fb8c527b4d95f9289ba9c56 (diff)
[skotty] Initial solid layer support
TBR= Change-Id: Ib78ff693a1c79873248563502635aed93a90f963 Reviewed-on: https://skia-review.googlesource.com/92624 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental')
-rw-r--r--experimental/skotty/Skotty.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/experimental/skotty/Skotty.cpp b/experimental/skotty/Skotty.cpp
index 8d43d46b45..df5e6e289d 100644
--- a/experimental/skotty/Skotty.cpp
+++ b/experimental/skotty/Skotty.cpp
@@ -16,6 +16,7 @@
#include "SkMakeUnique.h"
#include "SkOSPath.h"
#include "SkPaint.h"
+#include "SkParse.h"
#include "SkPath.h"
#include "SkPoint.h"
#include "SkSGColor.h"
@@ -598,11 +599,24 @@ sk_sp<sksg::RenderNode> AttachCompLayer(const Json::Value& layer, AttachContext*
return AttachComposition(**comp, ctx);
}
-sk_sp<sksg::RenderNode> AttachSolidLayer(const Json::Value& layer, AttachContext*) {
- SkASSERT(layer.isObject());
+sk_sp<sksg::RenderNode> AttachSolidLayer(const Json::Value& jlayer, AttachContext*) {
+ SkASSERT(jlayer.isObject());
+
+ const auto size = SkSize::Make(ParseScalar(jlayer["sw"], -1),
+ ParseScalar(jlayer["sh"], -1));
+ const auto hex = ParseString(jlayer["sc"], "");
+ uint32_t c;
+ if (size.isEmpty() ||
+ !hex.startsWith("#") ||
+ !SkParse::FindHex(hex.c_str() + 1, &c)) {
+ LogFail(jlayer, "Could not parse solid layer");
+ return nullptr;
+ }
- LOG("?? Solid layer stub\n");
- return nullptr;
+ const SkColor color = 0xff000000 | c;
+
+ return sksg::Draw::Make(sksg::Rect::Make(SkRect::MakeSize(size)),
+ sksg::Color::Make(color));
}
sk_sp<sksg::RenderNode> AttachImageAsset(const Json::Value& jimage, AttachContext* ctx) {