Fixup unit tests for Protected Vulkan
Since we're enabling Protectedness testing in Vulkan (for both Ganesh and Graphite) a lot of the Ganesh tests needs some updating.
Bug: b/237108194
Change-Id: I0dba1dcebe4a9f8921e6dfa9ee819bbf0b99920d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/789417
Reviewed-by: Nicolette Prevost <[email protected]>
Commit-Queue: Robert Phillips <[email protected]>
diff --git a/tests/BackendAllocationTest.cpp b/tests/BackendAllocationTest.cpp
index 9e1f973..58a533c 100644
--- a/tests/BackendAllocationTest.cpp
+++ b/tests/BackendAllocationTest.cpp
@@ -596,9 +596,13 @@
///////////////////////////////////////////////////////////////////////////////
void color_type_backend_allocation_test(const sk_gpu_test::ContextInfo& ctxInfo,
skiatest::Reporter* reporter) {
+ using namespace skgpu;
+
auto context = ctxInfo.directContext();
const GrCaps* caps = context->priv().caps();
+ Protected isProtected = Protected(caps->supportsProtectedContent());
+
constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f };
constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 0.75f };
@@ -653,8 +657,8 @@
continue;
}
- for (auto mipmapped : {skgpu::Mipmapped::kNo, skgpu::Mipmapped::kYes}) {
- if (skgpu::Mipmapped::kYes == mipmapped && !caps->mipmapSupport()) {
+ for (auto mipmapped : { Mipmapped::kNo, Mipmapped::kYes}) {
+ if (Mipmapped::kYes == mipmapped && !caps->mipmapSupport()) {
continue;
}
@@ -672,15 +676,15 @@
}
{
- auto uninitCreateMtd = [colorType](GrDirectContext* dContext,
- skgpu::Mipmapped mipmapped,
- GrRenderable renderable) {
+ auto uninitCreateMtd = [&](GrDirectContext* dContext,
+ Mipmapped mipmapped,
+ GrRenderable renderable) {
auto mbet = ManagedBackendTexture::MakeWithoutData(dContext,
32, 32,
colorType,
mipmapped,
renderable,
- GrProtected::kNo);
+ isProtected);
check_vk_tiling(mbet->texture());
#ifdef SK_DEBUG
{
@@ -698,17 +702,17 @@
}
{
- auto createWithColorMtd = [colorType](GrDirectContext* dContext,
- const SkColor4f& color,
- skgpu::Mipmapped mipmapped,
- GrRenderable renderable) {
+ auto createWithColorMtd = [&](GrDirectContext* dContext,
+ const SkColor4f& color,
+ Mipmapped mipmapped,
+ GrRenderable renderable) {
auto mbet = ManagedBackendTexture::MakeWithData(dContext,
32, 32,
colorType,
color,
mipmapped,
renderable,
- GrProtected::kNo);
+ isProtected);
check_vk_tiling(mbet->texture());
#ifdef SK_DEBUG
@@ -727,18 +731,18 @@
}
for (auto origin : {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
- auto createWithSrcDataMtd = [](GrDirectContext* dContext,
- const SkPixmap srcData[],
- int numLevels,
- GrSurfaceOrigin origin,
- GrRenderable renderable) {
+ auto createWithSrcDataMtd = [&](GrDirectContext* dContext,
+ const SkPixmap srcData[],
+ int numLevels,
+ GrSurfaceOrigin origin,
+ GrRenderable renderable) {
SkASSERT(srcData && numLevels);
auto mbet = ManagedBackendTexture::MakeWithData(dContext,
srcData,
numLevels,
origin,
renderable,
- GrProtected::kNo);
+ isProtected);
check_vk_tiling(mbet->texture());
#ifdef SK_DEBUG
{
@@ -951,9 +955,13 @@
reporter,
ctxInfo,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
auto context = ctxInfo.directContext();
const GrVkCaps* vkCaps = static_cast<const GrVkCaps*>(context->priv().caps());
+ Protected isProtected = Protected(vkCaps->supportsProtectedContent());
+
constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f };
constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 1 };
@@ -1010,8 +1018,8 @@
GrBackendFormat format = GrBackendFormats::MakeVk(combo.fFormat);
- for (auto mipmapped : {skgpu::Mipmapped::kNo, skgpu::Mipmapped::kYes}) {
- if (skgpu::Mipmapped::kYes == mipmapped && !vkCaps->mipmapSupport()) {
+ for (auto mipmapped : { Mipmapped::kNo, Mipmapped::kYes }) {
+ if (Mipmapped::kYes == mipmapped && !vkCaps->mipmapSupport()) {
continue;
}
@@ -1027,15 +1035,15 @@
}
{
- auto uninitCreateMtd = [format](GrDirectContext* dContext,
- skgpu::Mipmapped mipmapped,
- GrRenderable renderable) {
+ auto uninitCreateMtd = [&](GrDirectContext* dContext,
+ Mipmapped mipmapped,
+ GrRenderable renderable) {
auto mbet = ManagedBackendTexture::MakeWithoutData(dContext,
32, 32,
format,
mipmapped,
renderable,
- GrProtected::kNo);
+ isProtected);
check_vk_tiling(mbet->texture());
return mbet;
};
@@ -1053,34 +1061,34 @@
// Ideally we'd update our validation code to use a "raw" read that doesn't
// impose a color type but for now we just munge the data we upload to match the
// expectation.
- skgpu::Swizzle swizzle;
+ Swizzle swizzle;
switch (combo.fColorType) {
case GrColorType::kAlpha_8:
SkASSERT(combo.fFormat == VK_FORMAT_R8_UNORM);
- swizzle = skgpu::Swizzle("aaaa");
+ swizzle = Swizzle("aaaa");
break;
case GrColorType::kAlpha_16:
SkASSERT(combo.fFormat == VK_FORMAT_R16_UNORM);
- swizzle = skgpu::Swizzle("aaaa");
+ swizzle = Swizzle("aaaa");
break;
case GrColorType::kAlpha_F16:
SkASSERT(combo.fFormat == VK_FORMAT_R16_SFLOAT);
- swizzle = skgpu::Swizzle("aaaa");
+ swizzle = Swizzle("aaaa");
break;
case GrColorType::kABGR_4444:
if (combo.fFormat == VK_FORMAT_B4G4R4A4_UNORM_PACK16) {
- swizzle = skgpu::Swizzle("bgra");
+ swizzle = Swizzle("bgra");
}
break;
default:
- swizzle = skgpu::Swizzle("rgba");
+ swizzle = Swizzle("rgba");
break;
}
- auto createWithColorMtd = [format, swizzle](GrDirectContext* dContext,
- const SkColor4f& color,
- skgpu::Mipmapped mipmapped,
- GrRenderable renderable) {
+ auto createWithColorMtd = [&](GrDirectContext* dContext,
+ const SkColor4f& color,
+ Mipmapped mipmapped,
+ GrRenderable renderable) {
auto swizzledColor = swizzle.applyTo(color);
auto mbet = ManagedBackendTexture::MakeWithData(dContext,
32, 32,
@@ -1088,7 +1096,7 @@
swizzledColor,
mipmapped,
renderable,
- GrProtected::kNo);
+ isProtected);
check_vk_tiling(mbet->texture());
return mbet;
};
diff --git a/tests/BackendSurfaceMutableStateTest.cpp b/tests/BackendSurfaceMutableStateTest.cpp
index 69cbe73..cd1a7a1 100644
--- a/tests/BackendSurfaceMutableStateTest.cpp
+++ b/tests/BackendSurfaceMutableStateTest.cpp
@@ -46,11 +46,15 @@
reporter,
ctxInfo,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
auto dContext = ctxInfo.directContext();
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
GrBackendFormat format = GrBackendFormats::MakeVk(VK_FORMAT_R8G8B8A8_UNORM);
GrBackendTexture backendTex = dContext->createBackendTexture(
- 32, 32, format, skgpu::Mipmapped::kNo, GrRenderable::kNo, GrProtected::kNo);
+ 32, 32, format, Mipmapped::kNo, GrRenderable::kNo, isProtected);
REPORTER_ASSERT(reporter, backendTex.isValid());
@@ -58,7 +62,7 @@
REPORTER_ASSERT(reporter, GrBackendTextures::GetVkImageInfo(backendTex, &info));
VkImageLayout initLayout = info.fImageLayout;
uint32_t initQueue = info.fCurrentQueueFamily;
- skgpu::MutableTextureState initState(initLayout, initQueue);
+ MutableTextureState initState(initLayout, initQueue);
// Verify that setting that state via a copy of a backendTexture is reflected in all the
// backendTextures.
@@ -67,8 +71,7 @@
REPORTER_ASSERT(reporter, initLayout == info.fImageLayout);
REPORTER_ASSERT(reporter, initQueue == info.fCurrentQueueFamily);
- skgpu::MutableTextureState newState(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
- VK_QUEUE_FAMILY_IGNORED);
+ MutableTextureState newState(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_QUEUE_FAMILY_IGNORED);
backendTexCopy.setMutableState(newState);
REPORTER_ASSERT(reporter, GrBackendTextures::GetVkImageInfo(backendTex, &info));
@@ -138,7 +141,7 @@
// real transitions to the image so we need to be careful about doing actual valid transitions.
GrVkGpu* gpu = static_cast<GrVkGpu*>(dContext->priv().getGpu());
- skgpu::MutableTextureState previousState;
+ MutableTextureState previousState;
dContext->setBackendTextureState(backendTex, newState, &previousState);
@@ -147,19 +150,19 @@
REPORTER_ASSERT(reporter, gpu->queueIndex() == info.fCurrentQueueFamily);
REPORTER_ASSERT(reporter, previousState.isValid());
- REPORTER_ASSERT(reporter, previousState.backend() == skgpu::BackendApi::kVulkan);
+ REPORTER_ASSERT(reporter, previousState.backend() == BackendApi::kVulkan);
REPORTER_ASSERT(reporter, GetVkImageLayout(previousState) == initLayout);
REPORTER_ASSERT(reporter, GetVkQueueFamilyIndex(previousState) == initQueue);
// Make sure passing in VK_IMAGE_LAYOUT_UNDEFINED does not change the layout
- skgpu::MutableTextureState noopState(VK_IMAGE_LAYOUT_UNDEFINED, VK_QUEUE_FAMILY_IGNORED);
+ MutableTextureState noopState(VK_IMAGE_LAYOUT_UNDEFINED, VK_QUEUE_FAMILY_IGNORED);
dContext->setBackendTextureState(backendTex, noopState, &previousState);
REPORTER_ASSERT(reporter, GrBackendTextures::GetVkImageInfo(backendTex, &info));
REPORTER_ASSERT(reporter, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL == info.fImageLayout);
REPORTER_ASSERT(reporter, gpu->queueIndex() == info.fCurrentQueueFamily);
REPORTER_ASSERT(reporter, previousState.isValid());
- REPORTER_ASSERT(reporter, previousState.backend() == skgpu::BackendApi::kVulkan);
+ REPORTER_ASSERT(reporter, previousState.backend() == BackendApi::kVulkan);
REPORTER_ASSERT(reporter,
GetVkImageLayout(previousState) == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
REPORTER_ASSERT(reporter, GetVkQueueFamilyIndex(previousState) == gpu->queueIndex());
@@ -167,7 +170,7 @@
// To test queue transitions, we don't have any other valid queue available so instead we try
// to transition to external queue.
if (gpu->vkCaps().supportsExternalMemory()) {
- skgpu::MutableTextureState externalState(VK_IMAGE_LAYOUT_GENERAL, VK_QUEUE_FAMILY_EXTERNAL);
+ MutableTextureState externalState(VK_IMAGE_LAYOUT_GENERAL, VK_QUEUE_FAMILY_EXTERNAL);
dContext->setBackendTextureState(backendTex, externalState, &previousState);
@@ -176,7 +179,7 @@
REPORTER_ASSERT(reporter, VK_QUEUE_FAMILY_EXTERNAL == info.fCurrentQueueFamily);
REPORTER_ASSERT(reporter, previousState.isValid());
- REPORTER_ASSERT(reporter, previousState.backend() == skgpu::BackendApi::kVulkan);
+ REPORTER_ASSERT(reporter, previousState.backend() == BackendApi::kVulkan);
REPORTER_ASSERT(reporter,
GetVkImageLayout(previousState) == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
REPORTER_ASSERT(reporter, GetVkQueueFamilyIndex(previousState) == gpu->queueIndex());
@@ -185,7 +188,7 @@
// Go back to the initial queue. Also we should stay in VK_IMAGE_LAYOUT_GENERAL since we
// are passing in VK_IMAGE_LAYOUT_UNDEFINED
- skgpu::MutableTextureState externalState2(VK_IMAGE_LAYOUT_UNDEFINED, initQueue);
+ MutableTextureState externalState2(VK_IMAGE_LAYOUT_UNDEFINED, initQueue);
dContext->setBackendTextureState(backendTex, externalState2, &previousState);
REPORTER_ASSERT(reporter, GrBackendTextures::GetVkImageInfo(backendTex, &info));
@@ -193,7 +196,7 @@
REPORTER_ASSERT(reporter, gpu->queueIndex() == info.fCurrentQueueFamily);
REPORTER_ASSERT(reporter, previousState.isValid());
- REPORTER_ASSERT(reporter, previousState.backend() == skgpu::BackendApi::kVulkan);
+ REPORTER_ASSERT(reporter, previousState.backend() == BackendApi::kVulkan);
REPORTER_ASSERT(reporter, GetVkImageLayout(previousState) == VK_IMAGE_LAYOUT_GENERAL);
REPORTER_ASSERT(reporter, GetVkQueueFamilyIndex(previousState) == VK_QUEUE_FAMILY_EXTERNAL);
}
diff --git a/tests/BulkRectTest.cpp b/tests/BulkRectTest.cpp
index c1045ad..a775b41 100644
--- a/tests/BulkRectTest.cpp
+++ b/tests/BulkRectTest.cpp
@@ -66,8 +66,12 @@
}
static sk_sp<GrSurfaceProxy> create_proxy(GrRecordingContext* rContext) {
+ using namespace skgpu;
+
static constexpr SkISize kDimensions = {128, 128};
+ Protected isProtected = Protected(rContext->priv().caps()->supportsProtectedContent());
+
const GrBackendFormat format = rContext->priv().caps()->getDefaultBackendFormat(
GrColorType::kRGBA_8888,
GrRenderable::kYes);
@@ -75,10 +79,10 @@
kDimensions,
GrRenderable::kYes,
1,
- skgpu::Mipmapped::kNo,
+ Mipmapped::kNo,
SkBackingFit::kExact,
- skgpu::Budgeted::kNo,
- GrProtected::kNo,
+ Budgeted::kNo,
+ isProtected,
/*label=*/"CreateSurfaceProxy",
GrInternalSurfaceFlags::kNone);
}
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp
index 501bbb7..f5ecf62 100644
--- a/tests/DeferredDisplayListTest.cpp
+++ b/tests/DeferredDisplayListTest.cpp
@@ -1053,10 +1053,14 @@
reporter,
ctxInfo,
CtsEnforcement::kNever) {
+ using namespace skgpu;
+
auto dContext = ctxInfo.directContext();
size_t maxResourceBytes = dContext->getResourceCacheLimit();
auto proxy = dContext->threadSafeProxy().get();
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
auto check_create_fails = [proxy, reporter, maxResourceBytes](
const GrBackendFormat& backendFormat,
int width,
@@ -1064,7 +1068,7 @@
SkColorType ct,
bool willUseGLFBO0,
bool isTextureable,
- skgpu::Protected prot,
+ Protected prot,
bool vkRTSupportsInputAttachment,
bool forVulkanSecondaryCommandBuffer) {
const SkSurfaceProps surfaceProps(0x0, kRGB_H_SkPixelGeometry);
@@ -1079,7 +1083,7 @@
1,
kBottomLeft_GrSurfaceOrigin,
surfaceProps,
- skgpu::Mipmapped::kNo,
+ Mipmapped::kNo,
willUseGLFBO0,
isTextureable,
prot,
@@ -1119,47 +1123,42 @@
// In each of the check_create_fails calls there is one bad parameter that should cause the
// creation of the characterization to fail.
check_create_fails(goodBackendFormat, goodWidth, badHeights[0], kGoodCT, kGoodUseFBO0,
- kIsTextureable, skgpu::Protected::kNo, kGoodVkInputAttachment, kGoodForVkSCB);
+ kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
check_create_fails(goodBackendFormat, goodWidth, badHeights[1], kGoodCT, kGoodUseFBO0,
- kIsTextureable, skgpu::Protected::kNo, kGoodVkInputAttachment, kGoodForVkSCB);
+ kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
check_create_fails(goodBackendFormat, badWidths[0], goodHeight, kGoodCT, kGoodUseFBO0,
- kIsTextureable, skgpu::Protected::kNo, kGoodVkInputAttachment, kGoodForVkSCB);
+ kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
check_create_fails(goodBackendFormat, badWidths[1], goodHeight, kGoodCT, kGoodUseFBO0,
- kIsTextureable, skgpu::Protected::kNo, kGoodVkInputAttachment, kGoodForVkSCB);
+ kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
check_create_fails(badBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
- kIsTextureable, skgpu::Protected::kNo, kGoodVkInputAttachment, kGoodForVkSCB);
+ kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
check_create_fails(goodBackendFormat, goodWidth, goodHeight, kBadCT, kGoodUseFBO0,
- kIsTextureable, skgpu::Protected::kNo, kGoodVkInputAttachment, kGoodForVkSCB);
+ kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
// This fails because we always try to make a characterization that is textureable and we can't
// have UseFBO0 be true and textureable.
check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kBadUseFBO0,
- kIsTextureable, skgpu::Protected::kNo, kGoodVkInputAttachment, kGoodForVkSCB);
+ kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
if (dContext->backend() == GrBackendApi::kVulkan) {
- // The bad parameter in this case is the skgpu::Protected::kYes since none of our test contexts
- // are made protected we can't have a protected surface.
- check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
- kIsTextureable, skgpu::Protected::kYes, kGoodVkInputAttachment,
- kGoodForVkSCB);
// The following fails because forVulkanSecondaryCommandBuffer is true and
// isTextureable is true. This is not a legal combination.
check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
- kIsTextureable, skgpu::Protected::kNo, kGoodVkInputAttachment, kBadForVkSCB);
+ kIsTextureable, isProtected, kGoodVkInputAttachment, kBadForVkSCB);
// The following fails because forVulkanSecondaryCommandBuffer is true and
// vkRTSupportsInputAttachment is true. This is not a legal combination.
check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
- kIsNotTextureable, skgpu::Protected::kNo, kBadVkInputAttachment,
+ kIsNotTextureable, isProtected, kBadVkInputAttachment,
kBadForVkSCB);
// The following fails because forVulkanSecondaryCommandBuffer is true and
// willUseGLFBO0 is true. This is not a legal combination.
check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kBadUseFBO0,
- kIsNotTextureable, skgpu::Protected::kNo, kGoodVkInputAttachment,
+ kIsNotTextureable, isProtected, kGoodVkInputAttachment,
kBadForVkSCB);
} else {
// The following set vulkan only flags on non vulkan backends.
check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
- kIsTextureable, skgpu::Protected::kNo, kBadVkInputAttachment, kGoodForVkSCB);
+ kIsTextureable, isProtected, kBadVkInputAttachment, kGoodForVkSCB);
check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
- kIsNotTextureable, skgpu::Protected::kNo, kGoodVkInputAttachment,
+ kIsNotTextureable, isProtected, kGoodVkInputAttachment,
kBadForVkSCB);
}
}
@@ -1188,15 +1187,22 @@
reporter,
ctxInfo,
CtsEnforcement::kNever) {
+ using namespace skgpu;
+
auto context = ctxInfo.directContext();
+ Protected isProtected = Protected(context->priv().caps()->supportsProtectedContent());
+
SkImageInfo ii = SkImageInfo::Make(32, 32, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> s = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, ii);
+ sk_sp<SkSurface> s = SkSurfaces::RenderTarget(context, Budgeted::kNo, ii);
GrSurfaceCharacterization characterization;
SkAssertResult(s->characterize(&characterization));
- auto mbet = sk_gpu_test::ManagedBackendTexture::MakeFromInfo(context, ii);
+ auto mbet = sk_gpu_test::ManagedBackendTexture::MakeFromInfo(context, ii,
+ Mipmapped::kNo,
+ Renderable::kNo,
+ isProtected);
if (!mbet) {
ERRORF(reporter, "Could not make texture.");
return;
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index 3275165..d89371a 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -236,7 +236,6 @@
//TestReadPixels(reporter, context0, surfaceContext.get(), pixels.get(), "EGLImageTest-read");
- SkDebugf("type: %d\n", (int)surfaceContext->asTextureProxy()->textureType());
// We should not be able to write to an EXTERNAL texture
TestWritePixels(reporter, context0, surfaceContext.get(), false, "EGLImageTest-write");
diff --git a/tests/ExtendedSkColorTypeTests.cpp b/tests/ExtendedSkColorTypeTests.cpp
index 52affff..9b65aef 100644
--- a/tests/ExtendedSkColorTypeTests.cpp
+++ b/tests/ExtendedSkColorTypeTests.cpp
@@ -24,6 +24,7 @@
#include "include/private/base/SkTo.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkImageInfoPriv.h"
+#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"
@@ -197,6 +198,7 @@
static void gpu_tests(GrDirectContext* dContext,
skiatest::Reporter* reporter,
const TestCase& test) {
+ using namespace skgpu;
const SkImageInfo nativeII = SkImageInfo::Make(kSize, kSize, test.fColorType, test.fAlphaType);
const SkImageInfo f32Unpremul = SkImageInfo::Make(kSize, kSize, kRGBA_F32_SkColorType,
@@ -204,7 +206,7 @@
// We had better not be able to render to prohibited colorTypes
if (!test.fGpuCanMakeSurfaces) {
- auto s = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, nativeII);
+ auto s = SkSurfaces::RenderTarget(dContext, Budgeted::kNo, nativeII);
REPORTER_ASSERT(reporter, !SkToBool(s));
}
@@ -212,6 +214,8 @@
return;
}
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
SkAutoPixmapStorage nativeExpected;
nativeExpected.alloc(nativeII);
nativeExpected.erase(SkColors::kWhite);
@@ -225,16 +229,16 @@
};
if (fullInit) {
backendTex = dContext->createBackendTexture(nativeExpected, kTopLeft_GrSurfaceOrigin,
- GrRenderable::kNo, GrProtected::kNo,
+ GrRenderable::kNo, isProtected,
markFinished, &finishedBECreate);
} else {
backendTex = dContext->createBackendTexture(kSize,
kSize,
test.fColorType,
SkColors::kWhite,
- skgpu::Mipmapped::kNo,
+ Mipmapped::kNo,
GrRenderable::kNo,
- GrProtected::kNo,
+ isProtected,
markFinished,
&finishedBECreate);
}
@@ -265,7 +269,7 @@
// SkSurface::readPixels with the same colorType as the source pixels round trips
// (when allowed)
if (dContext->colorTypeSupportedAsSurface(test.fColorType)) {
- auto s = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, nativeII);
+ auto s = SkSurfaces::RenderTarget(dContext, Budgeted::kNo, nativeII);
REPORTER_ASSERT(reporter, SkToBool(s));
{
@@ -304,7 +308,7 @@
kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- auto s = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, rgba8888Premul);
+ auto s = SkSurfaces::RenderTarget(dContext, Budgeted::kNo, rgba8888Premul);
REPORTER_ASSERT(reporter, SkToBool(s));
{
diff --git a/tests/GrAHardwareBufferTest.cpp b/tests/GrAHardwareBufferTest.cpp
index 211f078..a368a4e 100644
--- a/tests/GrAHardwareBufferTest.cpp
+++ b/tests/GrAHardwareBufferTest.cpp
@@ -228,6 +228,8 @@
return;
}
+ bool isProtected = context->priv().caps()->supportsProtectedContent();
+
///////////////////////////////////////////////////////////////////////////
// Setup SkBitmaps
///////////////////////////////////////////////////////////////////////////
@@ -247,7 +249,8 @@
hwbDesc.usage = AHARDWAREBUFFER_USAGE_CPU_READ_NEVER |
AHARDWAREBUFFER_USAGE_CPU_WRITE_NEVER |
AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
- AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT;
+ AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT |
+ (isProtected ? AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT : 0);
hwbDesc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
// The following three are not used in the allocate
@@ -271,11 +274,13 @@
surface->getCanvas()->drawImage(srcBitmap.asImage(), 0, 0);
- SkBitmap readbackBitmap;
- readbackBitmap.allocN32Pixels(DEV_W, DEV_H);
+ if (!isProtected) {
+ SkBitmap readbackBitmap;
+ readbackBitmap.allocN32Pixels(DEV_W, DEV_H);
- REPORTER_ASSERT(reporter, surface->readPixels(readbackBitmap, 0, 0));
- REPORTER_ASSERT(reporter, check_read(reporter, srcBitmap, readbackBitmap));
+ REPORTER_ASSERT(reporter, surface->readPixels(readbackBitmap, 0, 0));
+ REPORTER_ASSERT(reporter, check_read(reporter, srcBitmap, readbackBitmap));
+ }
cleanup_resources(buffer);
}
diff --git a/tests/GrDDLImageTest.cpp b/tests/GrDDLImageTest.cpp
index 8d70170..197f664 100644
--- a/tests/GrDDLImageTest.cpp
+++ b/tests/GrDDLImageTest.cpp
@@ -22,6 +22,7 @@
#include "include/gpu/ganesh/SkImageGanesh.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/chromium/GrSurfaceCharacterization.h"
+#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/gpu/ContextType.h"
@@ -30,6 +31,8 @@
struct GrContextOptions;
DEF_GANESH_TEST(GrDDLImage_MakeSubset, reporter, options, CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
sk_gpu_test::GrContextFactory factory(options);
for (int ct = 0; ct < skgpu::kContextTypeCount; ++ct) {
auto contextType = static_cast<skgpu::ContextType>(ct);
@@ -37,6 +40,9 @@
if (!dContext) {
continue;
}
+
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
SkIRect subsetBounds = SkIRect::MakeLTRB(4,4,8,8);
SkImageInfo ii = SkImageInfo::Make(16, 16, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
@@ -65,7 +71,8 @@
ii.height(),
ii.colorType(),
skgpu::Mipmapped(sc.isMipMapped()),
- GrRenderable::kYes);
+ GrRenderable::kYes,
+ isProtected);
auto gpuImage = SkImages::BorrowTextureFrom(dContext,
tex,
kTopLeft_GrSurfaceOrigin,
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index a08dbed..8c84375 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -89,12 +89,16 @@
reporter,
ctxInfo,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
auto dContext = ctxInfo.directContext();
if (!dContext->priv().caps()->mipmapSupport()) {
return;
}
- for (auto mipmapped : {skgpu::Mipmapped::kNo, skgpu::Mipmapped::kYes}) {
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
+ for (auto mipmapped : { Mipmapped::kNo, Mipmapped::kYes }) {
for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
// createBackendTexture currently doesn't support uploading data to mip maps
// so we don't send any. However, we pretend there is data for the checks below which is
@@ -106,7 +110,7 @@
SkColors::kTransparent,
mipmapped,
renderable,
- GrProtected::kNo);
+ isProtected);
if (!mbet) {
ERRORF(reporter, "Could not make texture.");
return;
@@ -137,8 +141,7 @@
/* color space */ nullptr,
sk_gpu_test::ManagedBackendTexture::ReleaseProc,
mbet->releaseContext());
- REPORTER_ASSERT(reporter,
- (mipmapped == skgpu::Mipmapped::kYes) == image->hasMipmaps());
+ REPORTER_ASSERT(reporter, (mipmapped == Mipmapped::kYes) == image->hasMipmaps());
proxy = sk_ref_sp(sk_gpu_test::GetTextureImageProxy(image.get(), dContext));
}
REPORTER_ASSERT(reporter, proxy);
@@ -154,15 +157,15 @@
continue;
}
- if (mipmapped == skgpu::Mipmapped::kYes) {
- REPORTER_ASSERT(reporter, skgpu::Mipmapped::kYes == texture->mipmapped());
+ if (mipmapped == Mipmapped::kYes) {
+ REPORTER_ASSERT(reporter, Mipmapped::kYes == texture->mipmapped());
if (GrRenderable::kYes == renderable) {
REPORTER_ASSERT(reporter, texture->mipmapsAreDirty());
} else {
REPORTER_ASSERT(reporter, !texture->mipmapsAreDirty());
}
} else {
- REPORTER_ASSERT(reporter, skgpu::Mipmapped::kNo == texture->mipmapped());
+ REPORTER_ASSERT(reporter, Mipmapped::kNo == texture->mipmapped());
}
}
}
@@ -174,19 +177,25 @@
reporter,
ctxInfo,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
auto dContext = ctxInfo.directContext();
if (!dContext->priv().caps()->mipmapSupport()) {
return;
}
- for (auto betMipmapped : {skgpu::Mipmapped::kNo, skgpu::Mipmapped::kYes}) {
- for (auto requestMipmapped : {skgpu::Mipmapped::kNo, skgpu::Mipmapped::kYes}) {
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
+ for (auto betMipmapped : { Mipmapped::kNo, Mipmapped::kYes }) {
+ for (auto requestMipmapped : { Mipmapped::kNo, Mipmapped::kYes }) {
auto ii =
SkImageInfo::Make({kSize, kSize}, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
sk_sp<SkImage> image = sk_gpu_test::MakeBackendTextureImage(
- dContext, ii, SkColors::kTransparent, betMipmapped);
- REPORTER_ASSERT(reporter,
- (betMipmapped == skgpu::Mipmapped::kYes) == image->hasMipmaps());
+ dContext, ii, SkColors::kTransparent, betMipmapped,
+ Renderable::kNo,
+ GrSurfaceOrigin::kTopLeft_GrSurfaceOrigin,
+ isProtected);
+ REPORTER_ASSERT(reporter, (betMipmapped == Mipmapped::kYes) == image->hasMipmaps());
GrTextureProxy* proxy = sk_gpu_test::GetTextureImageProxy(image.get(), dContext);
REPORTER_ASSERT(reporter, proxy);
@@ -247,8 +256,7 @@
GrGLTextureInfo origTexInfo;
if (GrBackendTextures::GetGLTextureInfo(genBackendTex, &genTexInfo) &&
GrBackendTextures::GetGLTextureInfo(backendTex, &origTexInfo)) {
- if (requestMipmapped == skgpu::Mipmapped::kYes &&
- betMipmapped == skgpu::Mipmapped::kNo) {
+ if (requestMipmapped == Mipmapped::kYes && betMipmapped == Mipmapped::kNo) {
// We did a copy so the texture IDs should be different
REPORTER_ASSERT(reporter, origTexInfo.fID != genTexInfo.fID);
} else {
@@ -264,8 +272,7 @@
GrVkImageInfo origImageInfo;
if (GrBackendTextures::GetVkImageInfo(genBackendTex, &genImageInfo) &&
GrBackendTextures::GetVkImageInfo(backendTex, &origImageInfo)) {
- if (requestMipmapped == skgpu::Mipmapped::kYes &&
- betMipmapped == skgpu::Mipmapped::kNo) {
+ if (requestMipmapped == Mipmapped::kYes && betMipmapped == Mipmapped::kNo) {
// We did a copy so the texture IDs should be different
REPORTER_ASSERT(reporter, origImageInfo.fImage != genImageInfo.fImage);
} else {
@@ -281,8 +288,7 @@
GrMtlTextureInfo origImageInfo;
if (genBackendTex.getMtlTextureInfo(&genImageInfo) &&
backendTex.getMtlTextureInfo(&origImageInfo)) {
- if (requestMipmapped == skgpu::Mipmapped::kYes &&
- betMipmapped == skgpu::Mipmapped::kNo) {
+ if (requestMipmapped == Mipmapped::kYes && betMipmapped == Mipmapped::kNo) {
// We did a copy so the texture IDs should be different
REPORTER_ASSERT(reporter, origImageInfo.fTexture != genImageInfo.fTexture);
} else {
@@ -298,8 +304,7 @@
GrD3DTextureResourceInfo origImageInfo;
if (genBackendTex.getD3DTextureResourceInfo(&genImageInfo) &&
backendTex.getD3DTextureResourceInfo(&origImageInfo)) {
- if (requestMipmapped == skgpu::Mipmapped::kYes &&
- betMipmapped == skgpu::Mipmapped::kNo) {
+ if (requestMipmapped == Mipmapped::kYes && betMipmapped == Mipmapped::kNo) {
// We did a copy so the texture resources should be different
REPORTER_ASSERT(reporter,
origImageInfo.fResource != genImageInfo.fResource);
@@ -329,6 +334,8 @@
return;
}
+ GrProtected isProtected = GrProtected(dContext->priv().caps()->supportsProtectedContent());
+
auto resourceProvider = dContext->priv().resourceProvider();
for (auto willUseMips : {false, true}) {
@@ -343,7 +350,8 @@
info,
kTopLeft_GrSurfaceOrigin,
/* sample count */ 1,
- mipmapped);
+ mipmapped,
+ isProtected);
} else {
surface = SkSurfaces::RenderTarget(dContext,
skgpu::Budgeted::kYes,
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 97fabdb..9413cbf 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -417,6 +417,8 @@
reporter,
context_info,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
auto fillPixels = [](SkPixmap* p, const std::function<uint32_t(int x, int y)>& f) {
for (int y = 0; y < p->height(); ++y) {
for (int x = 0; x < p->width(); ++x) {
@@ -449,6 +451,8 @@
auto dContext = context_info.directContext();
GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
// We test both kRW in addition to kRead mostly to ensure that the calls are structured such
// that they'd succeed if the texture wasn't kRead. We want to be sure we're failing with
// kRead for the right reason.
@@ -457,7 +461,7 @@
srcPixmap,
kTopLeft_GrSurfaceOrigin,
GrRenderable::kNo,
- GrProtected::kNo);
+ isProtected);
if (!mbet) {
ERRORF(reporter, "Could not make texture.");
return;
@@ -465,8 +469,8 @@
auto proxy = proxyProvider->wrapBackendTexture(mbet->texture(), kBorrow_GrWrapOwnership,
GrWrapCacheable::kNo, ioType,
mbet->refCountedCallback());
- skgpu::Swizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(),
- GrColorType::kRGBA_8888);
+ Swizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(),
+ GrColorType::kRGBA_8888);
GrSurfaceProxyView view(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
auto surfContext = dContext->priv().makeSC(std::move(view), ii.colorInfo());
// Read pixels should work with a read-only texture.
@@ -522,9 +526,9 @@
kSize,
kSize,
kRGBA_8888_SkColorType,
- skgpu::Mipmapped::kYes,
+ Mipmapped::kYes,
GrRenderable::kNo,
- GrProtected::kNo);
+ isProtected);
proxy = proxyProvider->wrapBackendTexture(mbet->texture(), kBorrow_GrWrapOwnership,
GrWrapCacheable::kNo, ioType,
mbet->refCountedCallback());
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index eba2a61..a6e985b 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -563,8 +563,12 @@
reporter,
ctxInfo,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
auto dContext = ctxInfo.directContext();
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
static constexpr int kSize = 10;
for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) {
@@ -572,7 +576,8 @@
bool can = dContext->colorTypeSupportedAsImage(colorType);
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
- dContext, kSize, kSize, colorType, skgpu::Mipmapped::kNo, GrRenderable::kNo);
+ dContext, kSize, kSize, colorType, skgpu::Mipmapped::kNo, GrRenderable::kNo,
+ isProtected);
sk_sp<SkImage> img;
if (mbet) {
img = SkImages::BorrowTextureFrom(dContext,
diff --git a/tests/PromiseImageTest.cpp b/tests/PromiseImageTest.cpp
index c6b707e..6f99225 100644
--- a/tests/PromiseImageTest.cpp
+++ b/tests/PromiseImageTest.cpp
@@ -149,18 +149,21 @@
reporter,
ctxInfo,
CtsEnforcement::kNever) {
+ using namespace skgpu;
const int kWidth = 10;
const int kHeight = 10;
auto ctx = ctxInfo.directContext();
+ Protected isProtected = Protected(ctx->priv().caps()->supportsProtectedContent());
+
GrBackendTexture backendTex = ctx->createBackendTexture(kWidth,
kHeight,
kRGBA_8888_SkColorType,
SkColors::kTransparent,
skgpu::Mipmapped::kNo,
GrRenderable::kYes,
- GrProtected::kNo);
+ isProtected);
REPORTER_ASSERT(reporter, backendTex.isValid());
GrBackendFormat backendFormat = backendTex.getBackendFormat();
@@ -305,18 +308,22 @@
reporter,
ctxInfo,
CtsEnforcement::kNever) {
+ using namespace skgpu;
+
const int kWidth = 10;
const int kHeight = 10;
auto dContext = ctxInfo.directContext();
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
GrBackendTexture backendTex = dContext->createBackendTexture(kWidth,
kHeight,
kAlpha_8_SkColorType,
SkColors::kTransparent,
skgpu::Mipmapped::kNo,
GrRenderable::kNo,
- GrProtected::kNo);
+ isProtected);
REPORTER_ASSERT(reporter, backendTex.isValid());
SkImageInfo info =
@@ -354,7 +361,7 @@
1,
skgpu::Mipmapped::kNo,
skgpu::Budgeted::kYes,
- GrProtected::kNo,
+ isProtected,
/*label=*/"PromiseImageTextureFullCacheTest"));
REPORTER_ASSERT(reporter, textures[i]);
}
diff --git a/tests/ProtectedTest.cpp b/tests/ProtectedTest.cpp
index 5505af7..4b21450 100644
--- a/tests/ProtectedTest.cpp
+++ b/tests/ProtectedTest.cpp
@@ -30,6 +30,10 @@
for (bool textureable : { true, false }) {
for (bool isProtected : { true, false }) {
+ if (!isProtected && GrBackendApi::kVulkan == dContext->backend()) {
+ continue;
+ }
+
sk_sp<SkSurface> surface = ProtectedUtils::CreateProtectedSkSurface(dContext,
{ kSize, kSize },
textureable,
@@ -53,6 +57,10 @@
}
for (bool isProtected : { true, false }) {
+ if (!isProtected && GrBackendApi::kVulkan == dContext->backend()) {
+ continue;
+ }
+
sk_sp<SkImage> image = ProtectedUtils::CreateProtectedSkImage(dContext,
{ kSize, kSize },
SkColors::kBlue,
@@ -110,6 +118,10 @@
}
for (bool isProtected : { true, false }) {
+ if (!isProtected && GrBackendApi::kVulkan == dContext->backend()) {
+ continue;
+ }
+
sk_sp<SkSurface> surface = ProtectedUtils::CreateProtectedSkSurface(dContext,
{ kSize, kSize },
/* textureable= */ true,
@@ -150,6 +162,10 @@
}
for (bool isProtected : { true, false }) {
+ if (!isProtected && GrBackendApi::kVulkan == dContext->backend()) {
+ continue;
+ }
+
sk_sp<SkSurface> surface = ProtectedUtils::CreateProtectedSkSurface(dContext,
{ kSize, kSize },
/* textureable= */ true,
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 0d4267d..9f68869 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -127,17 +127,20 @@
reporter,
ctxInfo,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
auto direct = ctxInfo.directContext();
GrProxyProvider* proxyProvider = direct->priv().proxyProvider();
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
const GrCaps& caps = *direct->priv().caps();
+ Protected isProtected = Protected(caps.supportsProtectedContent());
for (auto widthHeight : {100, 128, 1048576}) {
for (auto ct : {GrColorType::kAlpha_8, GrColorType::kBGR_565, GrColorType::kRGBA_8888,
GrColorType::kRGBA_1010102}) {
for (auto fit : {SkBackingFit::kExact, SkBackingFit::kApprox}) {
- for (auto budgeted : {skgpu::Budgeted::kYes, skgpu::Budgeted::kNo}) {
+ for (auto budgeted : { Budgeted::kYes, Budgeted::kNo }) {
for (auto numSamples : {1, 4, 16, 128}) {
SkISize dims = {widthHeight, widthHeight};
@@ -155,7 +158,7 @@
GrTextureType::k2D,
GrRenderable::kYes,
numSamples,
- GrProtected::kNo,
+ isProtected,
/*label=*/{});
} else {
tex = resourceProvider->createTexture(dims,
@@ -163,9 +166,9 @@
GrTextureType::k2D,
GrRenderable::kYes,
numSamples,
- skgpu::Mipmapped::kNo,
+ Mipmapped::kNo,
budgeted,
- GrProtected::kNo,
+ isProtected,
/*label=*/{});
}
@@ -174,10 +177,10 @@
dims,
GrRenderable::kYes,
numSamples,
- skgpu::Mipmapped::kNo,
+ Mipmapped::kNo,
fit,
budgeted,
- GrProtected::kNo,
+ isProtected,
/*label=*/{});
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
if (proxy) {
@@ -208,7 +211,7 @@
GrTextureType::k2D,
GrRenderable::kNo,
numSamples,
- GrProtected::kNo,
+ isProtected,
/*label=*/{});
} else {
tex = resourceProvider->createTexture(dims,
@@ -216,9 +219,9 @@
GrTextureType::k2D,
GrRenderable::kNo,
numSamples,
- skgpu::Mipmapped::kNo,
+ Mipmapped::kNo,
budgeted,
- GrProtected::kNo,
+ isProtected,
/*label=*/{});
}
@@ -227,10 +230,10 @@
dims,
GrRenderable::kNo,
numSamples,
- skgpu::Mipmapped::kNo,
+ Mipmapped::kNo,
fit,
budgeted,
- GrProtected::kNo,
+ isProtected,
/*label=*/{}));
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
if (proxy) {
@@ -258,12 +261,16 @@
reporter,
ctxInfo,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
auto direct = ctxInfo.directContext();
GrProxyProvider* proxyProvider = direct->priv().proxyProvider();
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
GrGpu* gpu = direct->priv().getGpu();
const GrCaps& caps = *direct->priv().caps();
+ Protected isProtected = Protected(caps.supportsProtectedContent());
+
static const int kWidthHeight = 100;
for (auto colorType :
@@ -276,10 +283,10 @@
// sample counts :(.
if (direct->colorTypeSupportedAsSurface(colorType)) {
GrBackendRenderTarget backendRT = gpu->createTestingOnlyBackendRenderTarget(
- {kWidthHeight, kWidthHeight}, grColorType);
+ {kWidthHeight, kWidthHeight}, grColorType, /* sampleCount= */ 1, isProtected);
sk_sp<GrSurfaceProxy> sProxy(
proxyProvider->wrapBackendRenderTarget(backendRT, nullptr));
- check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, skgpu::Budgeted::kNo);
+ check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, Budgeted::kNo);
static constexpr int kExpectedNumSamples = 1;
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
kExpectedNumSamples, SkBackingFit::kExact,
@@ -301,7 +308,7 @@
GrGLFramebufferInfo fboInfo;
fboInfo.fFBOID = 0;
fboInfo.fFormat = GrBackendFormats::AsGLFormatEnum(beFormat);
- fboInfo.fProtected = skgpu::Protected::kNo;
+ fboInfo.fProtected = isProtected;
SkASSERT(fboInfo.fFormat);
static constexpr int kStencilBits = 8;
GrBackendRenderTarget backendRT = GrBackendRenderTargets::MakeGL(
@@ -309,7 +316,7 @@
sk_sp<GrSurfaceProxy> sProxy(
proxyProvider->wrapBackendRenderTarget(backendRT, nullptr));
check_surface(
- reporter, sProxy.get(), kWidthHeight, kWidthHeight, skgpu::Budgeted::kNo);
+ reporter, sProxy.get(), kWidthHeight, kWidthHeight, Budgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact, 0);
}
@@ -322,8 +329,9 @@
kWidthHeight,
kWidthHeight,
colorType,
- skgpu::Mipmapped::kNo,
- GrRenderable::kYes);
+ Mipmapped::kNo,
+ GrRenderable::kYes,
+ isProtected);
if (!mbet) {
ERRORF(reporter,
"Could not create renderable backend texture of color type %d",
@@ -339,7 +347,7 @@
}
check_surface(
- reporter, sProxy.get(), kWidthHeight, kWidthHeight, skgpu::Budgeted::kNo);
+ reporter, sProxy.get(), kWidthHeight, kWidthHeight, Budgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
caps.maxWindowRectangles());
@@ -352,8 +360,9 @@
kWidthHeight,
kWidthHeight,
colorType,
- skgpu::Mipmapped::kNo,
- GrRenderable::kNo);
+ Mipmapped::kNo,
+ GrRenderable::kNo,
+ isProtected);
if (!mbet) {
ERRORF(reporter,
"Could not create non-renderable backend texture of color type %d",
@@ -369,7 +378,7 @@
}
check_surface(
- reporter, sProxy.get(), kWidthHeight, kWidthHeight, skgpu::Budgeted::kNo);
+ reporter, sProxy.get(), kWidthHeight, kWidthHeight, Budgeted::kNo);
check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
SkBackingFit::kExact);
}
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index a209127..0b3afb0 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -1695,11 +1695,16 @@
reporter,
ctxInfo,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
auto dContext = ctxInfo.directContext();
GrGpu* gpu = dContext->priv().getGpu();
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
GrBackendTexture backend = dContext->createBackendTexture(
- 16, 16, SkColorType::kRGBA_8888_SkColorType, skgpu::Mipmapped::kNo, GrRenderable::kNo);
+ 16, 16, SkColorType::kRGBA_8888_SkColorType, skgpu::Mipmapped::kNo, GrRenderable::kNo,
+ isProtected);
sk_sp<GrTexture> tex = gpu->wrapBackendTexture(backend,
GrWrapOwnership::kBorrow_GrWrapOwnership,
GrWrapCacheable::kYes,
diff --git a/tests/SaveLayerOriginTest.cpp b/tests/SaveLayerOriginTest.cpp
index d269110..d707c6a 100644
--- a/tests/SaveLayerOriginTest.cpp
+++ b/tests/SaveLayerOriginTest.cpp
@@ -22,6 +22,7 @@
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
+#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
@@ -74,12 +75,16 @@
static void run_test(skiatest::Reporter* reporter,
GrDirectContext* context,
GrSurfaceOrigin origin) {
+ using namespace skgpu;
+
+ Protected isProtected = Protected(context->priv().caps()->supportsProtectedContent());
+
auto beTexture = context->createBackendTexture(8,
8,
kRGBA_8888_SkColorType,
- skgpu::Mipmapped::kNo,
+ Mipmapped::kNo,
GrRenderable::kYes,
- GrProtected::kNo);
+ isProtected);
REPORTER_ASSERT(reporter, beTexture.isValid());
if (!beTexture.isValid()) {
return;
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index e790fc5..e9de9e4 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -143,8 +143,12 @@
reporter,
ctxInfo,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
auto context = ctxInfo.directContext();
+ Protected isProtected = Protected(context->priv().caps()->supportsProtectedContent());
+
for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) {
static constexpr int kSize = 10;
@@ -153,7 +157,7 @@
{
bool can = context->colorTypeSupportedAsSurface(colorType);
- auto surf = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kYes, info, 1, nullptr);
+ auto surf = SkSurfaces::RenderTarget(context, Budgeted::kYes, info, 1, nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
colorType, can, SkToBool(surf));
@@ -161,7 +165,10 @@
{kSize, kSize},
kTopLeft_GrSurfaceOrigin,
/*sample cnt*/ 1,
- colorType);
+ colorType,
+ /* colorSpace= */ nullptr,
+ Mipmapped::kNo,
+ isProtected);
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
colorType, can, SkToBool(surf));
}
@@ -172,12 +179,13 @@
bool can = context->maxSurfaceSampleCountForColorType(colorType) >= kSampleCnt;
auto surf = SkSurfaces::RenderTarget(
- context, skgpu::Budgeted::kYes, info, kSampleCnt, nullptr);
+ context, Budgeted::kYes, info, kSampleCnt, nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
colorType, can, SkToBool(surf));
surf = sk_gpu_test::MakeBackendTextureSurface(
- context, {kSize, kSize}, kTopLeft_GrSurfaceOrigin, kSampleCnt, colorType);
+ context, {kSize, kSize}, kTopLeft_GrSurfaceOrigin, kSampleCnt, colorType,
+ /* colorSpace= */ nullptr, Mipmapped::kNo, isProtected);
REPORTER_ASSERT(reporter, can == SkToBool(surf),
"colorTypeSupportedAsSurface:%d, surf:%d, ct:%d", can, SkToBool(surf),
colorType);
@@ -199,7 +207,9 @@
{16, 16},
kTopLeft_GrSurfaceOrigin,
sampleCnt,
- colorType);
+ colorType,
+ /* colorSpace= */ nullptr,
+ isProtected);
bool can = context->colorTypeSupportedAsSurface(colorType) &&
context->maxSurfaceSampleCountForColorType(colorType) >= sampleCnt;
if (!surf && can && colorType == kBGRA_8888_SkColorType && sampleCnt > 1 &&
@@ -233,8 +243,12 @@
reporter,
ctxInfo,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
auto context = ctxInfo.directContext();
+ Protected isProtected = Protected(context->priv().caps()->supportsProtectedContent());
+
static constexpr int kSize = 10;
for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) {
@@ -250,7 +264,7 @@
auto info = SkImageInfo::Make(kSize, kSize, colorType, kOpaque_SkAlphaType, nullptr);
auto surf = sk_gpu_test::MakeBackendTextureSurface(
- context, info, kTopLeft_GrSurfaceOrigin, maxSampleCnt);
+ context, info, kTopLeft_GrSurfaceOrigin, maxSampleCnt, Mipmapped::kNo, isProtected);
if (!surf) {
ERRORF(reporter, "Could not make surface of color type %d.", colorType);
continue;
diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp
index d64e602..5a3397a 100644
--- a/tests/TextureProxyTest.cpp
+++ b/tests/TextureProxyTest.cpp
@@ -61,18 +61,22 @@
GrRecordingContext* rContext,
GrProxyProvider* proxyProvider,
SkBackingFit fit) {
+ using namespace skgpu;
+
const GrCaps* caps = rContext->priv().caps();
+ Protected isProtected = Protected(caps->supportsProtectedContent());
+
GrBackendFormat format = caps->getDefaultBackendFormat(kColorType, GrRenderable::kNo);
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(format,
kSize,
GrRenderable::kNo,
1,
- skgpu::Mipmapped::kNo,
+ Mipmapped::kNo,
fit,
- skgpu::Budgeted::kYes,
- GrProtected::kNo,
+ Budgeted::kYes,
+ isProtected,
/*label=*/{});
// Only budgeted & wrapped external proxies get to carry uniqueKeys
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
@@ -83,61 +87,79 @@
GrRecordingContext* rContext,
GrProxyProvider* proxyProvider,
SkBackingFit fit) {
+ using namespace skgpu;
+
const GrCaps* caps = rContext->priv().caps();
+ Protected isProtected = Protected(caps->supportsProtectedContent());
+
GrBackendFormat format = caps->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(format,
kSize,
GrRenderable::kYes,
1,
- skgpu::Mipmapped::kNo,
+ Mipmapped::kNo,
fit,
- skgpu::Budgeted::kYes,
- GrProtected::kNo,
+ Budgeted::kYes,
+ isProtected,
/*label=*/{});
// Only budgeted & wrapped external proxies get to carry uniqueKeys
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;
}
-static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, GrRecordingContext*,
+static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, GrRecordingContext* rContext,
GrProxyProvider* proxyProvider, SkBackingFit fit) {
+ using namespace skgpu;
+
+ Protected isProtected = Protected(rContext->priv().caps()->supportsProtectedContent());
+
sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
- kSize, kColorType, GrRenderable::kNo, 1, fit, skgpu::Budgeted::kYes, GrProtected::kNo);
+ kSize, kColorType, GrRenderable::kNo, 1, fit, Budgeted::kYes, isProtected);
// Only budgeted & wrapped external proxies get to carry uniqueKeys
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;
}
-static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, GrRecordingContext*,
- GrProxyProvider* proxyProvider, SkBackingFit fit) {
- static skgpu::UniqueKey::Domain d = skgpu::UniqueKey::GenerateDomain();
+static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter,
+ GrRecordingContext* rContext,
+ GrProxyProvider* proxyProvider,
+ SkBackingFit fit) {
+ using namespace skgpu;
+
+ Protected isProtected = Protected(rContext->priv().caps()->supportsProtectedContent());
+
+ static UniqueKey::Domain d = UniqueKey::GenerateDomain();
static int kUniqueKeyData = 0;
- skgpu::UniqueKey key;
+ UniqueKey key;
- skgpu::UniqueKey::Builder builder(&key, d, 1, nullptr);
+ UniqueKey::Builder builder(&key, d, 1, nullptr);
builder[0] = kUniqueKeyData++;
builder.finish();
// Only budgeted & wrapped external proxies get to carry uniqueKeys
sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
- kSize, kColorType, GrRenderable::kNo, 1, fit, skgpu::Budgeted::kYes, GrProtected::kNo);
+ kSize, kColorType, GrRenderable::kNo, 1, fit, Budgeted::kYes, isProtected);
SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
REPORTER_ASSERT(reporter, proxy->getUniqueKey().isValid());
return proxy;
}
static sk_sp<GrTextureProxy> create_wrapped_backend(GrDirectContext* dContext) {
+ using namespace skgpu;
+
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
dContext,
kSize.width(),
kSize.height(),
GrColorTypeToSkColorType(kColorType),
- skgpu::Mipmapped::kNo,
+ Mipmapped::kNo,
GrRenderable::kNo,
- GrProtected::kNo);
+ isProtected);
if (!mbet) {
return nullptr;
}
diff --git a/tests/VkBackendSurfaceTest.cpp b/tests/VkBackendSurfaceTest.cpp
index 81bb882..c0c6c46 100644
--- a/tests/VkBackendSurfaceTest.cpp
+++ b/tests/VkBackendSurfaceTest.cpp
@@ -42,6 +42,8 @@
struct GrContextOptions;
DEF_GANESH_TEST_FOR_VULKAN_CONTEXT(VkDRMModifierTest, reporter, ctxInfo, CtsEnforcement::kNever) {
+ using namespace skgpu;
+
auto dContext = ctxInfo.directContext();
const GrVkCaps* vkCaps = static_cast<const GrVkCaps*>(dContext->priv().caps());
@@ -49,9 +51,11 @@
return;
}
+ Protected isProtected = Protected(vkCaps->supportsProtectedContent());
+
// First make a normal backend texture with DRM
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
- dContext, 1, 1, kRGBA_8888_SkColorType, skgpu::Mipmapped::kNo, GrRenderable::kNo);
+ dContext, 1, 1, kRGBA_8888_SkColorType, Mipmapped::kNo, GrRenderable::kNo, isProtected);
if (!mbet) {
ERRORF(reporter, "Could not create backend texture.");
return;
@@ -84,7 +88,7 @@
REPORTER_ASSERT(reporter, ok);
REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(actual, drmBETex));
- auto [view, _] = skgpu::ganesh::AsView(dContext, drmImage, skgpu::Mipmapped::kNo);
+ auto [view, _] = skgpu::ganesh::AsView(dContext, drmImage, Mipmapped::kNo);
REPORTER_ASSERT(reporter, view);
const GrSurfaceProxy* proxy = view.proxy();
REPORTER_ASSERT(reporter, proxy);
@@ -99,10 +103,14 @@
}
DEF_GANESH_TEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo, CtsEnforcement::kNever) {
+ using namespace skgpu;
+
auto dContext = ctxInfo.directContext();
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
- dContext, 1, 1, kRGBA_8888_SkColorType, skgpu::Mipmapped::kNo, GrRenderable::kNo);
+ dContext, 1, 1, kRGBA_8888_SkColorType, Mipmapped::kNo, GrRenderable::kNo, isProtected);
if (!mbet) {
ERRORF(reporter, "Could not create backend texture.");
return;
diff --git a/tests/VkWrapTests.cpp b/tests/VkWrapTests.cpp
index 5d0f533..0ecc541 100644
--- a/tests/VkWrapTests.cpp
+++ b/tests/VkWrapTests.cpp
@@ -43,10 +43,15 @@
const SkColorType kColorType = SkColorType::kRGBA_8888_SkColorType;
void wrap_tex_test(skiatest::Reporter* reporter, GrDirectContext* dContext) {
+ using namespace skgpu;
+
GrGpu* gpu = dContext->priv().getGpu();
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
- dContext, kW, kH, kRGBA_8888_SkColorType, skgpu::Mipmapped::kNo, GrRenderable::kNo);
+ dContext, kW, kH, kRGBA_8888_SkColorType, skgpu::Mipmapped::kNo, GrRenderable::kNo,
+ isProtected);
if (!mbet) {
ERRORF(reporter, "Could not create backend texture.");
return;
@@ -104,9 +109,13 @@
}
void wrap_rt_test(skiatest::Reporter* reporter, GrDirectContext* dContext) {
+ using namespace skgpu;
+
GrGpu* gpu = dContext->priv().getGpu();
GrColorType ct = SkColorTypeToGrColorType(kColorType);
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
for (int sampleCnt : {1, 4}) {
GrBackendFormat format = gpu->caps()->getDefaultBackendFormat(ct, GrRenderable::kYes);
if (sampleCnt > gpu->caps()->maxRenderTargetSampleCount(format)) {
@@ -114,7 +123,7 @@
}
GrBackendRenderTarget origBackendRT =
- gpu->createTestingOnlyBackendRenderTarget({kW, kH}, ct, sampleCnt);
+ gpu->createTestingOnlyBackendRenderTarget({kW, kH}, ct, sampleCnt, isProtected);
if (!origBackendRT.isValid()) {
ERRORF(reporter, "Could not create backend render target.");
}
@@ -138,7 +147,7 @@
// alloc is null
{
GrVkImageInfo backendCopy = imageInfo;
- backendCopy.fAlloc = skgpu::VulkanAlloc();
+ backendCopy.fAlloc = VulkanAlloc();
// can wrap null alloc
GrBackendRenderTarget backendRT = GrBackendRenderTargets::MakeVk(kW, kH, backendCopy);
rt = gpu->wrapBackendRenderTarget(backendRT);
@@ -150,10 +159,15 @@
}
void wrap_trt_test(skiatest::Reporter* reporter, GrDirectContext* dContext) {
+ using namespace skgpu;
+
GrGpu* gpu = dContext->priv().getGpu();
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
- dContext, kW, kH, kRGBA_8888_SkColorType, skgpu::Mipmapped::kNo, GrRenderable::kYes);
+ dContext, kW, kH, kRGBA_8888_SkColorType, Mipmapped::kNo, GrRenderable::kYes,
+ isProtected);
if (!mbet) {
ERRORF(reporter, "Could not create renderable backend texture.");
return;
@@ -183,7 +197,7 @@
// alloc is null
{
GrVkImageInfo backendCopy = imageInfo;
- backendCopy.fAlloc = skgpu::VulkanAlloc();
+ backendCopy.fAlloc = VulkanAlloc();
GrBackendTexture backendTex = GrBackendTextures::MakeVk(kW, kH, backendCopy);
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kBorrow_GrWrapOwnership,
GrWrapCacheable::kNo);
diff --git a/tests/WrappedSurfaceCopyOnWriteTest.cpp b/tests/WrappedSurfaceCopyOnWriteTest.cpp
index 5b923ca..46f75ca 100644
--- a/tests/WrappedSurfaceCopyOnWriteTest.cpp
+++ b/tests/WrappedSurfaceCopyOnWriteTest.cpp
@@ -53,14 +53,20 @@
reporter,
ctxInfo,
CtsEnforcement::kApiLevel_T) {
+ using namespace skgpu;
+
GrDirectContext* dContext = ctxInfo.directContext();
+ Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
+
auto makeDirectBackendSurface = [&]() {
auto info = SkImageInfo::Make({10, 10}, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
return sk_gpu_test::MakeBackendTextureSurface(dContext,
info,
kTopLeft_GrSurfaceOrigin,
- /*sample count*/ 1);
+ /* sampleCnt= */ 1,
+ Mipmapped::kNo,
+ isProtected);
};
auto imageProxyID = [&](const sk_sp<SkImage>& img) {
diff --git a/tests/graphite/GraphitePromiseImageTest.cpp b/tests/graphite/GraphitePromiseImageTest.cpp
index c5a4a56..ed53c26 100644
--- a/tests/graphite/GraphitePromiseImageTest.cpp
+++ b/tests/graphite/GraphitePromiseImageTest.cpp
@@ -187,9 +187,11 @@
const Caps* caps = context->priv().caps();
testCtx->fRecorder = context->makeRecorder();
+ skgpu::Protected isProtected = skgpu::Protected(caps->protectedSupport());
+
TextureInfo textureInfo = caps->getDefaultSampledTextureInfo(kRGBA_8888_SkColorType,
skgpu::Mipmapped::kNo,
- skgpu::Protected::kNo,
+ isProtected,
skgpu::Renderable::kYes);
if (invalidBackendTex) {
diff --git a/tests/graphite/GraphiteYUVAPromiseImageTest.cpp b/tests/graphite/GraphiteYUVAPromiseImageTest.cpp
index e3698e0..637a413 100644
--- a/tests/graphite/GraphiteYUVAPromiseImageTest.cpp
+++ b/tests/graphite/GraphiteYUVAPromiseImageTest.cpp
@@ -209,6 +209,9 @@
testCtx->fContext = context;
const Caps* caps = context->priv().caps();
+
+ skgpu::Protected isProtected = skgpu::Protected(caps->protectedSupport());
+
testCtx->fRecorder = context->makeRecorder();
testCtx->fPromiseImageChecker = PromiseImageChecker();
@@ -217,7 +220,7 @@
for (int i = 0; i < 4; ++i) {
textureInfo[i] = caps->getDefaultSampledTextureInfo(kAlpha_8_SkColorType,
skgpu::Mipmapped::kNo,
- skgpu::Protected::kNo,
+ isProtected,
skgpu::Renderable::kYes);
if (invalidBackendTex) {
diff --git a/tests/graphite/ImageOriginTest.cpp b/tests/graphite/ImageOriginTest.cpp
index ced2b5e..a51a7c5 100644
--- a/tests/graphite/ImageOriginTest.cpp
+++ b/tests/graphite/ImageOriginTest.cpp
@@ -14,6 +14,8 @@
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Image.h"
#include "include/gpu/graphite/Surface.h"
+#include "src/gpu/graphite/Caps.h"
+#include "src/gpu/graphite/ContextPriv.h"
#include "src/gpu/graphite/Surface_Graphite.h"
#include "src/shaders/SkImageShader.h"
#include "tools/ToolUtils.h"
@@ -38,6 +40,7 @@
DrawFn drawImageFn) {
std::unique_ptr<Recorder> recorder = context->makeRecorder();
+ skgpu::Protected isProtected = skgpu::Protected(context->priv().caps()->protectedSupport());
SkBitmap bitmap;
bitmap.allocPixels(SkImageInfo::Make(kImageSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType),
@@ -50,7 +53,8 @@
sk_gpu_test::ManagedGraphiteTexture::MakeFromPixmap(recorder.get(),
bitmap.pixmap(),
skgpu::Mipmapped::kNo,
- skgpu::Renderable::kNo);
+ skgpu::Renderable::kNo,
+ isProtected);
REPORTER_ASSERT(reporter, managedTexture);
if (!managedTexture) {
diff --git a/tests/graphite/MutableImagesTest.cpp b/tests/graphite/MutableImagesTest.cpp
index bdc0af7..75cd633 100644
--- a/tests/graphite/MutableImagesTest.cpp
+++ b/tests/graphite/MutableImagesTest.cpp
@@ -210,11 +210,13 @@
}
std::unique_ptr<Recording> init(const Caps* caps) override {
+ skgpu::Protected isProtected = skgpu::Protected(caps->protectedSupport());
+
// Note: not renderable
TextureInfo info = caps->getDefaultSampledTextureInfo(kRGBA_8888_SkColorType,
fWithMips ? Mipmapped::kYes
: Mipmapped::kNo,
- skgpu::Protected::kNo,
+ isProtected,
skgpu::Renderable::kNo);
REPORTER_ASSERT(fReporter, info.isValid());
@@ -295,11 +297,13 @@
}
std::unique_ptr<Recording> init(const Caps* caps) override {
+ skgpu::Protected isProtected = skgpu::Protected(caps->protectedSupport());
+
// Note: not renderable
TextureInfo info = caps->getDefaultSampledTextureInfo(kRGBA_8888_SkColorType,
fWithMips ? Mipmapped::kYes
: Mipmapped::kNo,
- skgpu::Protected::kNo,
+ isProtected,
skgpu::Renderable::kNo);
REPORTER_ASSERT(fReporter, info.isValid());
diff --git a/tests/graphite/TextureProxyTest.cpp b/tests/graphite/TextureProxyTest.cpp
index 4351f89..010f30a 100644
--- a/tests/graphite/TextureProxyTest.cpp
+++ b/tests/graphite/TextureProxyTest.cpp
@@ -32,10 +32,12 @@
constexpr SkColorType kValidColorType = kRGBA_8888_SkColorType;
constexpr SkColorType kInvalidColorType = kUnknown_SkColorType;
+ Protected isProtected = Protected(caps->protectedSupport());
+
std::unique_ptr<Recorder> recorder = context->makeRecorder();
ResourceProvider* resourceProvider = recorder->priv().resourceProvider();
const TextureInfo textureInfo = caps->getDefaultSampledTextureInfo(
- kValidColorType, Mipmapped::kNo, Protected::kNo, Renderable::kNo);
+ kValidColorType, Mipmapped::kNo, isProtected, Renderable::kNo);
BackendTexture backendTexture = recorder->createBackendTexture(kValidSize, textureInfo);
sk_sp<Texture> texture = resourceProvider->createWrappedTexture(backendTexture);
@@ -54,7 +56,7 @@
kInvalidSize,
kValidColorType,
Mipmapped::kNo,
- Protected::kNo,
+ isProtected,
Renderable::kNo,
skgpu::Budgeted::kNo);
REPORTER_ASSERT(reporter, textureProxy == nullptr);
@@ -62,7 +64,7 @@
kValidSize,
kInvalidColorType,
Mipmapped::kNo,
- Protected::kNo,
+ isProtected,
Renderable::kNo,
skgpu::Budgeted::kNo);
REPORTER_ASSERT(reporter, textureProxy == nullptr);
@@ -72,7 +74,7 @@
kValidSize,
kValidColorType,
Mipmapped::kNo,
- Protected::kNo,
+ isProtected,
Renderable::kNo,
skgpu::Budgeted::kNo);
REPORTER_ASSERT(reporter, !textureProxy->isLazy());
@@ -163,7 +165,7 @@
kValidSize,
kValidColorType,
Mipmapped::kNo,
- Protected::kNo,
+ isProtected,
Renderable::kNo,
skgpu::Budgeted::kNo);
instantiateSuccess = TextureProxy::InstantiateIfNotLazy(resourceProvider, textureProxy.get());
diff --git a/tests/graphite/VulkanBackendTextureTest.cpp b/tests/graphite/VulkanBackendTextureTest.cpp
index 0f84cbf..398b3ca 100644
--- a/tests/graphite/VulkanBackendTextureTest.cpp
+++ b/tests/graphite/VulkanBackendTextureTest.cpp
@@ -11,6 +11,8 @@
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/vk/VulkanGraphiteTypes.h"
+#include "src/gpu/graphite/Caps.h"
+#include "src/gpu/graphite/ContextPriv.h"
using namespace skgpu::graphite;
@@ -22,10 +24,12 @@
CtsEnforcement::kNextRelease) {
auto recorder = context->makeRecorder();
+ bool isProtected = context->priv().caps()->protectedSupport();
+
VulkanTextureInfo textureInfo;
textureInfo.fSampleCount = 1;
textureInfo.fMipmapped = skgpu::Mipmapped::kNo;
- textureInfo.fFlags = 0;
+ textureInfo.fFlags = isProtected ? VK_IMAGE_CREATE_PROTECTED_BIT : 0;
textureInfo.fFormat = VK_FORMAT_R8G8B8A8_UNORM;
textureInfo.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
textureInfo.fImageUsageFlags = VK_IMAGE_USAGE_SAMPLED_BIT;
@@ -47,10 +51,12 @@
CtsEnforcement::kNextRelease) {
auto recorder = context->makeRecorder();
+ bool isProtected = context->priv().caps()->protectedSupport();
+
VulkanTextureInfo textureInfo;
textureInfo.fSampleCount = 1;
textureInfo.fMipmapped = skgpu::Mipmapped::kNo;
- textureInfo.fFlags = 0;
+ textureInfo.fFlags = isProtected ? VK_IMAGE_CREATE_PROTECTED_BIT : 0;
textureInfo.fFormat = VK_FORMAT_R8G8B8A8_UNORM;
textureInfo.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
textureInfo.fImageUsageFlags = VK_IMAGE_USAGE_SAMPLED_BIT;