Add internal calls for updateCompressedBackendTexture.
This splits the creation and the updating of backend compressed textures
below the public API level. In a follow on change I will add the public
api call to updateCompressedBackendTexture.
Bug: chromium:1099255
Change-Id: Ie410cfb42046d0e0c8f4fe60055be5782f811d47
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301577
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 35f34f4..3a8b661 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -695,6 +695,30 @@
//////////////////////////////////////////////////////////////////////////////
+static GrBackendTexture create_and_update_compressed_backend_texture(
+ GrContext* context,
+ SkISize dimensions,
+ const GrBackendFormat& backendFormat,
+ GrMipMapped mipMapped,
+ GrProtected isProtected,
+ sk_sp<GrRefCntedCallback> finishedCallback,
+ const GrGpu::BackendTextureData* data) {
+ GrGpu* gpu = context->priv().getGpu();
+
+ GrBackendTexture beTex = gpu->createCompressedBackendTexture(dimensions, backendFormat,
+ mipMapped, isProtected);
+ if (!beTex.isValid()) {
+ return {};
+ }
+
+ if (!context->priv().getGpu()->updateCompressedBackendTexture(
+ beTex, std::move(finishedCallback), data)) {
+ context->deleteBackendTexture(beTex);
+ return {};
+ }
+ return beTex;
+}
+
GrBackendTexture GrContext::createCompressedBackendTexture(int width, int height,
const GrBackendFormat& backendFormat,
const SkColor4f& color,
@@ -717,9 +741,9 @@
}
GrGpu::BackendTextureData data(color);
- return fGpu->createCompressedBackendTexture({width, height}, backendFormat,
- mipMapped, isProtected, std::move(finishedCallback),
- &data);
+ return create_and_update_compressed_backend_texture(this, {width, height}, backendFormat,
+ mipMapped, isProtected,
+ std::move(finishedCallback), &data);
}
GrBackendTexture GrContext::createCompressedBackendTexture(int width, int height,
@@ -759,9 +783,9 @@
}
GrGpu::BackendTextureData data(compressedData, dataSize);
- return fGpu->createCompressedBackendTexture({width, height}, backendFormat,
- mipMapped, isProtected, std::move(finishedCallback),
- &data);
+ return create_and_update_compressed_backend_texture(this, {width, height}, backendFormat,
+ mipMapped, isProtected,
+ std::move(finishedCallback), &data);
}
GrBackendTexture GrContext::createCompressedBackendTexture(int width, int height,