Add protected status to SkSurfaceCharacterization
Change-Id: I27bd051c1fce0239faff7fc073eaf82976fb63ae
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225940
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrContextThreadSafeProxy.cpp b/src/gpu/GrContextThreadSafeProxy.cpp
index 9a1a37a..5b00895 100644
--- a/src/gpu/GrContextThreadSafeProxy.cpp
+++ b/src/gpu/GrContextThreadSafeProxy.cpp
@@ -15,6 +15,10 @@
#include "src/gpu/GrSkSLFPFactoryCache.h"
#include "src/image/SkSurface_Gpu.h"
+#ifdef SK_VULKAN
+#include "src/gpu/vk/GrVkCaps.h"
+#endif
+
GrContextThreadSafeProxy::GrContextThreadSafeProxy(GrBackendApi backend,
const GrContextOptions& options,
uint32_t contextID)
@@ -33,7 +37,8 @@
const SkImageInfo& ii, const GrBackendFormat& backendFormat,
int sampleCnt, GrSurfaceOrigin origin,
const SkSurfaceProps& surfaceProps,
- bool isMipMapped, bool willUseGLFBO0, bool isTextureable) {
+ bool isMipMapped, bool willUseGLFBO0, bool isTextureable,
+ GrProtected isProtected) {
if (!backendFormat.isValid()) {
return SkSurfaceCharacterization(); // return an invalid characterization
}
@@ -73,6 +78,21 @@
return SkSurfaceCharacterization(); // return an invalid characterization
}
+ if (GrBackendApi::kVulkan == backendFormat.backend()) {
+ if (GrBackendApi::kVulkan != this->backend()) {
+ return SkSurfaceCharacterization(); // return an invalid characterization
+ }
+
+#ifdef SK_VULKAN
+ const GrVkCaps* vkCaps = (const GrVkCaps*) this->caps();
+
+ // The protection status of the characterization and the context need to match
+ if (isProtected != GrProtected(vkCaps->supportsProtectedMemory())) {
+ return SkSurfaceCharacterization(); // return an invalid characterization
+ }
+#endif
+ }
+
return SkSurfaceCharacterization(sk_ref_sp<GrContextThreadSafeProxy>(this),
cacheMaxResourceBytes, ii, backendFormat,
origin, sampleCnt,
@@ -80,6 +100,7 @@
SkSurfaceCharacterization::MipMapped(isMipMapped),
SkSurfaceCharacterization::UsesGLFBO0(willUseGLFBO0),
SkSurfaceCharacterization::VulkanSecondaryCBCompatible(false),
+ isProtected,
surfaceProps);
}