diff options
author | Kevin Lubick <kjlubick@google.com> | 2018-07-16 21:00:52 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-17 18:27:31 +0000 |
commit | 92eaa3cafd09aa4b93a23a601c40dc74cd94f0c7 (patch) | |
tree | afb2162e6fd8c35be07083c296a225c61fcc02ae /experimental/wasm/wasm_main.cpp | |
parent | eb1d9004f56a1fe812916e254ca2cce5c0209194 (diff) |
Add SkFloat2Bits and Region stub
Bug: skia:
Change-Id: I5ab9a4d42e9eec6563499a09e08ed8b183ac91b2
Reviewed-on: https://skia-review.googlesource.com/141426
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Diffstat (limited to 'experimental/wasm/wasm_main.cpp')
-rw-r--r-- | experimental/wasm/wasm_main.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/experimental/wasm/wasm_main.cpp b/experimental/wasm/wasm_main.cpp index a2876d9f40..ab68b795da 100644 --- a/experimental/wasm/wasm_main.cpp +++ b/experimental/wasm/wasm_main.cpp @@ -5,10 +5,12 @@ * found in the LICENSE file. */ +#include "SkFloatBits.h" #include "SkFloatingPoint.h" #include "SkParsePath.h" #include "SkPath.h" #include "SkPathOps.h" +#include "SkRegion.h" #include "SkString.h" #include <emscripten/emscripten.h> @@ -309,6 +311,16 @@ emscripten::val EMSCRIPTEN_KEEPALIVE ToPath2D(SkPath path, val/* Path2D&*/ retVa return retVal; } +//======================================================================================== +// Region things +//======================================================================================== + +SkPath GetBoundaryPathFromRegion(SkRegion region) { + SkPath p; + region.getBoundaryPath(&p); + return p; +} + // Binds the classes to the JS EMSCRIPTEN_BINDINGS(skia) { class_<SkPath>("SkPath") @@ -322,15 +334,30 @@ EMSCRIPTEN_BINDINGS(skia) { select_overload<void(SkScalar, SkScalar, SkScalar, SkScalar)>(&SkPath::quadTo)) .function("cubicTo", select_overload<void(SkScalar, SkScalar, SkScalar, SkScalar, SkScalar, SkScalar)>(&SkPath::cubicTo)) - .function("close", &SkPath::close); + .function("close", &SkPath::close) // Uncomment below for debugging. - //.function("dump", select_overload<void() const>(&SkPath::dump)); + .function("dump", select_overload<void() const>(&SkPath::dump)); class_<SkOpBuilder>("SkOpBuilder") .constructor<>() .function("add", &SkOpBuilder::add); + class_<SkRegion>("SkRegion") + .constructor<>() + + .function("setRect", + select_overload<bool(int32_t, int32_t, int32_t, int32_t)>(&SkRegion::setRect)) + .function("setPath", &SkRegion::setPath) + .function("opLTRB", + select_overload<bool(int32_t, int32_t, int32_t, int32_t, SkRegion::Op)>(&SkRegion::op)) + .function("opRegion", + select_overload<bool(const SkRegion&, SkRegion::Op)>(&SkRegion::op)) + .function("opRegionAB", + select_overload<bool(const SkRegion&, const SkRegion&, SkRegion::Op)>(&SkRegion::op)) + ; + + // Without this, module._ToPath2D (yes with an underscore) // would be exposed, but be unable to correctly handle the SkPath type. function("ToPath2D", &ToPath2D); @@ -347,6 +374,10 @@ EMSCRIPTEN_BINDINGS(skia) { function("ApplyPathOp", &ApplyPathOp); function("ResolveBuilder", &ResolveBuilder); + function("SkBits2Float", &SkBits2Float); + + function("GetBoundaryPathFromRegion", &GetBoundaryPathFromRegion); + enum_<SkPathOp>("PathOp") .value("DIFFERENCE", SkPathOp::kDifference_SkPathOp) .value("INTERSECT", SkPathOp::kIntersect_SkPathOp) @@ -354,6 +385,14 @@ EMSCRIPTEN_BINDINGS(skia) { .value("XOR", SkPathOp::kXOR_SkPathOp) .value("REVERSE_DIFFERENCE", SkPathOp::kReverseDifference_SkPathOp); + enum_<SkRegion::Op>("RegionOp") + .value("DIFFERENCE", SkRegion::Op::kDifference_Op) + .value("INTERSECT", SkRegion::Op::kIntersect_Op) + .value("UNION", SkRegion::Op::kUnion_Op) + .value("XOR", SkRegion::Op::kXOR_Op) + .value("REVERSE_DIFFERENCE", SkRegion::Op::kReverseDifference_Op) + .value("REPLACE", SkRegion::Op::kReplace_Op); + constant("MOVE_VERB", MOVE); constant("LINE_VERB", LINE); constant("QUAD_VERB", QUAD); |