[canvaskit] Make codec inclusion configurable

By default, we just ship with PNG encoding/decoding and
then decoding of JPEG, GIF, WEBP.

Change-Id: I19cbb3162acdbfde809df29d49050e3e7cb049db
Bug: skia:9733
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277598
Reviewed-by: Nathaniel Nifong <nifong@google.com>
This commit is contained in:
Kevin Lubick 2020-03-18 09:15:17 -04:00
parent d29d885c88
commit 8febecfee6
3 changed files with 41 additions and 10 deletions

View File

@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `SkCanvas.saveLayer` can now be called with 1 argument (the paint). In this case the current
effective clip will be used, as the current rect is assumed to be null.
- `SkPaint.setAlphaf`
- Clients can supply `no_codecs` to compile.sh to remove all codec encoding and decoded code.
This can save over 100 kb compressed if codecs are not needed.
### Deprecated
- `MakeSkDashPathEffect` will be renamed soon. Calls can be replaced with
@ -27,11 +29,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Shadow offsets properly ignore the CTM in the canvas2d emulation layer.
### Changed
- Stop compiling jpeg and webp encoders, for a smaller binary.
- Stop compiling jpeg and webp encoders by default. This results in a 100kb binary size reduction.
Clients that need these encoders can supply `force_encode_webp` or `force_encode_jpeg` to
compile.sh.
### Removed
- Removed inverse filltypes
- Removed StrokeAndFill paint style
- Removed inverse filltypes.
- Removed StrokeAndFill paint style.
- Removed TextEncoding enum (it was only used internally). All functions assume UTF-8.
## [0.13.0] - 2020-02-28

View File

@ -1681,9 +1681,11 @@ EMSCRIPTEN_BINDINGS(Skia) {
.value("High", SkFilterQuality::kHigh_SkFilterQuality);
// Only used to control the encode function.
// TODO(kjlubick): compile these out when the appropriate encoder is disabled.
enum_<SkEncodedImageFormat>("ImageFormat")
.value("PNG", SkEncodedImageFormat::kPNG)
.value("JPEG", SkEncodedImageFormat::kJPEG);
.value("JPEG", SkEncodedImageFormat::kJPEG)
.value("WEBP", SkEncodedImageFormat::kWEBP);
enum_<SkPaint::Style>("PaintStyle")
.value("Fill", SkPaint::Style::kFill_Style)

View File

@ -191,6 +191,31 @@ if [[ $@ == *no_paragraph* ]] || [[ $@ == *primitive_shaper* ]] || [[ $@ == *no_
PARAGRAPH_BINDINGS=""
fi
DO_DECODE="true"
if [[ $@ == *no_codecs* ]]; then
echo "Omitting codecs"
DO_DECODE="false"
ENCODE_PNG="false"
ENCODE_JPEG="false"
ENCODE_WEBP="false"
else
ENCODE_PNG="true"
if [[ $@ == *no_encode_png* ]]; then
ENCODE_PNG="false"
fi
ENCODE_JPEG="false"
if [[ $@ == *force_encode_jpeg* ]]; then
ENCODE_JPEG="true"
fi
ENCODE_WEBP="false"
if [[ $@ == *force_encode_webp* ]]; then
ENCODE_WEBP="true"
fi
fi # no_codecs
# Turn off exiting while we check for ninja (which may not be on PATH)
set +e
@ -233,12 +258,12 @@ echo "Compiling bitcode"
skia_use_fontconfig=false \
skia_use_freetype=true \
skia_use_libheif=false \
skia_use_libjpeg_turbo_decode=true \
skia_use_libjpeg_turbo_encode=false \
skia_use_libpng_decode=true \
skia_use_libpng_encode=true \
skia_use_libwebp_decode=true \
skia_use_libwebp_encode=false \
skia_use_libjpeg_turbo_decode=${DO_DECODE} \
skia_use_libjpeg_turbo_encode=${ENCODE_JPEG} \
skia_use_libpng_decode=${DO_DECODE} \
skia_use_libpng_encode=${ENCODE_PNG} \
skia_use_libwebp_decode=${DO_DECODE} \
skia_use_libwebp_encode=${ENCODE_WEBP} \
skia_use_lua=false \
skia_use_piex=false \
skia_use_system_freetype2=false \