File tree Expand file tree Collapse file tree 5 files changed +15
-2
lines changed Expand file tree Collapse file tree 5 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
99### Added
1010 - ` getImageInfo() ` and ` getColorSpace() ` to the ` Image ` type.
11+ - ` CanvasKit.deleteContext ` for deleting WebGL contexts when done with them, resizing, etc.
1112
1213### Breaking
1314 - ` Path.addPoly() ` no longer accepts a 2d array of points, but a flattened 1d array.
Original file line number Diff line number Diff line change @@ -344,6 +344,7 @@ function fontMgrTests(CK: CanvasKit) {
344344function globalTests ( CK : CanvasKit ) {
345345 const ctx = CK . currentContext ( ) ;
346346 CK . setCurrentContext ( ctx ) ;
347+ CK . deleteContext ( ctx ) ;
347348 const n = CK . getDecodeCacheLimitBytes ( ) ;
348349 const u = CK . getDecodeCacheUsedBytes ( ) ;
349350 CK . setDecodeCacheLimitBytes ( 1000 ) ;
Original file line number Diff line number Diff line change @@ -263,6 +263,12 @@ export interface CanvasKit {
263263 */
264264 setCurrentContext ( ctx : WebGLContextHandle ) : void ;
265265
266+ /**
267+ * Deletes the associated WebGLContext. Function not available on the CPU version.
268+ * @param ctx
269+ */
270+ deleteContext ( ctx : WebGLContextHandle ) : void ;
271+
266272 /**
267273 * Returns the max size of the global cache for bitmaps used by CanvasKit.
268274 */
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ var CanvasKit = {
6262 Free : function ( ) { } ,
6363 computeTonalColors : function ( ) { } ,
6464 currentContext : function ( ) { } ,
65+ deleteContext : function ( ) { } ,
6566 getColorComponents : function ( ) { } ,
6667 getDecodeCacheLimitBytes : function ( ) { } ,
6768 getDecodeCacheUsageBytes : function ( ) { } ,
@@ -72,7 +73,7 @@ var CanvasKit = {
7273 setDecodeCacheLimitBytes : function ( ) { } ,
7374
7475 // Defined by emscripten.
75- createContext :function ( ) { } ,
76+ createContext : function ( ) { } ,
7677
7778 // private API (i.e. things declared in the bindings that we use
7879 // in the pre-js file)
Original file line number Diff line number Diff line change 4848 }
4949 GL . makeContextCurrent ( handle ) ;
5050 return handle ;
51- }
51+ } ;
52+
53+ CanvasKit . deleteContext = function ( handle ) {
54+ GL . deleteContext ( handle ) ;
55+ } ;
5256
5357 // idOrElement can be of types:
5458 // - String - in which case it is interpreted as an id of a
You can’t perform that action at this time.
0 commit comments