blob: 3a268422960c8d7a47b7bc5b7063f0537c6e6f7d [file] [log] [blame]
Kevin Lubick5b90b842018-10-17 07:57:18 -04001// Adds compile-time JS functions to augment the CanvasKit interface.
2// Specifically, anything that should only be on the GPU version of canvaskit.
3(function(CanvasKit){
4 CanvasKit._extraInitializations = CanvasKit._extraInitializations || [];
5 CanvasKit._extraInitializations.push(function() {
Kevin Lubick006a6f32018-10-19 14:34:34 -04006 CanvasKit.MakeCanvasSurface = function(htmlID) {
Kevin Lubick5b90b842018-10-17 07:57:18 -04007 var canvas = document.getElementById(htmlID);
8 if (!canvas) {
9 throw 'Canvas with id ' + htmlID + ' was not found';
10 }
11 // Maybe better to use clientWidth/height. See:
12 // https://webglfundamentals.org/webgl/lessons/webgl-anti-patterns.html
13 return this._getWebGLSurface(htmlID, canvas.width, canvas.height);
14 };
15
16 CanvasKit.SkSurface.prototype.flush = function() {
17 this._flush();
18 }
19
20 CanvasKit.SkSurface.prototype.dispose = function() {
21 this.delete();
22 }
23 });
24}(Module)); // When this file is loaded in, the high level object is "Module";