[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 <nifong@google.com>
This commit is contained in:
Kevin Lubick 2022-02-15 15:02:17 -05:00
parent 56438322bd
commit 149938e8e3
7 changed files with 46 additions and 82 deletions

View File

@ -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": [],
})

View File

@ -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" ]
}
}

View File

@ -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

View File

@ -73,25 +73,25 @@
#include <webgl/webgl1.h>
#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> SkFontMgr_New_Custom_Data(sk_sp<SkData>* 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>(SkVertices* ptr) {
}
#ifndef SK_NO_FONTS
#ifndef CK_NO_FONTS
template<>
void raw_destructor<SkTextBlob>(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<SkPicture> {
uint8_t* d = reinterpret_cast<uint8_t*>(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_<SkFont>("Font")
.constructor<>()
.constructor<sk_sp<SkTypeface>>()
@ -1348,7 +1348,7 @@ EMSCRIPTEN_BINDINGS(Skia) {
return self.makeFromData(fontData);
}), allow_raw_pointers());
#endif // SK_NO_FONTS
#endif // CK_NO_FONTS
class_<SkImage>("Image")
.smart_ptr<sk_sp<SkImage>>("sk_sp<Image>")
@ -1529,7 +1529,7 @@ EMSCRIPTEN_BINDINGS(Skia) {
// TODO(kjlubick, reed) Make SkPath immutable and only creatable via a factory/builder.
class_<SkPath>("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<SkRect*>(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_<SkSL::DebugTrace>("DebugTrace")
.smart_ptr<sk_sp<SkSL::DebugTrace>>("sk_sp<DebugTrace>")
.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<SkShader> shader,
int traceCoordX,
@ -1961,7 +1961,7 @@ EMSCRIPTEN_BINDINGS(Skia) {
#endif
.function("width", &SkSurface::width);
#ifndef SK_NO_FONTS
#ifndef CK_NO_FONTS
class_<SkTextBlob>("TextBlob")
.smart_ptr<sk_sp<SkTextBlob>>("sk_sp<TextBlob>")
.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_<SkPathOp>("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_<SkFontHinting>("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
}

View File

@ -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} \

View File

@ -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 <string>
#include <vector>
#include <emscripten.h>
#include <emscripten/bind.h>
#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>("ManagedAnimation")
.smart_ptr<sk_sp<ManagedAnimation>>("sk_sp<ManagedAnimation>")
.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
}

View File

@ -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<sksg::RenderNode> 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<sksg::RenderNode> AnimationBuilder::attachTextLayer(const skjson::ObjectVa
fLazyFontMgr.getMaybeNull(),
fLogger);
}
#endif
const AnimationBuilder::FontInfo* AnimationBuilder::findFont(const SkString& font_name) const {
return fFonts.find(font_name);