Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 19304d8

Browse files
Nathaniel NifongSkia Commit-Bot
authored andcommitted
Move all canvaskit example resources to CDN
Change-Id: I92c83051017648d5703b06daac77e99ff40aeb2e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/273000 Commit-Queue: Nathaniel Nifong <nifong@google.com> Reviewed-by: Kevin Lubick <kjlubick@google.com>
1 parent a64f5b2 commit 19304d8

File tree

8 files changed

+22
-20
lines changed

8 files changed

+22
-20
lines changed
-342 KB
Binary file not shown.
-123 KB
Binary file not shown.
-151 KB
Binary file not shown.
-176 KB
Binary file not shown.

modules/canvaskit/canvaskit/example.html

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
5757

5858
var bonesImageData = null;
5959
var mandrillData = null;
60+
var cdn = 'https://storage.googleapis.com/skia-cdn/misc/';
6061
CanvasKitInit({
6162
locateFile: (file) => '/node_modules/canvaskit/bin/'+file,
6263
}).ready().then((CK) => {
@@ -88,21 +89,21 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
8889
AtlasAPI1(CanvasKit, mandrillData);
8990
});
9091

91-
fetch('https://storage.googleapis.com/skia-cdn/misc/bones.jpg').then((resp) => {
92+
fetch(cdn + 'bones.jpg').then((resp) => {
9293
resp.arrayBuffer().then((buffer) => {
9394
bonesImageData = buffer;
9495
VertexAPI2(CanvasKit, bonesImageData);
9596
});
9697
});
9798

98-
fetch('./Roboto-Regular.woff').then((resp) => {
99+
fetch(cdn + 'Roboto-Regular.ttf').then((resp) => {
99100
resp.arrayBuffer().then((buffer) => {
100101
robotoData = buffer;
101102
DrawingExample(CanvasKit, robotoData);
102103
});
103104
});
104105

105-
fetch('./NotoSerif-Regular.ttf').then((resp) => {
106+
fetch(cdn + 'NotoSerif-Regular.ttf').then((resp) => {
106107
resp.arrayBuffer().then((buffer) => {
107108
notoserifData = buffer;
108109
TextShapingAPI1(CanvasKit, notoserifData);
@@ -111,7 +112,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
111112
});
112113

113114
// Mandrill test image
114-
fetch('./test.png').then((response) => response.arrayBuffer()).then((buffer) => {
115+
fetch(cdn + 'test.png').then((response) => response.arrayBuffer()).then((buffer) => {
115116
mandrillData = buffer;
116117
AtlasAPI1(CanvasKit, mandrillData);
117118
});
@@ -328,14 +329,14 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
328329
let skcanvas = CanvasKit.MakeCanvas(300, 300);
329330
let realCanvas = document.getElementById('api1_c');
330331

331-
let skPromise = fetch('./test.png')
332+
let skPromise = fetch(cdn + 'test.png')
332333
// if clients want to use a Blob, they are responsible
333334
// for reading it themselves.
334335
.then((response) => response.arrayBuffer())
335336
.then((buffer) => {
336337
skcanvas._img = skcanvas.decodeImage(buffer);
337338
});
338-
let realPromise = fetch('./test.png')
339+
let realPromise = fetch(cdn + 'test.png')
339340
.then((response) => response.blob())
340341
.then((blob) => createImageBitmap(blob))
341342
.then((bitmap) => {
@@ -711,14 +712,14 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
711712
let skcanvas = CanvasKit.MakeCanvas(300, 300);
712713
let realCanvas = document.getElementById('api7_c');
713714

714-
let skPromise = fetch('./test.png')
715+
let skPromise = fetch(cdn + 'test.png')
715716
// if clients want to use a Blob, they are responsible
716717
// for reading it themselves.
717718
.then((response) => response.arrayBuffer())
718719
.then((buffer) => {
719720
skcanvas._img = skcanvas.decodeImage(buffer);
720721
});
721-
let realPromise = fetch('./test.png')
722+
let realPromise = fetch(cdn + 'test.png')
722723
.then((response) => response.blob())
723724
.then((blob) => createImageBitmap(blob))
724725
.then((bitmap) => {

modules/canvaskit/canvaskit/extra.html

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ <h2> 3D perspective transformations </h2>
5454
var bonesImageData = null;
5555
var flightAnimGif = null;
5656
var skpData = null;
57+
var cdn = 'https://storage.googleapis.com/skia-cdn/misc/';
5758
const ckLoaded = CanvasKitInit({
5859
locateFile: (file) => '/node_modules/canvaskit/bin/'+file,
5960
}).ready();
@@ -78,36 +79,36 @@ <h2> 3D perspective transformations </h2>
7879
SkpExample(CanvasKit, skpData);
7980
});
8081

81-
fetch('https://storage.googleapis.com/skia-cdn/misc/lego_loader.json').then((resp) => {
82+
fetch(cdn + 'lego_loader.json').then((resp) => {
8283
resp.text().then((str) => {
8384
legoJSON = str;
8485
SkottieExample(CanvasKit, 'sk_legos', legoJSON,
8586
{fLeft: -50, fTop: 0, fRight: 350, fBottom: 300});
8687
});
8788
});
8889

89-
fetch('https://storage.googleapis.com/skia-cdn/misc/drinks.json').then((resp) => {
90+
fetch(cdn + 'drinks.json').then((resp) => {
9091
resp.text().then((str) => {
9192
drinksJSON = str;
9293
SkottieExample(CanvasKit, 'sk_drinks', drinksJSON, fullBounds);
9394
});
9495
});
9596

96-
fetch('https://storage.googleapis.com/skia-cdn/misc/confetti.json').then((resp) => {
97+
fetch(cdn + 'confetti.json').then((resp) => {
9798
resp.text().then((str) => {
9899
confettiJSON = str;
99100
SkottieExample(CanvasKit, 'sk_party', confettiJSON, fullBounds);
100101
});
101102
});
102103

103-
fetch('https://storage.googleapis.com/skia-cdn/misc/onboarding.json').then((resp) => {
104+
fetch(cdn + 'onboarding.json').then((resp) => {
104105
resp.text().then((str) => {
105106
onboardingJSON = str;
106107
SkottieExample(CanvasKit, 'sk_onboarding', onboardingJSON, fullBounds);
107108
});
108109
});
109110

110-
fetch('https://storage.googleapis.com/skia-cdn/misc/skottie_sample_multiframe.json').then((resp) => {
111+
fetch(cdn + 'skottie_sample_multiframe.json').then((resp) => {
111112
resp.text().then((str) => {
112113
multiFrameJSON = str;
113114
SkottieExample(CanvasKit, 'sk_animated_gif', multiFrameJSON, fullBounds, {
@@ -116,7 +117,7 @@ <h2> 3D perspective transformations </h2>
116117
});
117118
});
118119

119-
fetch('https://storage.googleapis.com/skia-cdn/misc/flightAnim.gif').then((resp) => {
120+
fetch(cdn + 'flightAnim.gif').then((resp) => {
120121
resp.arrayBuffer().then((buffer) => {
121122
flightAnimGif = buffer;
122123
SkottieExample(CanvasKit, 'sk_animated_gif', multiFrameJSON, fullBounds, {
@@ -125,22 +126,22 @@ <h2> 3D perspective transformations </h2>
125126
});
126127
});
127128

128-
fetch('./Roboto-Regular.ttf').then((resp) => {
129+
fetch(cdn + 'Roboto-Regular.ttf').then((resp) => {
129130
resp.arrayBuffer().then((buffer) => {
130131
robotoData = buffer;
131132
ParagraphAPI1(CanvasKit, robotoData);
132133
});
133134
});
134135

135-
fetch('./red_line.skp').then((response) => response.arrayBuffer()).then((buffer) => {
136+
fetch(cdn + 'red_line.skp').then((response) => response.arrayBuffer()).then((buffer) => {
136137
skpData = buffer;
137138
SkpExample(CanvasKit, skpData);
138139
});
139140

140-
const loadDog = fetch('https://storage.googleapis.com/skia-cdn/misc/dog.jpg').then((response) => response.arrayBuffer());
141-
const loadMandrill = fetch('https://storage.googleapis.com/skia-cdn/misc/mandrill_256.png').then((response) => response.arrayBuffer());
142-
const loadBrickTex = fetch('./brickwork-texture.jpg').then((response) => response.arrayBuffer());
143-
const loadBrickBump = fetch('./brickwork_normal-map.jpg').then((response) => response.arrayBuffer());
141+
const loadDog = fetch(cdn + 'dog.jpg').then((response) => response.arrayBuffer());
142+
const loadMandrill = fetch(cdn + 'mandrill_256.png').then((response) => response.arrayBuffer());
143+
const loadBrickTex = fetch(cdn + 'brickwork-texture.jpg').then((response) => response.arrayBuffer());
144+
const loadBrickBump = fetch(cdn + 'brickwork_normal-map.jpg').then((response) => response.arrayBuffer());
144145
Promise.all([ckLoaded, loadBrickTex, loadBrickBump]).then((results) => {Camera3D(...results)});
145146

146147
function SkottieExample(CanvasKit, id, jsonStr, bounds, assets) {
-173 Bytes
Binary file not shown.
-611 KB
Binary file not shown.

0 commit comments

Comments
 (0)