[canvaskit] expose ComputeTonalColors
Change-Id: Ia4f0eec8e162ad273e856c04ca98c7e2cb48935e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/240693
Reviewed-by: Jim Van Verth <jvanverth@google.com>
diff --git a/modules/canvaskit/canvaskit_bindings.cpp b/modules/canvaskit/canvaskit_bindings.cpp
index 7e7d881..37f1059 100644
--- a/modules/canvaskit/canvaskit_bindings.cpp
+++ b/modules/canvaskit/canvaskit_bindings.cpp
@@ -577,6 +577,18 @@
return rr;
}
+struct TonalColors {
+ SkColor ambientColor;
+ SkColor spotColor;
+};
+
+TonalColors computeTonalColors(const TonalColors& in) {
+ TonalColors out;
+ SkShadowUtils::ComputeTonalColors(in.ambientColor, in.spotColor,
+ &out.ambientColor, &out.spotColor);
+ return out;
+}
+
// These objects have private destructors / delete methods - I don't think
// we need to do anything other than tell emscripten to do nothing.
namespace emscripten {
@@ -624,6 +636,7 @@
constant("gpu", true);
#endif
+ function("computeTonalColors", &computeTonalColors);
function("_decodeImage", optional_override([](uintptr_t /* uint8_t* */ iptr,
size_t length)->sk_sp<SkImage> {
uint8_t* imgData = reinterpret_cast<uint8_t*>(iptr);
@@ -1336,6 +1349,10 @@
.field("fRight", &SkIRect::fRight)
.field("fBottom", &SkIRect::fBottom);
+ value_object<TonalColors>("TonalColors")
+ .field("ambient", &TonalColors::ambientColor)
+ .field("spot", &TonalColors::spotColor);
+
value_object<SimpleImageInfo>("SkImageInfo")
.field("width", &SimpleImageInfo::width)
.field("height", &SimpleImageInfo::height)