Add glue to link the GrContext createCompressedBackendTexture API to the GL and Vulkan backends
Bug: skia:9680
Change-Id: I05230ec8fd4f9733ba868fd595b163a79c30d32a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261081
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 420e357..5e8a079 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -57,6 +57,34 @@
return caps->areColorTypeAndFormatCompatible(grCT, backendFormat);
}
+bool SkImage_GpuBase::ValidateCompressedBackendTexture(const GrCaps* caps,
+ const GrBackendTexture& tex,
+ SkAlphaType at) {
+
+ if (!tex.isValid() || tex.width() <= 0 || tex.height() <= 0) {
+ return false;
+ }
+
+ if (tex.width() > caps->maxTextureSize() || tex.height() > caps->maxTextureSize()) {
+ return false;
+ }
+
+ if (at == kUnknown_SkAlphaType) {
+ return false;
+ }
+
+ GrBackendFormat backendFormat = tex.getBackendFormat();
+ if (!backendFormat.isValid()) {
+ return false;
+ }
+
+ if (!caps->isFormatCompressed(backendFormat)) {
+ return false;
+ }
+
+ return true;
+}
+
//////////////////////////////////////////////////////////////////////////////////////////////////
bool SkImage_GpuBase::getROPixels(SkBitmap* dst, CachingHint chint) const {