2020-01-06 13:10:05 +00:00
|
|
|
CanvasKit._extraInitializations = CanvasKit._extraInitializations || [];
|
|
|
|
CanvasKit._extraInitializations.push(function() {
|
2020-01-14 13:39:09 +00:00
|
|
|
// data is a TypedArray or ArrayBuffer e.g. from fetch().then(resp.arrayBuffer())
|
2020-10-07 20:09:22 +00:00
|
|
|
CanvasKit.MakePicture = function(data) {
|
2020-01-14 13:39:09 +00:00
|
|
|
data = new Uint8Array(data);
|
|
|
|
|
|
|
|
var iptr = CanvasKit._malloc(data.byteLength);
|
|
|
|
CanvasKit.HEAPU8.set(data, iptr);
|
2021-02-16 20:38:42 +00:00
|
|
|
// The skp takes ownership of the malloc'd data.
|
2020-10-07 20:09:22 +00:00
|
|
|
var pic = CanvasKit._MakePicture(iptr, data.byteLength);
|
2020-01-14 13:39:09 +00:00
|
|
|
if (!pic) {
|
2020-10-07 20:09:22 +00:00
|
|
|
Debug('Could not decode picture');
|
2020-01-14 13:39:09 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return pic;
|
2021-02-16 20:38:42 +00:00
|
|
|
};
|
2020-10-07 20:09:22 +00:00
|
|
|
});
|