From 149938e8e34f042e67719daef4a4ece91478fd55 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Tue, 15 Feb 2022 15:02:17 -0500 Subject: [PATCH] [canvaskit] Rename some CK-specific defines The one use of the define in //modules/skottie was in an old G3 BUILD file which has since been deleted. Change-Id: I3cbb0dd2bcbff7de433b2d044b3e7a0c34a45240 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/509400 Reviewed-by: Nathaniel Nifong --- modules/canvaskit/BUILD.bazel | 17 +++----- modules/canvaskit/BUILD.gn | 27 ++++++------- modules/canvaskit/canvaskit.gni | 1 - modules/canvaskit/canvaskit_bindings.cpp | 50 ++++++++++++------------ modules/canvaskit/compile.sh | 7 ---- modules/canvaskit/skottie_bindings.cpp | 16 ++------ modules/skottie/src/layers/TextLayer.cpp | 10 ----- 7 files changed, 46 insertions(+), 82 deletions(-) diff --git a/modules/canvaskit/BUILD.bazel b/modules/canvaskit/BUILD.bazel index 976acee98c..68b91babb0 100644 --- a/modules/canvaskit/BUILD.bazel +++ b/modules/canvaskit/BUILD.bazel @@ -127,23 +127,18 @@ genrule( # Note: These are defines that only impact the _bindings.cpp files in this folder. # Any defines that need to effect the entire Skia build should go in //bazel/BUILD.bazel CK_DEFINES = [ - "SK_INCLUDE_PATHOPS=1", + "CK_INCLUDE_PATHOPS", ] + select({ - ":enable_fonts_true": ["SK_INCLUDE_PARAGRAPH=1"], - ":enable_fonts_false": ["SK_NO_FONTS"], + ":enable_fonts_true": ["CK_INCLUDE_PARAGRAPH"], + ":enable_fonts_false": ["CK_NO_FONTS"], }) + select({ - # TODO(kjlubick) Get rid of this extra define - if we are including skottie, we will include the - # managed version. - ":enable_skottie_true": ["SK_INCLUDE_MANAGED_SKOTTIE=1"], - ":enable_skottie_false": [], -}) + select({ - ":enable_skp_serialization_true": ["SK_SERIALIZE_SKP=1"], + ":enable_skp_serialization_true": ["CK_SERIALIZE_SKP=1"], ":enable_skp_serialization_false": [], }) + select({ - ":enable_runtime_effect_true": ["SK_INCLUDE_RUNTIME_EFFECT=1"], + ":enable_runtime_effect_true": ["CK_INCLUDE_RUNTIME_EFFECT=1"], ":enable_runtime_effect_false": [], }) + select({ - ":enable_sksl_tracing_true": ["SK_INCLUDE_SKSL_TRACE=1"], + ":enable_sksl_tracing_true": ["CK_INCLUDE_SKSL_TRACE=1"], ":enable_sksl_tracing_false": [], }) diff --git a/modules/canvaskit/BUILD.gn b/modules/canvaskit/BUILD.gn index c18949d026..58d06d5a3f 100644 --- a/modules/canvaskit/BUILD.gn +++ b/modules/canvaskit/BUILD.gn @@ -114,10 +114,10 @@ skia_wasm_lib("canvaskit") { ] } if (skia_canvaskit_enable_skottie) { - sources += [ "skottie_bindings.cpp" ] - if (skia_canvaskit_enable_managed_skottie) { - sources += [ "../../modules/skottie/utils/SkottieUtils.cpp" ] - } + sources += [ + "../../modules/skottie/utils/SkottieUtils.cpp", + "skottie_bindings.cpp", + ] } if (skia_canvaskit_enable_particles) { sources += [ "particles_bindings.cpp" ] @@ -321,10 +321,10 @@ skia_wasm_lib("canvaskit") { "SK_SHAPER_HARFBUZZ_AVAILABLE", ] if (skia_canvaskit_enable_paragraph) { - defines += [ "SK_INCLUDE_PARAGRAPH=1" ] + defines += [ "CK_INCLUDE_PARAGRAPH" ] } if (skia_canvaskit_enable_skp_serialization) { - defines += [ "SK_SERIALIZE_SKP" ] + defines += [ "CK_SERIALIZE_SKP" ] } if (skia_enable_gpu) { defines += [ @@ -338,26 +338,21 @@ skia_wasm_lib("canvaskit") { "SK_ENABLE_SKSL", ] } - if (!skia_canvaskit_enable_skottie || - !skia_canvaskit_enable_managed_skottie) { - defines += [ "SK_INCLUDE_MANAGED_SKOTTIE=0" ] - } else { - defines += [ "SK_INCLUDE_MANAGED_SKOTTIE=1" ] - } + if (skia_canvaskit_enable_pathops) { - defines += [ "SK_INCLUDE_PATHOPS" ] + defines += [ "CK_INCLUDE_PATHOPS" ] } if (skia_canvaskit_enable_rt_shader) { - defines += [ "SK_INCLUDE_RUNTIME_EFFECT" ] + defines += [ "CK_INCLUDE_RUNTIME_EFFECT" ] } if (skia_canvaskit_enable_sksl_trace) { - defines += [ "SK_INCLUDE_SKSL_TRACE" ] + defines += [ "CK_INCLUDE_SKSL_TRACE" ] } if (!skia_canvaskit_enable_alias_font) { defines += [ "CANVASKIT_NO_ALIAS_FONT" ] } if (!skia_canvaskit_enable_font) { - defines += [ "SK_NO_FONTS" ] + defines += [ "CK_NO_FONTS" ] } } diff --git a/modules/canvaskit/canvaskit.gni b/modules/canvaskit/canvaskit.gni index 7b6ac9fcb7..7b5a844421 100644 --- a/modules/canvaskit/canvaskit.gni +++ b/modules/canvaskit/canvaskit.gni @@ -5,7 +5,6 @@ declare_args() { skia_canvaskit_enable_canvas_bindings = true skia_canvaskit_enable_skottie = true - skia_canvaskit_enable_managed_skottie = true skia_canvaskit_enable_pathops = true skia_canvaskit_enable_particles = true skia_canvaskit_enable_rt_shader = true diff --git a/modules/canvaskit/canvaskit_bindings.cpp b/modules/canvaskit/canvaskit_bindings.cpp index b659212ba3..7d0ac3974a 100644 --- a/modules/canvaskit/canvaskit_bindings.cpp +++ b/modules/canvaskit/canvaskit_bindings.cpp @@ -73,25 +73,25 @@ #include #endif -#ifndef SK_NO_FONTS +#ifndef CK_NO_FONTS #include "include/core/SkFont.h" #include "include/core/SkFontMetrics.h" #include "include/core/SkFontMgr.h" #include "include/core/SkFontTypes.h" -#ifdef SK_INCLUDE_PARAGRAPH +#ifdef CK_INCLUDE_PARAGRAPH #include "modules/skparagraph/include/Paragraph.h" -#endif // SK_INCLUDE_PARAGRAPH -#endif // SK_NO_FONTS +#endif // CK_INCLUDE_PARAGRAPH +#endif // CK_NO_FONTS -#ifdef SK_INCLUDE_PATHOPS +#ifdef CK_INCLUDE_PATHOPS #include "include/pathops/SkPathOps.h" #endif -#if defined(SK_INCLUDE_RUNTIME_EFFECT) && defined(SK_INCLUDE_SKSL_TRACE) +#if defined(CK_INCLUDE_RUNTIME_EFFECT) && defined(CK_INCLUDE_SKSL_TRACE) #include "include/sksl/SkSLDebugTrace.h" #endif -#ifndef SK_NO_FONTS +#ifndef CK_NO_FONTS sk_sp SkFontMgr_New_Custom_Data(sk_sp* datas, int n); #endif @@ -327,7 +327,7 @@ void ApplyTransform(SkPath& orig, orig.transform(m); } -#ifdef SK_INCLUDE_PATHOPS +#ifdef CK_INCLUDE_PATHOPS bool ApplySimplify(SkPath& path) { return Simplify(path, &path); } @@ -626,7 +626,7 @@ void computeTonalColors(WASMPointerF32 cPtrAmbi, WASMPointerF32 cPtrSpot) { memcpy(spotFloats, spot4f.vec(), 4 * sizeof(SkScalar)); } -#ifdef SK_INCLUDE_RUNTIME_EFFECT +#ifdef CK_INCLUDE_RUNTIME_EFFECT struct RuntimeEffectUniform { int columns; int rows; @@ -693,7 +693,7 @@ namespace emscripten { void raw_destructor(SkVertices* ptr) { } -#ifndef SK_NO_FONTS +#ifndef CK_NO_FONTS template<> void raw_destructor(SkTextBlob* ptr) { } @@ -867,7 +867,7 @@ EMSCRIPTEN_BINDINGS(Skia) { flags, outputBounds); })); -#ifdef SK_SERIALIZE_SKP +#ifdef CK_SERIALIZE_SKP function("_MakePicture", optional_override([](WASMPointerU8 dPtr, size_t bytes)->sk_sp { uint8_t* d = reinterpret_cast(dPtr); @@ -1068,7 +1068,7 @@ EMSCRIPTEN_BINDINGS(Skia) { self.drawOval(*oval, paint); })) .function("_drawPaint", &SkCanvas::drawPaint) -#ifdef SK_INCLUDE_PARAGRAPH +#ifdef CK_INCLUDE_PARAGRAPH .function("_drawParagraph", optional_override([](SkCanvas& self, skia::textlayout::Paragraph* p, SkScalar x, SkScalar y) { p->paint(&self, x, y); @@ -1124,7 +1124,7 @@ EMSCRIPTEN_BINDINGS(Skia) { ptrToSkColor4f(spotColorPtr).toSkColor(), flags); })) -#ifndef SK_NO_FONTS +#ifndef CK_NO_FONTS .function("_drawSimpleText", optional_override([](SkCanvas& self, WASMPointerU8 sptr, size_t len, SkScalar x, SkScalar y, const SkFont& font, const SkPaint& paint) { @@ -1234,7 +1234,7 @@ EMSCRIPTEN_BINDINGS(Skia) { .function("isClosed", &SkContourMeasure::isClosed) .function("length", &SkContourMeasure::length); -#ifndef SK_NO_FONTS +#ifndef CK_NO_FONTS class_("Font") .constructor<>() .constructor>() @@ -1348,7 +1348,7 @@ EMSCRIPTEN_BINDINGS(Skia) { return self.makeFromData(fontData); }), allow_raw_pointers()); -#endif // SK_NO_FONTS +#endif // CK_NO_FONTS class_("Image") .smart_ptr>("sk_sp") @@ -1529,7 +1529,7 @@ EMSCRIPTEN_BINDINGS(Skia) { // TODO(kjlubick, reed) Make SkPath immutable and only creatable via a factory/builder. class_("Path") .constructor<>() -#ifdef SK_INCLUDE_PATHOPS +#ifdef CK_INCLUDE_PATHOPS .class_function("MakeFromOp", &MakePathFromOp) #endif .class_function("MakeFromSVGString", &MakePathFromSVGString) @@ -1606,7 +1606,7 @@ EMSCRIPTEN_BINDINGS(Skia) { .function("_trim", &ApplyTrim) .function("_stroke", &ApplyStroke) -#ifdef SK_INCLUDE_PATHOPS +#ifdef CK_INCLUDE_PATHOPS // PathOps .function("_simplify", &ApplySimplify) .function("_op", &ApplyPathOp) @@ -1657,7 +1657,7 @@ EMSCRIPTEN_BINDINGS(Skia) { SkRect* tileRect = reinterpret_cast(rPtr); return self.makeShader(tmx, tmy, mode, &localMatrix, tileRect); }), allow_raw_pointers()) -#ifdef SK_SERIALIZE_SKP +#ifdef CK_SERIALIZE_SKP // The serialized format of an SkPicture (informally called an "skp"), is not something // that clients should ever rely on. The format may change at anytime and no promises // are made for backwards or forward compatibility. @@ -1799,8 +1799,8 @@ EMSCRIPTEN_BINDINGS(Skia) { return nullptr; }), allow_raw_pointers()); -#ifdef SK_INCLUDE_RUNTIME_EFFECT -#ifdef SK_INCLUDE_SKSL_TRACE +#ifdef CK_INCLUDE_RUNTIME_EFFECT +#ifdef CK_INCLUDE_SKSL_TRACE class_("DebugTrace") .smart_ptr>("sk_sp") .function("writeTrace", optional_override([](SkSL::DebugTrace& self) -> std::string { @@ -1828,7 +1828,7 @@ EMSCRIPTEN_BINDINGS(Skia) { } return effect; })) -#ifdef SK_INCLUDE_SKSL_TRACE +#ifdef CK_INCLUDE_SKSL_TRACE .class_function("MakeTraced", optional_override([]( sk_sp shader, int traceCoordX, @@ -1961,7 +1961,7 @@ EMSCRIPTEN_BINDINGS(Skia) { #endif .function("width", &SkSurface::width); -#ifndef SK_NO_FONTS +#ifndef CK_NO_FONTS class_("TextBlob") .smart_ptr>("sk_sp") .class_function("_MakeFromRSXform", optional_override([](WASMPointerU8 sptr, @@ -2130,7 +2130,7 @@ EMSCRIPTEN_BINDINGS(Skia) { .value("Rotate", SkPath1DPathEffect::Style::kRotate_Style) .value("Morph", SkPath1DPathEffect::Style::kMorph_Style); -#ifdef SK_INCLUDE_PATHOPS +#ifdef CK_INCLUDE_PATHOPS enum_("PathOp") .value("Difference", SkPathOp::kDifference_SkPathOp) .value("Intersect", SkPathOp::kIntersect_SkPathOp) @@ -2154,7 +2154,7 @@ EMSCRIPTEN_BINDINGS(Skia) { .value("Round", SkPaint::Join::kRound_Join) .value("Bevel", SkPaint::Join::kBevel_Join); -#ifndef SK_NO_FONTS +#ifndef CK_NO_FONTS enum_("FontHinting") .value("None", SkFontHinting::kNone) .value("Slight", SkFontHinting::kSlight) @@ -2212,7 +2212,7 @@ EMSCRIPTEN_BINDINGS(Skia) { constant("ShadowGeometricOnly", (int)SkShadowFlags::kGeometricOnly_ShadowFlag); constant("ShadowDirectionalLight", (int)SkShadowFlags::kDirectionalLight_ShadowFlag); -#ifdef SK_INCLUDE_PARAGRAPH +#ifdef CK_INCLUDE_PARAGRAPH constant("_GlyphRunFlags_isWhiteSpace", (int)skia::textlayout::Paragraph::kWhiteSpace_VisitorFlag); #endif } diff --git a/modules/canvaskit/compile.sh b/modules/canvaskit/compile.sh index 3494a95005..c83bf7932a 100755 --- a/modules/canvaskit/compile.sh +++ b/modules/canvaskit/compile.sh @@ -73,12 +73,6 @@ if [[ $@ == *viewer* ]]; then IS_OFFICIAL_BUILD="false" fi -ENABLE_MANAGED_SKOTTIE="true" -if [[ $@ == *no_managed_skottie* || $@ == *no_skottie* ]]; then - echo "Omitting managed Skottie" - ENABLED_MANAGED_SKOTTIE="false" -fi - ENABLE_PARTICLES="true" if [[ $@ == *no_particles* ]]; then echo "Omitting Particles" @@ -239,7 +233,6 @@ echo "Compiling" skia_canvaskit_enable_effects_deserialization=${DESERIALIZE_EFFECTS} \ skia_canvaskit_enable_skottie=${ENABLE_SKOTTIE} \ skia_canvaskit_include_viewer=${INCLUDE_VIEWER} \ - skia_canvaskit_enable_managed_skottie=${ENABLE_MANAGED_SKOTTIE} \ skia_canvaskit_enable_particles=${ENABLE_PARTICLES} \ skia_canvaskit_enable_pathops=${ENABLE_PATHOPS} \ skia_canvaskit_enable_rt_shader=${ENABLE_RT_SHADER} \ diff --git a/modules/canvaskit/skottie_bindings.cpp b/modules/canvaskit/skottie_bindings.cpp index 1de0331efc..b51f5eaa91 100644 --- a/modules/canvaskit/skottie_bindings.cpp +++ b/modules/canvaskit/skottie_bindings.cpp @@ -9,25 +9,20 @@ #include "include/core/SkImage.h" #include "include/core/SkString.h" #include "include/core/SkTypes.h" +#include "modules/canvaskit/WasmCommon.h" #include "modules/skottie/include/Skottie.h" +#include "modules/skottie/include/SkottieProperty.h" +#include "modules/skottie/utils/SkottieUtils.h" +#include "modules/skresources/include/SkResources.h" #include "modules/sksg/include/SkSGInvalidationController.h" #include #include - #include #include -#include "modules/canvaskit/WasmCommon.h" - -#if SK_INCLUDE_MANAGED_SKOTTIE -#include "modules/skottie/include/SkottieProperty.h" -#include "modules/skottie/utils/SkottieUtils.h" -#include "modules/skresources/include/SkResources.h" -#endif // SK_INCLUDE_MANAGED_SKOTTIE using namespace emscripten; -#if SK_INCLUDE_MANAGED_SKOTTIE namespace { // WebTrack wraps a JS object that has a 'seek' method. @@ -280,7 +275,6 @@ private: }; } // anonymous ns -#endif // SK_INCLUDE_MANAGED_SKOTTIE EMSCRIPTEN_BINDINGS(Skottie) { // Animation things (may eventually go in own library) @@ -313,7 +307,6 @@ EMSCRIPTEN_BINDINGS(Skottie) { })); constant("skottie", true); -#if SK_INCLUDE_MANAGED_SKOTTIE class_("ManagedAnimation") .smart_ptr>("sk_sp") .function("version" , &ManagedAnimation::version) @@ -381,5 +374,4 @@ EMSCRIPTEN_BINDINGS(Skottie) { prop_prefix, std::move(logger)); })); constant("managed_skottie", true); -#endif // SK_INCLUDE_MANAGED_SKOTTIE } diff --git a/modules/skottie/src/layers/TextLayer.cpp b/modules/skottie/src/layers/TextLayer.cpp index ef458edb48..ebdc0e828f 100644 --- a/modules/skottie/src/layers/TextLayer.cpp +++ b/modules/skottie/src/layers/TextLayer.cpp @@ -170,15 +170,6 @@ bool AnimationBuilder::FontInfo::matches(const char family[], const char style[] && 0 == strcmp(fStyle.c_str(), style); } -#ifdef SK_NO_FONTS -void AnimationBuilder::parseFonts(const skjson::ObjectValue* jfonts, - const skjson::ArrayValue* jchars) {} - -sk_sp AnimationBuilder::attachTextLayer(const skjson::ObjectValue& jlayer, - LayerInfo*) const { - return nullptr; -} -#else void AnimationBuilder::parseFonts(const skjson::ObjectValue* jfonts, const skjson::ArrayValue* jchars) { // Optional array of font entries, referenced (by name) from text layer document nodes. E.g. @@ -404,7 +395,6 @@ sk_sp AnimationBuilder::attachTextLayer(const skjson::ObjectVa fLazyFontMgr.getMaybeNull(), fLogger); } -#endif const AnimationBuilder::FontInfo* AnimationBuilder::findFont(const SkString& font_name) const { return fFonts.find(font_name);