You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
samples/web/charts/canvaskit/profiling/canvaskit.js

22 lines
241 KiB

var CanvasKitInit = (() => {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(CanvasKitInit) {
CanvasKitInit = CanvasKitInit || {};
null;var Module=typeof CanvasKitInit!=="undefined"?CanvasKitInit:{};var objAssign=Object.assign;var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});function Debug(msg){}var IsDebug=false;(function(CanvasKit){CanvasKit._extraInitializations=CanvasKit._extraInitializations||[];CanvasKit._extraInitializations.push(function(){CanvasKit.MakeSWCanvasSurface=function(idOrElement){var canvas=idOrElement;if(canvas.tagName!=="CANVAS"){canvas=document.getElementById(idOrElement);if(!canvas){throw"Canvas with id "+idOrElement+" was not found"}}var surface=CanvasKit.MakeSurface(canvas.width,canvas.height);if(surface){surface._canvas=canvas}return surface};if(!CanvasKit.MakeCanvasSurface){CanvasKit.MakeCanvasSurface=CanvasKit.MakeSWCanvasSurface}CanvasKit.MakeSurface=function(width,height){var imageInfo={"width":width,"height":height,"colorType":CanvasKit.ColorType.RGBA_8888,"alphaType":CanvasKit.AlphaType.Unpremul,"colorSpace":CanvasKit.ColorSpace.SRGB};var pixelLen=width*height*4;var pixelPtr=CanvasKit._malloc(pixelLen);var surface=CanvasKit.Surface._makeRasterDirect(imageInfo,pixelPtr,width*4);if(surface){surface._canvas=null;surface._width=width;surface._height=height;surface._pixelLen=pixelLen;surface._pixelPtr=pixelPtr;surface.getCanvas().clear(CanvasKit.TRANSPARENT)}return surface};CanvasKit.MakeRasterDirectSurface=function(imageInfo,mallocObj,bytesPerRow){return CanvasKit.Surface._makeRasterDirect(imageInfo,mallocObj["byteOffset"],bytesPerRow)};CanvasKit.Surface.prototype.flush=function(dirtyRect){CanvasKit.setCurrentContext(this._context);this._flush();if(this._canvas){var pixels=new Uint8ClampedArray(CanvasKit.HEAPU8.buffer,this._pixelPtr,this._pixelLen);var imageData=new ImageData(pixels,this._width,this._height);if(!dirtyRect){this._canvas.getContext("2d").putImageData(imageData,0,0)}else{this._canvas.getContext("2d").putImageData(imageData,0,0,dirtyRect[0],dirtyRect[1],dirtyRect[2]-dirtyRect[0],dirtyRect[3]-dirtyRect[1])}}};CanvasKit.Surface.prototype.dispose=function(){if(this._pixelPtr){CanvasKit._free(this._pixelPtr)}this.delete()};CanvasKit.setCurrentContext=CanvasKit.setCurrentContext||function(){}})})(Module);(function(CanvasKit){CanvasKit._extraInitializations=CanvasKit._extraInitializations||[];CanvasKit._extraInitializations.push(function(){function get(obj,attr,defaultValue){if(obj&&obj.hasOwnProperty(attr)){return obj[attr]}return defaultValue}CanvasKit.GetWebGLContext=function(canvas,attrs){if(!canvas){throw"null canvas passed into makeWebGLContext"}var contextAttributes={"alpha":get(attrs,"alpha",1),"depth":get(attrs,"depth",1),"stencil":get(attrs,"stencil",8),"antialias":get(attrs,"antialias",0),"premultipliedAlpha":get(attrs,"premultipliedAlpha",1),"preserveDrawingBuffer":get(attrs,"preserveDrawingBuffer",0),"preferLowPowerToHighPerformance":get(attrs,"preferLowPowerToHighPerformance",0),"failIfMajorPerformanceCaveat":get(attrs,"failIfMajorPerformanceCaveat",0),"enableExtensionsByDefault":get(attrs,"enableExtensionsByDefault",1),"explicitSwapControl":get(attrs,"explicitSwapControl",0),"renderViaOffscreenBackBuffer":get(attrs,"renderViaOffscreenBackBuffer",0)};if(attrs&&attrs["majorVersion"]){contextAttributes["majorVersion"]=attrs["majorVersion"]}else{contextAttributes["majorVersion"]=typeof WebGL2RenderingContext!=="undefined"?2:1}if(contextAttributes["explicitSwapControl"]){throw"explicitSwapControl is not supported"}var handle=GL.createContext(canvas,contextAttributes);if(!handle){return 0}GL.makeContextCurrent(handle);return handle};CanvasKit.deleteContext=function(handle){GL.deleteContext(handle)};CanvasKit._setTextureCleanup({"deleteTexture":function(webglHandle,texHandle){var tex=GL.textures[texHandle];if(tex){GL.getContext(webglHandle).GLctx.deleteTexture(tex)}GL.textures[texHandle]=null}});CanvasKit.MakeGrContext=function(ctx){if(!this.setCurrentContext(ctx)){return null}var grCtx=this._MakeGrContext();if(!grCtx){return null}grCtx._context=ctx;return grCtx};CanvasKit.MakeOnScreenGLSurface=function(g
return CanvasKitInit.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = CanvasKitInit;
else if (typeof define === 'function' && define['amd'])
define([], function() { return CanvasKitInit; });
else if (typeof exports === 'object')
exports["CanvasKitInit"] = CanvasKitInit;