From 0e66fbab101d4e31f98efd05b80c73654341142b Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Tue, 9 Jan 2018 17:10:18 -0500 Subject: [skotty] Initial solid layer support TBR= Change-Id: Ib78ff693a1c79873248563502635aed93a90f963 Reviewed-on: https://skia-review.googlesource.com/92624 Commit-Queue: Florin Malita Reviewed-by: Florin Malita --- experimental/skotty/Skotty.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'experimental/skotty') 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 AttachCompLayer(const Json::Value& layer, AttachContext* return AttachComposition(**comp, ctx); } -sk_sp AttachSolidLayer(const Json::Value& layer, AttachContext*) { - SkASSERT(layer.isObject()); +sk_sp 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 AttachImageAsset(const Json::Value& jimage, AttachContext* ctx) { -- cgit v1.2.3