[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>
diff --git a/experimental/skotty/Skotty.cpp b/experimental/skotty/Skotty.cpp
index 8d43d46..df5e6e2 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 @@
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());
- LOG("?? Solid layer stub\n");
- return nullptr;
+ 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;
+ }
+
+ 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) {