Kevin Lubick | 5b90b84 | 2018-10-17 07:57:18 -0400 | [diff] [blame] | 1 | // 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 Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 6 | CanvasKit.MakeCanvasSurface = function(htmlID) { |
Kevin Lubick | 5b90b84 | 2018-10-17 07:57:18 -0400 | [diff] [blame] | 7 | 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"; |