From 9279798022a028e9da82db9d9ca593949c883bbf Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Mon, 24 Feb 2020 10:00:20 -0500 Subject: [PATCH] [canvaskit] Expose releaseResourcesAndAbandonContext on GrContext Bug: skia:9910 Change-Id: If0a6aa106d42c680f1f0f3092c4a4dbd0f04c937 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270936 Reviewed-by: Nathaniel Nifong --- modules/canvaskit/CHANGELOG.md | 1 + modules/canvaskit/canvaskit_bindings.cpp | 1 + modules/canvaskit/externs.js | 1 + 3 files changed, 3 insertions(+) diff --git a/modules/canvaskit/CHANGELOG.md b/modules/canvaskit/CHANGELOG.md index 5fd4a660ca..17dc02e1e6 100644 --- a/modules/canvaskit/CHANGELOG.md +++ b/modules/canvaskit/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Experimental 4x4 matrices added in `SkM44`. - Vector math functions added in `SkVector`. - `SkRuntimeEffect.makeShaderWithChildren`, which can take in other shaders as fragmentProcessors. + - `GrContext.releaseResourcesAndAbandonContext` to free up WebGL contexts. ### Changed - We now compile/ship with Emscripten v1.39.6. diff --git a/modules/canvaskit/canvaskit_bindings.cpp b/modules/canvaskit/canvaskit_bindings.cpp index 1fe8becc1d..047ecf3340 100644 --- a/modules/canvaskit/canvaskit_bindings.cpp +++ b/modules/canvaskit/canvaskit_bindings.cpp @@ -900,6 +900,7 @@ EMSCRIPTEN_BINDINGS(Skia) { self.getResourceCacheUsage(&usedResources, &currUsage); return currUsage; })) + .function("releaseResourcesAndAbandonContext", &GrContext::releaseResourcesAndAbandonContext) .function("setResourceCacheLimitBytes", optional_override([](GrContext& self, size_t maxResourceBytes)->void { int maxResources = 0; size_t currMax = 0; // ignored diff --git a/modules/canvaskit/externs.js b/modules/canvaskit/externs.js index 9ceadaa3cc..158de8b4a1 100644 --- a/modules/canvaskit/externs.js +++ b/modules/canvaskit/externs.js @@ -105,6 +105,7 @@ var CanvasKit = { // public API (from C++ bindings) getResourceCacheLimitBytes: function() {}, getResourceCacheUsageBytes: function() {}, + releaseResourcesAndAbandonContext: function() {}, setResourceCacheLimitBytes: function() {}, },