[canvaskit] remove POC Nima code
Now that drawVertices is exposed, no need to keep this around as a demo
Docs-Preview: https://skia.org/?cl=173994
Bug: skia:
Change-Id: I6293c8e2038ece27635d254db097e651c9d77a94
Reviewed-on: https://skia-review.googlesource.com/c/173994
Reviewed-by: Kevin Lubick <kjlubick@google.com>
diff --git a/experimental/canvaskit/canvaskit/example.html b/experimental/canvaskit/canvaskit/example.html
index 876e6d5..f388019 100644
--- a/experimental/canvaskit/canvaskit/example.html
+++ b/experimental/canvaskit/canvaskit/example.html
@@ -48,9 +48,6 @@
<!-- Doesn't work yet. -->
<button id=lego_btn>Take a picture of the legos</button>
-<h2> Nima </h2>
-
-<canvas id=nima_example width=300 height=300></canvas>
<script type="text/javascript" src="/node_modules/canvaskit/bin/canvaskit.js"></script>
@@ -90,8 +87,6 @@
SkottieExample(CanvasKit, 'sk_party', confettiJSON, fullBounds);
SkottieExample(CanvasKit, 'sk_onboarding', onboardingJSON, fullBounds);
- NimaExample(CanvasKit, nimaFile, nimaTexture);
-
CanvasAPI1(CanvasKit);
CanvasAPI2(CanvasKit);
CanvasAPI3(CanvasKit);
@@ -135,20 +130,6 @@
});
});
- fetch('https://storage.googleapis.com/skia-cdn/misc/robot.nima').then((resp) => {
- resp.arrayBuffer().then((buffer) => {
- nimaFile = buffer;
- NimaExample(CanvasKit, nimaFile, nimaTexture);
- });
- });
-
- fetch('https://storage.googleapis.com/skia-cdn/misc/robot.nima.png').then((resp) => {
- resp.arrayBuffer().then((arrayBuffer) => {
- nimaTexture = arrayBuffer;
- NimaExample(CanvasKit, nimaFile, nimaTexture);
- });
- });
-
fetch('https://storage.googleapis.com/skia-cdn/misc/bones.jpg').then((resp) => {
resp.arrayBuffer().then((buffer) => {
bonesImage = buffer;
@@ -742,42 +723,6 @@
document.getElementById('api6').src = skcanvas.toDataURL();
}
- function NimaExample(CanvasKit, nimaFile, nimaTexture) {
- if (!CanvasKit || !nimaFile || !nimaTexture) {
- return;
- }
- const animation = CanvasKit.MakeNimaActor(nimaFile, nimaTexture);
- if (!animation) {
- console.error('could not make animation');
- return;
- }
-
- const surface = CanvasKit.MakeCanvasSurface('nima_example');
- if (!surface) {
- console.error('Could not make surface');
- return;
- }
-
- const context = CanvasKit.currentContext();
- const canvas = surface.getCanvas();
- canvas.translate(125, 275);
- canvas.scale(0.4, -0.4);
-
- let firstFrame = Date.now();
- animation.setAnimationByName('attack');
-
- function drawFrame() {
- let seek = ((Date.now() - firstFrame) / 1000.0);
- CanvasKit.setCurrentContext(context);
- canvas.clear(CanvasKit.TRANSPARENT);
- animation.seek(seek);
- animation.render(canvas);
- surface.flush();
- window.requestAnimationFrame(drawFrame);
- }
- window.requestAnimationFrame(drawFrame);
- }
-
function VertexAPI1(CanvasKit) {
const surface = CanvasKit.MakeCanvasSurface('vertex1');
if (!surface) {
diff --git a/experimental/canvaskit/canvaskit_bindings.cpp b/experimental/canvaskit/canvaskit_bindings.cpp
index 24e37ac..83f8fb7 100644
--- a/experimental/canvaskit/canvaskit_bindings.cpp
+++ b/experimental/canvaskit/canvaskit_bindings.cpp
@@ -53,9 +53,6 @@
#include "SkottieUtils.h"
#endif // SK_INCLUDE_MANAGED_SKOTTIE
#endif // SK_INCLUDE_SKOTTIE
-#if SK_INCLUDE_NIMA
-#include "nima/NimaActor.h"
-#endif
#include <iostream>
#include <string>
@@ -988,34 +985,4 @@
#endif // SK_INCLUDE_MANAGED_SKOTTIE
#endif // SK_INCLUDE_SKOTTIE
-#if SK_INCLUDE_NIMA
- class_<NimaActor>("NimaActor")
- .function("duration", &NimaActor::duration)
- .function("getAnimationNames", optional_override([](NimaActor& self)->JSArray {
- JSArray names = emscripten::val::array();
- auto vNames = self.getAnimationNames();
- for (size_t i = 0; i < vNames.size(); i++) {
- names.call<void>("push", vNames[i]);
- }
- return names;
- }), allow_raw_pointers())
- .function("render", optional_override([](NimaActor& self, SkCanvas* canvas)->void {
- self.render(canvas, 0);
- }), allow_raw_pointers())
- .function("seek", &NimaActor::seek)
- .function("setAnimationByIndex", select_overload<void(uint8_t )>(&NimaActor::setAnimation))
- .function("setAnimationByName" , select_overload<void(std::string)>(&NimaActor::setAnimation));
-
- function("_MakeNimaActor", optional_override([](uintptr_t /* uint8_t* */ nptr, int nlen,
- uintptr_t /* uint8_t* */ tptr, int tlen)->NimaActor* {
- // See comment above for uintptr_t explanation
- const uint8_t* nimaBytes = reinterpret_cast<const uint8_t*>(nptr);
- const uint8_t* textureBytes = reinterpret_cast<const uint8_t*>(tptr);
-
- auto nima = SkData::MakeFromMalloc(nimaBytes, nlen);
- auto texture = SkData::MakeFromMalloc(textureBytes, tlen);
- return new NimaActor(nima, texture);
- }), allow_raw_pointers());
- constant("nima", true);
-#endif
}
diff --git a/experimental/canvaskit/compile.sh b/experimental/canvaskit/compile.sh
index 55de4b5..c4249a3 100755
--- a/experimental/canvaskit/compile.sh
+++ b/experimental/canvaskit/compile.sh
@@ -76,15 +76,6 @@
WASM_MANAGED_SKOTTIE="-DSK_INCLUDE_MANAGED_SKOTTIE=0"
fi
-GN_NIMA="skia_enable_nima=true"
-WASM_NIMA="-DSK_INCLUDE_NIMA=1 \
- experimental/nima/NimaActor.cpp"
-if [[ $@ == *no_nima* ]]; then
- echo "Omitting Nima"
- GN_NIMA="skia_enable_nima=false"
- WASM_NIMA="-DSK_INCLUDE_NIMA=0"
-fi
-
HTML_CANVAS_API="--pre-js $BASE_DIR/htmlcanvas/canvas2d.js"
if [[ $@ == *no_canvas* ]]; then
echo "Omitting bindings for HTML Canvas API"
@@ -139,7 +130,6 @@
skia_enable_ccpr=false \
skia_enable_nvpr=false \
skia_enable_skpicture=false \
- ${GN_NIMA} \
${GN_GPU} \
skia_enable_fontmgr_empty=false \
skia_enable_pdf=false"
@@ -178,8 +168,6 @@
-Isrc/utils/ \
-Itools \
-Itools/fonts \
- -I$BUILD_DIR/gen/third_party/Nima-Cpp/Nima-Cpp \
- -I$BUILD_DIR/gen/third_party/Nima-Cpp/Nima-Math-Cpp \
-DSK_DISABLE_READBUFFER \
-DSK_DISABLE_AAA \
-DSK_DISABLE_DAA \
@@ -192,7 +180,6 @@
$BASE_DIR/canvaskit_bindings.cpp \
tools/fonts/SkTestFontMgr.cpp \
tools/fonts/SkTestTypeface.cpp \
- $WASM_NIMA \
$WASM_SKOTTIE \
$WASM_MANAGED_SKOTTIE \
$BUILD_DIR/libskia.a \
diff --git a/experimental/canvaskit/externs.js b/experimental/canvaskit/externs.js
index b4e30a9..fec7b88 100644
--- a/experimental/canvaskit/externs.js
+++ b/experimental/canvaskit/externs.js
@@ -37,7 +37,6 @@
MakeImageFromEncoded: function() {},
/** @return {LinearCanvasGradient} */
MakeLinearGradientShader: function() {},
- MakeNimaActor: function() {},
MakeRadialGradientShader: function() {},
MakeSWCanvasSurface: function() {},
MakeSkDashPathEffect: function() {},
@@ -57,7 +56,6 @@
// in the pre-js file)
_MakeImageShader: function() {},
_MakeLinearGradientShader: function() {},
- _MakeNimaActor: function() {},
_MakeRadialGradientShader: function() {},
_MakeSkDashPathEffect: function() {},
_MakeSkVertices: function() {},
@@ -73,18 +71,6 @@
// Objects and properties on CanvasKit
- NimaActor: {
- // public API (from C++ bindings)
- duration: function() {},
- getAnimationNames: function() {},
- render: function() {},
- seek: function() {},
- setAnimationByIndex: function() {},
- setAnimationByName: function() {},
-
- // private API
- },
-
SkCanvas: {
// public API (from C++ bindings)
clear: function() {},
diff --git a/site/user/modules/canvaskit.md b/site/user/modules/canvaskit.md
index 590daf1..09d831e 100644
--- a/site/user/modules/canvaskit.md
+++ b/site/user/modules/canvaskit.md
@@ -87,12 +87,6 @@
<canvas id=sk_onboarding width=500 height=500></canvas>
</a>
- <h3>Nima (click for fiddle)</h3>
- <a href="https://jsfiddle.skia.org/canvaskit/8f72aa124b91d28c77ef38c849ad7b3b0a4c207010ecca6dccba2b273329895c"
- target=_blank rel=noopener>
- <canvas id=nima_robot width=300 height=300></canvas>
- </a>
-
</div>
<script type="text/javascript" charset="utf-8">
@@ -115,8 +109,6 @@
var drinksJSON = null;
var confettiJSON = null;
var onboardingJSON = null;
- var nimaFile = null;
- var nimaTexture = null;
var fullBounds = {fLeft: 0, fTop: 0, fRight: 500, fBottom: 500};
CanvasKitInit({
locateFile: (file) => locate_file + file,
@@ -131,8 +123,6 @@
SkottieExample(CanvasKit, 'sk_drinks', drinksJSON, fullBounds);
SkottieExample(CanvasKit, 'sk_party', confettiJSON, fullBounds);
SkottieExample(CanvasKit, 'sk_onboarding', onboardingJSON, fullBounds);
-
- NimaExample(CanvasKit, nimaFile, nimaTexture);
});
fetch('https://storage.googleapis.com/skia-cdn/misc/lego_loader.json').then((resp) => {
@@ -163,28 +153,6 @@
});
});
- fetch('https://storage.googleapis.com/skia-cdn/misc/robot.nima').then((resp) => {
- resp.blob().then((blob) => {
- let reader = new FileReader();
- reader.addEventListener('loadend', function() {
- nimaFile = reader.result;
- NimaExample(CanvasKit, nimaFile, nimaTexture);
- });
- reader.readAsArrayBuffer(blob);
- });
- });
-
- fetch('https://storage.googleapis.com/skia-cdn/misc/robot.nima.png').then((resp) => {
- resp.blob().then((blob) => {
- let reader = new FileReader();
- reader.addEventListener('loadend', function() {
- nimaTexture = reader.result;
- NimaExample(CanvasKit, nimaFile, nimaTexture);
- });
- reader.readAsArrayBuffer(blob);
- });
- });
-
function preventScrolling(canvas) {
canvas.addEventListener('touchmove', (e) => {
// Prevents touch events in the canvas from scrolling the canvas.
@@ -369,42 +337,6 @@
window.requestAnimationFrame(drawFrame);
//animation.delete();
}
-
- function NimaExample(CanvasKit, nimaFile, nimaTexture) {
- if (!CanvasKit || !nimaFile || !nimaTexture) {
- return;
- }
- const animation = CanvasKit.MakeNimaActor(nimaFile, nimaTexture);
- if (!animation) {
- console.error('could not make animation');
- return;
- }
-
- const surface = CanvasKit.MakeCanvasSurface('nima_robot');
- if (!surface) {
- console.error('Could not make surface');
- return;
- }
-
- const context = CanvasKit.currentContext();
- const canvas = surface.getCanvas();
- canvas.translate(125, 275);
- canvas.scale(0.4, -0.4);
-
- let firstFrame = Date.now();
- animation.setAnimationByName('attack');
-
- function drawFrame() {
- let seek = ((Date.now() - firstFrame) / 1000.0);
- CanvasKit.setCurrentContext(context);
- canvas.clear(CanvasKit.Color(255, 255, 255, 0.0));
- animation.seek(seek);
- animation.render(canvas);
- surface.flush();
- window.requestAnimationFrame(drawFrame);
- }
- window.requestAnimationFrame(drawFrame);
- }
}
document.head.appendChild(s);
})();
@@ -416,10 +348,6 @@
[Confetti](https://www.lottiefiles.com/1370-confetti),
[Onboarding](https://www.lottiefiles.com/1134-onboarding-1)
-Nima files courtesy of 2dimensions.com:
-[Robot](https://www.2dimensions.com/s/281-robot)
-
-
Test server
-----------
Test your code on our [CanvasKit Fiddle](https://jsfiddle.skia.org/canvaskit)