Expose ManagedBackendTexture from BackendTextureImageFactory.
Add helper to create self-managed BackendTexture-backed SkSurface for
tests using MBET.
GrGpu::createTestingOnlyBackendRenderTarget supports protected.
Make SkSurfaceCharacterization tests use self-managed SkSurface
factories and a use case of MakeFromBackendTextureAsRenderTarget is
removed.
Use self-managed BackendTexture-backed SkSurface factory in DM sinks and
in fm.
Bug: skia:9832
Change-Id: I0c1dc49697f8b3c942864e18b9112a3552f431ba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323559
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/tools/gpu/ManagedBackendTexture.cpp b/tools/gpu/ManagedBackendTexture.cpp
new file mode 100644
index 0000000..8409caa
--- /dev/null
+++ b/tools/gpu/ManagedBackendTexture.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "tools/gpu/ManagedBackendTexture.h"
+
+namespace sk_gpu_test {
+
+void ManagedBackendTexture::ReleaseProc(void* context) {
+ static_cast<ManagedBackendTexture*>(context)->unref();
+}
+
+ManagedBackendTexture::~ManagedBackendTexture() {
+ if (fDContext && fTexture.isValid()) {
+ fDContext->deleteBackendTexture(fTexture);
+ }
+}
+
+void* ManagedBackendTexture::releaseContext() {
+ this->ref();
+ return static_cast<void*>(this);
+}
+
+} // namespace sk_gpu_test