a1e30a3a28
Also add some explanation to the image_sampling demo. Change-Id: Id20fe4d47c45b6a6b27e227871458bb862ec83d8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378936 Reviewed-by: Mike Reed <reed@google.com>
28 lines
879 B
JavaScript
28 lines
879 B
JavaScript
importScripts('https://unpkg.com/canvaskit-wasm@0.25.0/bin/full/canvaskit.js');
|
|
importScripts('shared.js');
|
|
|
|
const transferCanvasToOffscreenPromise =
|
|
new Promise((resolve) => addEventListener('message', resolve));
|
|
const canvasKitInitPromise =
|
|
CanvasKitInit({locateFile: (file) => 'https://unpkg.com/canvaskit-wasm@0.25.0/bin/full/'+file});
|
|
const skottieJsonPromise =
|
|
fetch('https://storage.googleapis.com/skia-cdn/misc/lego_loader.json')
|
|
.then((response) => response.text());
|
|
|
|
Promise.all([
|
|
transferCanvasToOffscreenPromise,
|
|
canvasKitInitPromise,
|
|
skottieJsonPromise
|
|
]).then(([
|
|
{ data: { offscreenCanvas } },
|
|
CanvasKit,
|
|
jsonStr
|
|
]) => {
|
|
const surface = CanvasKit.MakeWebGLCanvasSurface(offscreenCanvas, null);
|
|
if (!surface) {
|
|
throw 'Could not make canvas surface';
|
|
}
|
|
|
|
SkottieExample(CanvasKit, surface, jsonStr);
|
|
});
|