2019-06-24 14:53:09 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This is a Vulkan protected memory specific test.
|
|
|
|
|
|
|
|
#include "include/core/SkTypes.h"
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU && defined(SK_VULKAN)
|
|
|
|
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkMaskFilter.h"
|
|
|
|
#include "include/core/SkPaint.h"
|
|
|
|
#include "include/core/SkSurface.h"
|
|
|
|
#include "include/gpu/GrBackendSurface.h"
|
|
|
|
#include "include/gpu/vk/GrVkBackendContext.h"
|
|
|
|
#include "include/gpu/vk/GrVkExtensions.h"
|
|
|
|
#include "tests/Test.h"
|
|
|
|
#include "tools/gpu/GrContextFactory.h"
|
2020-06-11 12:51:50 +00:00
|
|
|
#include "tools/gpu/vk/VkTestHelper.h"
|
2019-06-24 14:53:09 +00:00
|
|
|
|
2020-07-20 14:56:01 +00:00
|
|
|
static sk_sp<SkSurface> create_protected_sksurface(GrDirectContext* dContext,
|
2020-06-11 12:51:50 +00:00
|
|
|
skiatest::Reporter* reporter) {
|
2019-06-24 14:53:09 +00:00
|
|
|
const int kW = 8;
|
|
|
|
const int kH = 8;
|
2020-07-20 14:56:01 +00:00
|
|
|
GrBackendTexture backendTex = dContext->createBackendTexture(
|
2020-07-21 13:27:25 +00:00
|
|
|
kW, kH, kRGBA_8888_SkColorType, GrMipmapped::kNo, GrRenderable::kYes, GrProtected::kYes);
|
2019-06-24 14:53:09 +00:00
|
|
|
REPORTER_ASSERT(reporter, backendTex.isValid());
|
2020-06-11 12:51:50 +00:00
|
|
|
REPORTER_ASSERT(reporter, backendTex.isProtected());
|
2019-06-24 14:53:09 +00:00
|
|
|
|
2020-06-11 12:51:50 +00:00
|
|
|
SkSurfaceProps surfaceProps = SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
|
2020-05-12 18:17:44 +00:00
|
|
|
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(
|
2020-07-20 14:56:01 +00:00
|
|
|
dContext, backendTex, kTopLeft_GrSurfaceOrigin, 1,
|
2019-06-24 14:53:09 +00:00
|
|
|
kRGBA_8888_SkColorType, nullptr, &surfaceProps);
|
|
|
|
REPORTER_ASSERT(reporter, surface);
|
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_CreateNonprotectedContext, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto nonprotectedTestHelper = std::make_unique<VkTestHelper>(false);
|
|
|
|
REPORTER_ASSERT(reporter, nonprotectedTestHelper->init());
|
2019-06-24 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_CreateProtectedContext, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_CreateProtectedSkSurface, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-20 14:56:01 +00:00
|
|
|
|
|
|
|
auto dContext = protectedTestHelper->directContext();
|
|
|
|
REPORTER_ASSERT(reporter, dContext != nullptr);
|
2019-06-24 14:53:09 +00:00
|
|
|
|
|
|
|
const int kW = 8;
|
|
|
|
const int kH = 8;
|
2020-07-20 14:56:01 +00:00
|
|
|
GrBackendTexture backendTex = dContext->createBackendTexture(kW, kH, kRGBA_8888_SkColorType,
|
2020-07-21 13:27:25 +00:00
|
|
|
GrMipmapped::kNo,
|
2020-07-20 14:56:01 +00:00
|
|
|
GrRenderable::kNo,
|
|
|
|
GrProtected::kYes);
|
2019-06-24 14:53:09 +00:00
|
|
|
REPORTER_ASSERT(reporter, backendTex.isValid());
|
|
|
|
REPORTER_ASSERT(reporter, backendTex.isProtected());
|
|
|
|
|
2020-06-11 12:51:50 +00:00
|
|
|
SkSurfaceProps surfaceProps = SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
|
2019-06-24 14:53:09 +00:00
|
|
|
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
|
2020-07-20 14:56:01 +00:00
|
|
|
dContext, backendTex, kTopLeft_GrSurfaceOrigin, 1,
|
2019-06-24 14:53:09 +00:00
|
|
|
kRGBA_8888_SkColorType, nullptr, &surfaceProps);
|
|
|
|
REPORTER_ASSERT(reporter, surface);
|
|
|
|
|
2020-07-20 14:56:01 +00:00
|
|
|
dContext->deleteBackendTexture(backendTex);
|
2019-06-24 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_CreateNonprotectedTextureInProtectedContext, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-06-24 14:53:09 +00:00
|
|
|
|
|
|
|
const int kW = 8;
|
|
|
|
const int kH = 8;
|
|
|
|
GrBackendTexture backendTex =
|
2020-07-06 19:50:15 +00:00
|
|
|
protectedTestHelper->directContext()->createBackendTexture(
|
2020-07-21 13:27:25 +00:00
|
|
|
kW, kH, kRGBA_8888_SkColorType, GrMipmapped::kNo, GrRenderable::kNo,
|
2019-06-24 14:53:09 +00:00
|
|
|
GrProtected::kNo);
|
|
|
|
REPORTER_ASSERT(reporter, !backendTex.isValid());
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_CreateProtectedTextureInNonprotectedContext, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(false);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-06-24 14:53:09 +00:00
|
|
|
|
|
|
|
const int kW = 8;
|
|
|
|
const int kH = 8;
|
|
|
|
GrBackendTexture backendTex =
|
2020-07-06 19:50:15 +00:00
|
|
|
protectedTestHelper->directContext()->createBackendTexture(
|
2020-07-21 13:27:25 +00:00
|
|
|
kW, kH, kRGBA_8888_SkColorType, GrMipmapped::kNo, GrRenderable::kNo,
|
2019-06-24 14:53:09 +00:00
|
|
|
GrProtected::kYes);
|
|
|
|
REPORTER_ASSERT(reporter, !backendTex.isValid());
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_ReadFromProtectedSurface, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-06-24 14:53:09 +00:00
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
|
2019-06-24 14:53:09 +00:00
|
|
|
REPORTER_ASSERT(reporter, surface);
|
2020-06-11 12:51:50 +00:00
|
|
|
REPORTER_ASSERT(reporter, !surface->readPixels(SkImageInfo(), nullptr, 8, 0, 0));
|
2019-06-24 14:53:09 +00:00
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
protectedTestHelper->directContext()->deleteBackendTexture(
|
2019-10-25 17:28:54 +00:00
|
|
|
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct AsyncContext {
|
|
|
|
bool fCalled = false;
|
|
|
|
std::unique_ptr<const SkSurface::AsyncReadResult> fResult;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void async_callback(void* c, std::unique_ptr<const SkSurface::AsyncReadResult> result) {
|
|
|
|
auto context = static_cast<AsyncContext*>(c);
|
|
|
|
context->fResult = std::move(result);
|
|
|
|
context->fCalled = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_AsyncReadFromProtectedSurface, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-10-25 17:28:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-20 14:56:01 +00:00
|
|
|
auto dContext = protectedTestHelper->directContext();
|
2020-07-10 20:23:47 +00:00
|
|
|
|
2020-07-20 14:56:01 +00:00
|
|
|
REPORTER_ASSERT(reporter, dContext != nullptr);
|
2020-07-10 20:23:47 +00:00
|
|
|
|
2020-07-20 14:56:01 +00:00
|
|
|
auto surface = create_protected_sksurface(dContext, reporter);
|
2019-10-25 17:28:54 +00:00
|
|
|
REPORTER_ASSERT(reporter, surface);
|
|
|
|
AsyncContext cbContext;
|
|
|
|
const auto image_info = SkImageInfo::Make(10, 10, kRGBA_8888_SkColorType, kPremul_SkAlphaType,
|
|
|
|
SkColorSpace::MakeSRGB());
|
|
|
|
surface->asyncRescaleAndReadPixelsYUV420(kIdentity_SkYUVColorSpace, SkColorSpace::MakeSRGB(),
|
|
|
|
image_info.bounds(), image_info.dimensions(),
|
|
|
|
SkSurface::RescaleGamma::kSrc, kNone_SkFilterQuality,
|
|
|
|
&async_callback, &cbContext);
|
2020-07-20 14:56:01 +00:00
|
|
|
dContext->submit();
|
2019-10-25 17:28:54 +00:00
|
|
|
while (!cbContext.fCalled) {
|
2020-07-20 14:56:01 +00:00
|
|
|
dContext->checkAsyncWorkCompletion();
|
2019-10-25 17:28:54 +00:00
|
|
|
}
|
|
|
|
REPORTER_ASSERT(reporter, !cbContext.fResult);
|
|
|
|
|
2020-07-20 14:56:01 +00:00
|
|
|
dContext->deleteBackendTexture(
|
2020-07-10 20:23:47 +00:00
|
|
|
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
|
2019-06-24 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_DrawRectangle, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-06-24 14:53:09 +00:00
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
|
2019-06-24 14:53:09 +00:00
|
|
|
REPORTER_ASSERT(reporter, surface);
|
|
|
|
SkCanvas* canvas = surface->getCanvas();
|
|
|
|
REPORTER_ASSERT(reporter, canvas);
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor(SK_ColorBLACK);
|
|
|
|
canvas->drawRect(SkRect::MakeWH(4, 4), paint);
|
|
|
|
|
2020-06-30 17:42:46 +00:00
|
|
|
surface->flush();
|
2020-07-06 19:50:15 +00:00
|
|
|
protectedTestHelper->directContext()->submit(true);
|
|
|
|
protectedTestHelper->directContext()->deleteBackendTexture(
|
2019-06-24 14:53:09 +00:00
|
|
|
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_DrawRectangleWithAntiAlias, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-06-24 14:53:09 +00:00
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
|
2019-06-24 14:53:09 +00:00
|
|
|
REPORTER_ASSERT(reporter, surface);
|
|
|
|
SkCanvas* canvas = surface->getCanvas();
|
|
|
|
REPORTER_ASSERT(reporter, canvas);
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor(SK_ColorBLACK);
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
canvas->drawRect(SkRect::MakeWH(4, 4), paint);
|
|
|
|
|
2020-06-30 17:42:46 +00:00
|
|
|
surface->flush();
|
2020-07-06 19:50:15 +00:00
|
|
|
protectedTestHelper->directContext()->submit(true);
|
|
|
|
protectedTestHelper->directContext()->deleteBackendTexture(
|
2019-06-24 14:53:09 +00:00
|
|
|
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_DrawRectangleWithBlendMode, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-06-24 14:53:09 +00:00
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
|
2019-06-24 14:53:09 +00:00
|
|
|
REPORTER_ASSERT(reporter, surface);
|
|
|
|
SkCanvas* canvas = surface->getCanvas();
|
|
|
|
REPORTER_ASSERT(reporter, canvas);
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor(SK_ColorBLACK);
|
|
|
|
paint.setBlendMode(SkBlendMode::kColorDodge);
|
|
|
|
canvas->drawRect(SkRect::MakeWH(4, 4), paint);
|
|
|
|
|
2020-06-30 17:42:46 +00:00
|
|
|
surface->flush();
|
2020-07-06 19:50:15 +00:00
|
|
|
protectedTestHelper->directContext()->submit(true);
|
|
|
|
protectedTestHelper->directContext()->deleteBackendTexture(
|
2019-06-24 14:53:09 +00:00
|
|
|
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_DrawRectangleWithFilter, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-06-24 14:53:09 +00:00
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
|
2019-06-24 14:53:09 +00:00
|
|
|
REPORTER_ASSERT(reporter, surface);
|
|
|
|
SkCanvas* canvas = surface->getCanvas();
|
|
|
|
REPORTER_ASSERT(reporter, canvas);
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor(SK_ColorBLACK);
|
|
|
|
paint.setStyle(SkPaint::kFill_Style);
|
|
|
|
paint.setMaskFilter(SkMaskFilter::MakeBlur(
|
|
|
|
SkBlurStyle::kOuter_SkBlurStyle, 1.1f));
|
|
|
|
canvas->drawRect(SkRect::MakeWH(4, 4), paint);
|
|
|
|
|
2020-06-30 17:42:46 +00:00
|
|
|
surface->flush();
|
2020-07-06 19:50:15 +00:00
|
|
|
protectedTestHelper->directContext()->submit(true);
|
|
|
|
protectedTestHelper->directContext()->deleteBackendTexture(
|
2019-06-24 14:53:09 +00:00
|
|
|
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_DrawThinPath, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-06-24 14:53:09 +00:00
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
|
2019-06-24 14:53:09 +00:00
|
|
|
REPORTER_ASSERT(reporter, surface);
|
|
|
|
SkCanvas* canvas = surface->getCanvas();
|
|
|
|
REPORTER_ASSERT(reporter, canvas);
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor(SK_ColorBLACK);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setStrokeWidth(.4f);
|
|
|
|
canvas->drawPath(SkPath().moveTo(4, 4).lineTo(6, 6), paint);
|
|
|
|
|
2020-06-30 17:42:46 +00:00
|
|
|
surface->flush();
|
2020-07-06 19:50:15 +00:00
|
|
|
protectedTestHelper->directContext()->submit(true);
|
|
|
|
protectedTestHelper->directContext()->deleteBackendTexture(
|
2019-06-24 14:53:09 +00:00
|
|
|
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_SaveLayer, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-06-24 14:53:09 +00:00
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
|
2019-06-24 14:53:09 +00:00
|
|
|
REPORTER_ASSERT(reporter, surface);
|
|
|
|
SkCanvas* canvas = surface->getCanvas();
|
|
|
|
REPORTER_ASSERT(reporter, canvas);
|
|
|
|
canvas->saveLayer(nullptr, nullptr);
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor(SK_ColorBLACK);
|
|
|
|
canvas->drawRect(SkRect::MakeWH(4, 4), paint);
|
|
|
|
canvas->restore();
|
|
|
|
|
2020-06-30 17:42:46 +00:00
|
|
|
surface->flush();
|
2020-07-06 19:50:15 +00:00
|
|
|
protectedTestHelper->directContext()->submit(true);
|
|
|
|
protectedTestHelper->directContext()->deleteBackendTexture(
|
2019-06-24 14:53:09 +00:00
|
|
|
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_DrawProtectedImageOnProtectedSurface, reporter, options) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-06-24 14:53:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-06-24 14:53:09 +00:00
|
|
|
|
|
|
|
// Create protected image.
|
2020-07-06 19:50:15 +00:00
|
|
|
auto surface1 = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
|
2019-06-24 14:53:09 +00:00
|
|
|
REPORTER_ASSERT(reporter, surface1);
|
|
|
|
auto image = surface1->makeImageSnapshot();
|
|
|
|
REPORTER_ASSERT(reporter, image);
|
|
|
|
|
|
|
|
// Create protected canvas.
|
2020-07-06 19:50:15 +00:00
|
|
|
auto surface2 = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
|
2019-06-24 14:53:09 +00:00
|
|
|
REPORTER_ASSERT(reporter, surface2);
|
|
|
|
SkCanvas* canvas = surface2->getCanvas();
|
|
|
|
REPORTER_ASSERT(reporter, canvas);
|
|
|
|
|
|
|
|
canvas->drawImage(image, 0, 0);
|
|
|
|
|
2020-06-30 17:42:46 +00:00
|
|
|
surface1->flush();
|
2020-07-06 19:50:15 +00:00
|
|
|
protectedTestHelper->directContext()->submit(true);
|
|
|
|
protectedTestHelper->directContext()->deleteBackendTexture(
|
2019-06-24 14:53:09 +00:00
|
|
|
surface1->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
|
2020-06-30 17:42:46 +00:00
|
|
|
surface2->flush();
|
2020-07-06 19:50:15 +00:00
|
|
|
protectedTestHelper->directContext()->submit(true);
|
|
|
|
protectedTestHelper->directContext()->deleteBackendTexture(
|
2019-06-24 14:53:09 +00:00
|
|
|
surface2->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
|
|
|
|
}
|
|
|
|
|
2019-07-10 13:28:59 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Test out DDLs using a protected Vulkan context
|
|
|
|
|
2020-07-20 14:56:01 +00:00
|
|
|
void DDLMakeRenderTargetTestImpl(GrDirectContext*, skiatest::Reporter*);
|
2019-07-10 13:28:59 +00:00
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_DDLMakeRenderTargetTest, reporter, ctxInfo) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-07-10 13:28:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-07-10 13:28:59 +00:00
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
DDLMakeRenderTargetTestImpl(protectedTestHelper->directContext(), reporter);
|
2019-07-10 13:28:59 +00:00
|
|
|
}
|
|
|
|
|
2020-07-20 14:56:01 +00:00
|
|
|
void DDLSurfaceCharacterizationTestImpl(GrDirectContext*, skiatest::Reporter*);
|
2019-07-10 13:28:59 +00:00
|
|
|
|
|
|
|
DEF_GPUTEST(VkProtectedContext_DDLSurfaceCharacterizationTest, reporter, ctxInfo) {
|
2020-06-11 12:51:50 +00:00
|
|
|
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
|
|
|
if (!protectedTestHelper->init()) {
|
2019-07-10 13:28:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-06 19:50:15 +00:00
|
|
|
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
2019-07-10 13:28:59 +00:00
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
DDLSurfaceCharacterizationTestImpl(protectedTestHelper->directContext(), reporter);
|
2019-07-10 13:28:59 +00:00
|
|
|
}
|
|
|
|
|
2019-06-24 14:53:09 +00:00
|
|
|
#endif // SK_SUPPORT_GPU && defined(SK_VULKAN)
|