Clean up more tests wrt GrContext
Change-Id: I70189e316be19f28d70c2fae832a868101fd3329 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303998 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
daa5859e49
commit
c8ae494401
@ -7,6 +7,7 @@
|
||||
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "include/gpu/GrRecordingContext.h"
|
||||
#include "src/core/SkAutoPixmapStorage.h"
|
||||
#include "src/core/SkCompressedDataUtils.h"
|
||||
#include "src/core/SkMipmap.h"
|
||||
@ -51,7 +52,7 @@ sk_sp<SkImage> create_image(GrContext* context, const GrBackendTexture& backendT
|
||||
|
||||
// Draw the compressed backend texture (wrapped in an SkImage) into an RGBA surface, attempting
|
||||
// to access all the mipMap levels.
|
||||
static void check_compressed_mipmaps(GrContext* context, sk_sp<SkImage> img,
|
||||
static void check_compressed_mipmaps(GrRecordingContext* rContext, sk_sp<SkImage> img,
|
||||
SkImage::CompressionType compressionType,
|
||||
const SkColor4f expectedColors[6],
|
||||
GrMipMapped mipMapped,
|
||||
@ -60,7 +61,7 @@ static void check_compressed_mipmaps(GrContext* context, sk_sp<SkImage> img,
|
||||
SkImageInfo readbackSurfaceII = SkImageInfo::Make(32, 32, kRGBA_8888_SkColorType,
|
||||
kPremul_SkAlphaType);
|
||||
|
||||
sk_sp<SkSurface> surf = SkSurface::MakeRenderTarget(context,
|
||||
sk_sp<SkSurface> surf = SkSurface::MakeRenderTarget(rContext,
|
||||
SkBudgeted::kNo,
|
||||
readbackSurfaceII, 1,
|
||||
kTopLeft_GrSurfaceOrigin,
|
||||
@ -107,13 +108,13 @@ static void check_compressed_mipmaps(GrContext* context, sk_sp<SkImage> img,
|
||||
}
|
||||
|
||||
// Verify that we can readback from a compressed texture
|
||||
static void check_readback(GrContext* context, sk_sp<SkImage> img,
|
||||
static void check_readback(GrDirectContext* dContext, sk_sp<SkImage> img,
|
||||
SkImage::CompressionType compressionType,
|
||||
const SkColor4f& expectedColor,
|
||||
skiatest::Reporter* reporter, const char* label) {
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
// reading back ETC2 is broken on Metal/iOS (skbug.com/9839)
|
||||
if (context->backend() == GrBackendApi::kMetal) {
|
||||
if (dContext->backend() == GrBackendApi::kMetal) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -135,32 +136,32 @@ static void check_readback(GrContext* context, sk_sp<SkImage> img,
|
||||
}
|
||||
|
||||
// Test initialization of compressed GrBackendTextures to a specific color
|
||||
static void test_compressed_color_init(GrContext* context,
|
||||
static void test_compressed_color_init(GrDirectContext* dContext,
|
||||
skiatest::Reporter* reporter,
|
||||
std::function<GrBackendTexture (GrContext*,
|
||||
std::function<GrBackendTexture (GrDirectContext*,
|
||||
const SkColor4f&,
|
||||
GrMipMapped)> create,
|
||||
const SkColor4f& color,
|
||||
SkImage::CompressionType compression,
|
||||
GrMipMapped mipMapped) {
|
||||
GrBackendTexture backendTex = create(context, color, mipMapped);
|
||||
GrBackendTexture backendTex = create(dContext, color, mipMapped);
|
||||
if (!backendTex.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<SkImage> img = create_image(context, backendTex);
|
||||
sk_sp<SkImage> img = create_image(dContext, backendTex);
|
||||
if (!img) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkColor4f expectedColors[6] = { color, color, color, color, color, color };
|
||||
|
||||
check_compressed_mipmaps(context, img, compression, expectedColors, mipMapped,
|
||||
check_compressed_mipmaps(dContext, img, compression, expectedColors, mipMapped,
|
||||
reporter, "colorinit");
|
||||
check_readback(context, std::move(img), compression, color, reporter,
|
||||
check_readback(dContext, std::move(img), compression, color, reporter,
|
||||
"solid readback");
|
||||
|
||||
context->deleteBackendTexture(backendTex);
|
||||
dContext->deleteBackendTexture(backendTex);
|
||||
}
|
||||
|
||||
// Create compressed data pulling the color for each mipmap level from 'levelColors'.
|
||||
@ -194,9 +195,9 @@ static std::unique_ptr<const char[]> make_compressed_data(SkImage::CompressionTy
|
||||
|
||||
// Verify that we can initialize a compressed backend texture with data (esp.
|
||||
// the mipmap levels).
|
||||
static void test_compressed_data_init(GrContext* context,
|
||||
static void test_compressed_data_init(GrDirectContext* dContext,
|
||||
skiatest::Reporter* reporter,
|
||||
std::function<GrBackendTexture (GrContext*,
|
||||
std::function<GrBackendTexture (GrDirectContext*,
|
||||
const char* data,
|
||||
size_t dataSize,
|
||||
GrMipMapped)> create,
|
||||
@ -217,27 +218,27 @@ static void test_compressed_data_init(GrContext* context,
|
||||
size_t dataSize = SkCompressedDataSize(compression, { 32, 32 }, nullptr,
|
||||
mipMapped == GrMipMapped::kYes);
|
||||
|
||||
GrBackendTexture backendTex = create(context, data.get(), dataSize, mipMapped);
|
||||
GrBackendTexture backendTex = create(dContext, data.get(), dataSize, mipMapped);
|
||||
if (!backendTex.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<SkImage> img = create_image(context, backendTex);
|
||||
sk_sp<SkImage> img = create_image(dContext, backendTex);
|
||||
if (!img) {
|
||||
return;
|
||||
}
|
||||
|
||||
check_compressed_mipmaps(context, img, compression, expectedColors,
|
||||
check_compressed_mipmaps(dContext, img, compression, expectedColors,
|
||||
mipMapped, reporter, "pixmap");
|
||||
check_readback(context, std::move(img), compression, expectedColors[0], reporter,
|
||||
check_readback(dContext, std::move(img), compression, expectedColors[0], reporter,
|
||||
"data readback");
|
||||
|
||||
context->deleteBackendTexture(backendTex);
|
||||
dContext->deleteBackendTexture(backendTex);
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CompressedBackendAllocationTest, reporter, ctxInfo) {
|
||||
auto context = ctxInfo.directContext();
|
||||
const GrCaps* caps = context->priv().caps();
|
||||
auto dContext = ctxInfo.directContext();
|
||||
const GrCaps* caps = dContext->priv().caps();
|
||||
|
||||
struct {
|
||||
SkImage::CompressionType fCompression;
|
||||
@ -249,7 +250,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CompressedBackendAllocationTest, reporter, ct
|
||||
};
|
||||
|
||||
for (auto combo : combinations) {
|
||||
GrBackendFormat format = context->compressedBackendFormat(combo.fCompression);
|
||||
GrBackendFormat format = dContext->compressedBackendFormat(combo.fCompression);
|
||||
if (!format.isValid()) {
|
||||
continue;
|
||||
}
|
||||
@ -265,27 +266,27 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CompressedBackendAllocationTest, reporter, ct
|
||||
|
||||
// color initialized
|
||||
{
|
||||
auto createWithColorMtd = [format](GrContext* context,
|
||||
auto createWithColorMtd = [format](GrDirectContext* dContext,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped) {
|
||||
return context->createCompressedBackendTexture(32, 32, format, color,
|
||||
mipMapped, GrProtected::kNo);
|
||||
return dContext->createCompressedBackendTexture(32, 32, format, color,
|
||||
mipMapped, GrProtected::kNo);
|
||||
};
|
||||
|
||||
test_compressed_color_init(context, reporter, createWithColorMtd,
|
||||
test_compressed_color_init(dContext, reporter, createWithColorMtd,
|
||||
combo.fColor, combo.fCompression, mipMapped);
|
||||
}
|
||||
|
||||
// data initialized
|
||||
{
|
||||
auto createWithDataMtd = [format](GrContext* context,
|
||||
auto createWithDataMtd = [format](GrDirectContext* dContext,
|
||||
const char* data, size_t dataSize,
|
||||
GrMipMapped mipMapped) {
|
||||
return context->createCompressedBackendTexture(32, 32, format, data, dataSize,
|
||||
mipMapped, GrProtected::kNo);
|
||||
return dContext->createCompressedBackendTexture(32, 32, format, data, dataSize,
|
||||
mipMapped, GrProtected::kNo);
|
||||
};
|
||||
|
||||
test_compressed_data_init(context, reporter, createWithDataMtd,
|
||||
test_compressed_data_init(dContext, reporter, createWithDataMtd,
|
||||
combo.fCompression, mipMapped);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
#include "include/gpu/GrContextThreadSafeProxy.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "include/gpu/GrRecordingContext.h"
|
||||
#include "include/gpu/GrTypes.h"
|
||||
#include "include/gpu/gl/GrGLTypes.h"
|
||||
#include "include/private/GrTypesPriv.h"
|
||||
@ -31,6 +32,7 @@
|
||||
#include "src/gpu/GrCaps.h"
|
||||
#include "src/gpu/GrContextPriv.h"
|
||||
#include "src/gpu/GrGpu.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrRenderTargetContext.h"
|
||||
#include "src/gpu/GrRenderTargetProxy.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
@ -58,8 +60,8 @@ public:
|
||||
static const int kFBO0Count = 9;
|
||||
static const int kProtectedCount = 11;
|
||||
|
||||
SurfaceParameters(GrContext* context)
|
||||
: fBackend(context->backend())
|
||||
SurfaceParameters(GrRecordingContext* rContext)
|
||||
: fBackend(rContext->backend())
|
||||
, fWidth(64)
|
||||
, fHeight(64)
|
||||
, fOrigin(kTopLeft_GrSurfaceOrigin)
|
||||
@ -72,8 +74,8 @@ public:
|
||||
, fIsTextureable(true)
|
||||
, fIsProtected(GrProtected::kNo) {
|
||||
#ifdef SK_VULKAN
|
||||
if (GrBackendApi::kVulkan == context->backend()) {
|
||||
const GrVkCaps* vkCaps = (const GrVkCaps*) context->priv().caps();
|
||||
if (GrBackendApi::kVulkan == rContext->backend()) {
|
||||
const GrVkCaps* vkCaps = (const GrVkCaps*) rContext->priv().caps();
|
||||
|
||||
fIsProtected = GrProtected(vkCaps->supportsProtectedMemory());
|
||||
}
|
||||
@ -141,10 +143,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
SkSurfaceCharacterization createCharacterization(GrContext* context) const {
|
||||
size_t maxResourceBytes = context->getResourceCacheLimit();
|
||||
SkSurfaceCharacterization createCharacterization(GrDirectContext* dContext) const {
|
||||
size_t maxResourceBytes = dContext->getResourceCacheLimit();
|
||||
|
||||
if (!context->colorTypeSupportedAsSurface(fColorType)) {
|
||||
if (!dContext->colorTypeSupportedAsSurface(fColorType)) {
|
||||
return SkSurfaceCharacterization();
|
||||
}
|
||||
|
||||
@ -152,13 +154,13 @@ public:
|
||||
SkImageInfo ii = SkImageInfo::Make(fWidth, fHeight, fColorType,
|
||||
kPremul_SkAlphaType, fColorSpace);
|
||||
|
||||
GrBackendFormat backendFormat = context->defaultBackendFormat(fColorType,
|
||||
GrRenderable::kYes);
|
||||
GrBackendFormat backendFormat = dContext->defaultBackendFormat(fColorType,
|
||||
GrRenderable::kYes);
|
||||
if (!backendFormat.isValid()) {
|
||||
return SkSurfaceCharacterization();
|
||||
}
|
||||
|
||||
SkSurfaceCharacterization c = context->threadSafeProxy()->createCharacterization(
|
||||
SkSurfaceCharacterization c = dContext->threadSafeProxy()->createCharacterization(
|
||||
maxResourceBytes, ii, backendFormat, fSampleCount,
|
||||
fOrigin, fSurfaceProps, fShouldCreateMipMaps,
|
||||
fUsesGLFBO0, fIsTextureable, fIsProtected);
|
||||
@ -166,8 +168,8 @@ public:
|
||||
}
|
||||
|
||||
// Create a DDL whose characterization captures the current settings
|
||||
sk_sp<SkDeferredDisplayList> createDDL(GrContext* context) const {
|
||||
SkSurfaceCharacterization c = this->createCharacterization(context);
|
||||
sk_sp<SkDeferredDisplayList> createDDL(GrDirectContext* dContext) const {
|
||||
SkSurfaceCharacterization c = this->createCharacterization(dContext);
|
||||
SkAssertResult(c.isValid());
|
||||
|
||||
SkDeferredDisplayListRecorder r(c);
|
||||
@ -181,8 +183,8 @@ public:
|
||||
}
|
||||
|
||||
// Create the surface with the current set of parameters
|
||||
sk_sp<SkSurface> make(GrContext* context, GrBackendTexture* backend) const {
|
||||
const SkSurfaceCharacterization c = this->createCharacterization(context);
|
||||
sk_sp<SkSurface> make(GrDirectContext* dContext, GrBackendTexture* backend) const {
|
||||
const SkSurfaceCharacterization c = this->createCharacterization(dContext);
|
||||
|
||||
GrMipMapped mipmapped = !fIsTextureable
|
||||
? GrMipMapped::kNo
|
||||
@ -190,7 +192,7 @@ public:
|
||||
|
||||
#ifdef SK_GL
|
||||
if (fUsesGLFBO0) {
|
||||
if (GrBackendApi::kOpenGL != context->backend()) {
|
||||
if (GrBackendApi::kOpenGL != dContext->backend()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -204,7 +206,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkSurface> result = SkSurface::MakeFromBackendRenderTarget(context, backendRT,
|
||||
sk_sp<SkSurface> result = SkSurface::MakeFromBackendRenderTarget(dContext, backendRT,
|
||||
fOrigin, fColorType,
|
||||
fColorSpace,
|
||||
&fSurfaceProps);
|
||||
@ -212,7 +214,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
CreateBackendTexture(context, backend, fWidth, fHeight, fColorType,
|
||||
CreateBackendTexture(dContext, backend, fWidth, fHeight, fColorType,
|
||||
SkColors::kTransparent, mipmapped, GrRenderable::kYes, fIsProtected);
|
||||
if (!backend->isValid()) {
|
||||
return nullptr;
|
||||
@ -226,17 +228,17 @@ public:
|
||||
if (!fIsTextureable) {
|
||||
// Create a surface w/ the current parameters but make it non-textureable
|
||||
surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
|
||||
context, *backend, fOrigin, fSampleCount, fColorType,
|
||||
dContext, *backend, fOrigin, fSampleCount, fColorType,
|
||||
fColorSpace, &fSurfaceProps);
|
||||
} else {
|
||||
surface = SkSurface::MakeFromBackendTexture(
|
||||
context, *backend, fOrigin, fSampleCount, fColorType,
|
||||
dContext, *backend, fOrigin, fSampleCount, fColorType,
|
||||
fColorSpace, &fSurfaceProps);
|
||||
}
|
||||
|
||||
if (!surface) {
|
||||
SkASSERT(!c.isValid());
|
||||
this->cleanUpBackEnd(context, *backend);
|
||||
this->cleanUpBackEnd(dContext, *backend);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -245,8 +247,8 @@ public:
|
||||
return surface;
|
||||
}
|
||||
|
||||
void cleanUpBackEnd(GrContext* context, const GrBackendTexture& backend) const {
|
||||
context->deleteBackendTexture(backend);
|
||||
void cleanUpBackEnd(GrDirectContext* dContext, const GrBackendTexture& backend) const {
|
||||
dContext->deleteBackendTexture(backend);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -325,9 +327,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLOperatorEqTest, reporter, ctxInfo) {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// This tests SkSurfaceCharacterization/SkSurface compatibility
|
||||
void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter* reporter) {
|
||||
GrGpu* gpu = context->priv().getGpu();
|
||||
const GrCaps* caps = context->priv().caps();
|
||||
void DDLSurfaceCharacterizationTestImpl(GrDirectContext* dContext, skiatest::Reporter* reporter) {
|
||||
GrGpu* gpu = dContext->priv().getGpu();
|
||||
const GrCaps* caps = dContext->priv().caps();
|
||||
|
||||
// Create a bitmap that we can readback into
|
||||
SkImageInfo imageInfo = SkImageInfo::Make(64, 64, kRGBA_8888_SkColorType,
|
||||
@ -339,38 +341,38 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
|
||||
|
||||
// First, create a DDL using the stock SkSurface parameters
|
||||
{
|
||||
SurfaceParameters params(context);
|
||||
SurfaceParameters params(dContext);
|
||||
|
||||
ddl = params.createDDL(context);
|
||||
ddl = params.createDDL(dContext);
|
||||
SkAssertResult(ddl);
|
||||
|
||||
// The DDL should draw into an SkSurface created with the same parameters
|
||||
GrBackendTexture backend;
|
||||
sk_sp<SkSurface> s = params.make(context, &backend);
|
||||
sk_sp<SkSurface> s = params.make(dContext, &backend);
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
|
||||
REPORTER_ASSERT(reporter, s->draw(ddl));
|
||||
s->readPixels(imageInfo, bitmap.getPixels(), bitmap.rowBytes(), 0, 0);
|
||||
context->flushAndSubmit();
|
||||
dContext->flushAndSubmit();
|
||||
gpu->testingOnly_flushGpuAndSync();
|
||||
s = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
}
|
||||
|
||||
// Then, alter each parameter in turn and check that the DDL & surface are incompatible
|
||||
for (int i = 0; i < SurfaceParameters::kNumParams; ++i) {
|
||||
SurfaceParameters params(context);
|
||||
SurfaceParameters params(dContext);
|
||||
params.modify(i);
|
||||
|
||||
if (SurfaceParameters::kProtectedCount == i) {
|
||||
if (context->backend() != GrBackendApi::kVulkan) {
|
||||
if (dContext->backend() != GrBackendApi::kVulkan) {
|
||||
// Only the Vulkan backend respects the protected parameter
|
||||
continue;
|
||||
}
|
||||
#ifdef SK_VULKAN
|
||||
const GrVkCaps* vkCaps = (const GrVkCaps*) context->priv().caps();
|
||||
const GrVkCaps* vkCaps = (const GrVkCaps*) dContext->priv().caps();
|
||||
|
||||
// And, even then, only when it is a protected context
|
||||
if (!vkCaps->supportsProtectedMemory()) {
|
||||
@ -380,7 +382,7 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
|
||||
}
|
||||
|
||||
GrBackendTexture backend;
|
||||
sk_sp<SkSurface> s = params.make(context, &backend);
|
||||
sk_sp<SkSurface> s = params.make(dContext, &backend);
|
||||
if (!s) {
|
||||
continue;
|
||||
}
|
||||
@ -392,7 +394,7 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
|
||||
// If changing the sample count won't result in a different
|
||||
// surface characterization, skip this step
|
||||
s = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -401,36 +403,36 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
|
||||
// If changing the mipmap setting won't result in a different surface characterization,
|
||||
// skip this step
|
||||
s = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (SurfaceParameters::kFBO0Count == i && context->backend() != GrBackendApi::kOpenGL) {
|
||||
if (SurfaceParameters::kFBO0Count == i && dContext->backend() != GrBackendApi::kOpenGL) {
|
||||
// FBO0 only affects the surface characterization when using OpenGL
|
||||
s = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
continue;
|
||||
}
|
||||
|
||||
REPORTER_ASSERT(reporter, !s->draw(ddl),
|
||||
"DDLSurfaceCharacterizationTest failed on parameter: %d\n", i);
|
||||
|
||||
context->flushAndSubmit();
|
||||
dContext->flushAndSubmit();
|
||||
gpu->testingOnly_flushGpuAndSync();
|
||||
s = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
}
|
||||
|
||||
// Next test the compatibility of resource cache parameters
|
||||
{
|
||||
const SurfaceParameters params(context);
|
||||
const SurfaceParameters params(dContext);
|
||||
GrBackendTexture backend;
|
||||
|
||||
sk_sp<SkSurface> s = params.make(context, &backend);
|
||||
sk_sp<SkSurface> s = params.make(dContext, &backend);
|
||||
|
||||
size_t maxResourceBytes = context->getResourceCacheLimit();
|
||||
size_t maxResourceBytes = dContext->getResourceCacheLimit();
|
||||
|
||||
context->setResourceCacheLimit(maxResourceBytes/2);
|
||||
dContext->setResourceCacheLimit(maxResourceBytes/2);
|
||||
REPORTER_ASSERT(reporter, !s->draw(ddl));
|
||||
|
||||
// DDL TODO: once proxies/ops can be de-instantiated we can re-enable these tests.
|
||||
@ -450,27 +452,27 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
|
||||
s->readPixels(imageInfo, bitmap.getPixels(), bitmap.rowBytes(), 0, 0);
|
||||
#endif
|
||||
|
||||
context->flushAndSubmit();
|
||||
dContext->flushAndSubmit();
|
||||
gpu->testingOnly_flushGpuAndSync();
|
||||
s = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
}
|
||||
|
||||
// Test that the textureability of the DDL characterization can block a DDL draw
|
||||
{
|
||||
GrBackendTexture backend;
|
||||
SurfaceParameters params(context);
|
||||
SurfaceParameters params(dContext);
|
||||
params.setShouldCreateMipMaps(false);
|
||||
params.setTextureable(false);
|
||||
|
||||
sk_sp<SkSurface> s = params.make(context, &backend);
|
||||
sk_sp<SkSurface> s = params.make(dContext, &backend);
|
||||
if (s) {
|
||||
REPORTER_ASSERT(reporter, !s->draw(ddl)); // bc the DDL was made w/ textureability
|
||||
|
||||
context->flushAndSubmit();
|
||||
dContext->flushAndSubmit();
|
||||
gpu->testingOnly_flushGpuAndSync();
|
||||
s = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
}
|
||||
}
|
||||
|
||||
@ -485,10 +487,10 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
|
||||
|
||||
// Exercise the createResized method
|
||||
{
|
||||
SurfaceParameters params(context);
|
||||
SurfaceParameters params(dContext);
|
||||
GrBackendTexture backend;
|
||||
|
||||
sk_sp<SkSurface> s = params.make(context, &backend);
|
||||
sk_sp<SkSurface> s = params.make(dContext, &backend);
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
@ -511,15 +513,15 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
|
||||
REPORTER_ASSERT(reporter, 32 == char3.height());
|
||||
|
||||
s = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
}
|
||||
|
||||
// Exercise the createColorSpace method
|
||||
{
|
||||
SurfaceParameters params(context);
|
||||
SurfaceParameters params(dContext);
|
||||
GrBackendTexture backend;
|
||||
|
||||
sk_sp<SkSurface> s = params.make(context, &backend);
|
||||
sk_sp<SkSurface> s = params.make(dContext, &backend);
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
@ -556,15 +558,15 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
|
||||
}
|
||||
|
||||
s = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
}
|
||||
|
||||
// Exercise the createBackendFormat method
|
||||
{
|
||||
SurfaceParameters params(context);
|
||||
SurfaceParameters params(dContext);
|
||||
GrBackendTexture backend;
|
||||
|
||||
sk_sp<SkSurface> s = params.make(context, &backend);
|
||||
sk_sp<SkSurface> s = params.make(dContext, &backend);
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
@ -573,13 +575,13 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
|
||||
SkAssertResult(s->characterize(&char0));
|
||||
|
||||
// The default params create a renderable RGBA8 surface
|
||||
auto originalBackendFormat = context->defaultBackendFormat(kRGBA_8888_SkColorType,
|
||||
GrRenderable::kYes);
|
||||
auto originalBackendFormat = dContext->defaultBackendFormat(kRGBA_8888_SkColorType,
|
||||
GrRenderable::kYes);
|
||||
REPORTER_ASSERT(reporter, originalBackendFormat.isValid());
|
||||
REPORTER_ASSERT(reporter, char0.backendFormat() == originalBackendFormat);
|
||||
|
||||
auto newBackendFormat = context->defaultBackendFormat(kRGB_565_SkColorType,
|
||||
GrRenderable::kYes);
|
||||
auto newBackendFormat = dContext->defaultBackendFormat(kRGB_565_SkColorType,
|
||||
GrRenderable::kYes);
|
||||
|
||||
if (newBackendFormat.isValid()) {
|
||||
SkSurfaceCharacterization char1 = char0.createBackendFormat(kRGB_565_SkColorType,
|
||||
@ -595,15 +597,15 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
|
||||
}
|
||||
|
||||
s = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
}
|
||||
|
||||
// Exercise the createFBO0 method
|
||||
if (context->backend() == GrBackendApi::kOpenGL) {
|
||||
SurfaceParameters params(context);
|
||||
if (dContext->backend() == GrBackendApi::kOpenGL) {
|
||||
SurfaceParameters params(dContext);
|
||||
GrBackendTexture backend;
|
||||
|
||||
sk_sp<SkSurface> s = params.make(context, &backend);
|
||||
sk_sp<SkSurface> s = params.make(dContext, &backend);
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
@ -628,7 +630,7 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
|
||||
}
|
||||
|
||||
s = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
}
|
||||
}
|
||||
|
||||
@ -761,34 +763,34 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLNonTextureabilityTest, reporter, ctxInfo)
|
||||
}
|
||||
|
||||
static void test_make_render_target(skiatest::Reporter* reporter,
|
||||
GrContext* context,
|
||||
GrDirectContext* dContext,
|
||||
const SurfaceParameters& params) {
|
||||
{
|
||||
const SkSurfaceCharacterization c = params.createCharacterization(context);
|
||||
const SkSurfaceCharacterization c = params.createCharacterization(dContext);
|
||||
|
||||
if (!c.isValid()) {
|
||||
GrBackendTexture backend;
|
||||
sk_sp<SkSurface> tmp = params.make(context, &backend);
|
||||
sk_sp<SkSurface> tmp = params.make(dContext, &backend);
|
||||
|
||||
// If we couldn't characterize the surface we shouldn't be able to create it either
|
||||
REPORTER_ASSERT(reporter, !tmp);
|
||||
if (tmp) {
|
||||
tmp = nullptr;
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const SkSurfaceCharacterization c = params.createCharacterization(context);
|
||||
const SkSurfaceCharacterization c = params.createCharacterization(dContext);
|
||||
GrBackendTexture backend;
|
||||
|
||||
{
|
||||
sk_sp<SkSurface> s = params.make(context, &backend);
|
||||
sk_sp<SkSurface> s = params.make(dContext, &backend);
|
||||
REPORTER_ASSERT(reporter, s);
|
||||
if (!s) {
|
||||
REPORTER_ASSERT(reporter, !c.isValid());
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -800,26 +802,26 @@ static void test_make_render_target(skiatest::Reporter* reporter,
|
||||
|
||||
// Make an SkSurface from scratch
|
||||
{
|
||||
sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(context, c, SkBudgeted::kYes);
|
||||
sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(dContext, c, SkBudgeted::kYes);
|
||||
REPORTER_ASSERT(reporter, s);
|
||||
REPORTER_ASSERT(reporter, s->isCompatible(c));
|
||||
}
|
||||
|
||||
// Make an SkSurface that wraps the existing backend texture
|
||||
{
|
||||
sk_sp<SkSurface> s = SkSurface::MakeFromBackendTexture(context, c, backend);
|
||||
sk_sp<SkSurface> s = SkSurface::MakeFromBackendTexture(dContext, c, backend);
|
||||
REPORTER_ASSERT(reporter, s);
|
||||
REPORTER_ASSERT(reporter, s->isCompatible(c));
|
||||
}
|
||||
|
||||
params.cleanUpBackEnd(context, backend);
|
||||
params.cleanUpBackEnd(dContext, backend);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// This tests the SkSurface::MakeRenderTarget variants that take an SkSurfaceCharacterization.
|
||||
// In particular, the SkSurface, backendTexture and SkSurfaceCharacterization
|
||||
// should always be compatible.
|
||||
void DDLMakeRenderTargetTestImpl(GrContext* context, skiatest::Reporter* reporter) {
|
||||
void DDLMakeRenderTargetTestImpl(GrDirectContext* dContext, skiatest::Reporter* reporter) {
|
||||
for (int i = 0; i < SurfaceParameters::kNumParams; ++i) {
|
||||
|
||||
if (SurfaceParameters::kFBO0Count == i) {
|
||||
@ -828,12 +830,12 @@ void DDLMakeRenderTargetTestImpl(GrContext* context, skiatest::Reporter* reporte
|
||||
}
|
||||
|
||||
if (SurfaceParameters::kProtectedCount == i) {
|
||||
if (context->backend() != GrBackendApi::kVulkan) {
|
||||
if (dContext->backend() != GrBackendApi::kVulkan) {
|
||||
// Only the Vulkan backend respects the protected parameter
|
||||
continue;
|
||||
}
|
||||
#ifdef SK_VULKAN
|
||||
const GrVkCaps* vkCaps = (const GrVkCaps*) context->priv().caps();
|
||||
const GrVkCaps* vkCaps = (const GrVkCaps*) dContext->priv().caps();
|
||||
|
||||
// And, even then, only when it is a protected context
|
||||
if (!vkCaps->supportsProtectedMemory()) {
|
||||
@ -843,14 +845,14 @@ void DDLMakeRenderTargetTestImpl(GrContext* context, skiatest::Reporter* reporte
|
||||
}
|
||||
|
||||
|
||||
SurfaceParameters params(context);
|
||||
SurfaceParameters params(dContext);
|
||||
params.modify(i);
|
||||
|
||||
if (!context->priv().caps()->mipMapSupport()) {
|
||||
if (!dContext->priv().caps()->mipMapSupport()) {
|
||||
params.setShouldCreateMipMaps(false);
|
||||
}
|
||||
|
||||
test_make_render_target(reporter, context, params);
|
||||
test_make_render_target(reporter, dContext, params);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,9 @@ static void compare_pixmaps(skiatest::Reporter* reporter,
|
||||
ComparePixels(expected, actual, tols, error);
|
||||
}
|
||||
|
||||
static void gpu_tests(GrContext* context, skiatest::Reporter* reporter, const TestCase& test) {
|
||||
static void gpu_tests(GrDirectContext* dContext,
|
||||
skiatest::Reporter* reporter,
|
||||
const TestCase& test) {
|
||||
|
||||
const SkImageInfo nativeII = SkImageInfo::Make(kSize, kSize, test.fColorType, test.fAlphaType);
|
||||
const SkImageInfo f32Unpremul = SkImageInfo::Make(kSize, kSize, kRGBA_F32_SkColorType,
|
||||
@ -181,11 +183,11 @@ static void gpu_tests(GrContext* context, skiatest::Reporter* reporter, const Te
|
||||
|
||||
// We had better not be able to render to prohibited colorTypes
|
||||
if (!test.fGpuCanMakeSurfaces) {
|
||||
auto s = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, nativeII);
|
||||
auto s = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, nativeII);
|
||||
REPORTER_ASSERT(reporter, !SkToBool(s));
|
||||
}
|
||||
|
||||
if (!context->colorTypeSupportedAsImage(test.fColorType)) {
|
||||
if (!dContext->colorTypeSupportedAsImage(test.fColorType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -201,22 +203,22 @@ static void gpu_tests(GrContext* context, skiatest::Reporter* reporter, const Te
|
||||
*(bool*)context = true;
|
||||
};
|
||||
if (fullInit) {
|
||||
backendTex = context->createBackendTexture(&nativeExpected, 1,
|
||||
GrRenderable::kNo, GrProtected::kNo,
|
||||
markFinished, &finishedBECreate);
|
||||
backendTex = dContext->createBackendTexture(&nativeExpected, 1,
|
||||
GrRenderable::kNo, GrProtected::kNo,
|
||||
markFinished, &finishedBECreate);
|
||||
} else {
|
||||
backendTex = context->createBackendTexture(kSize, kSize, test.fColorType,
|
||||
SkColors::kWhite, GrMipMapped::kNo,
|
||||
GrRenderable::kNo, GrProtected::kNo,
|
||||
markFinished, &finishedBECreate);
|
||||
backendTex = dContext->createBackendTexture(kSize, kSize, test.fColorType,
|
||||
SkColors::kWhite, GrMipMapped::kNo,
|
||||
GrRenderable::kNo, GrProtected::kNo,
|
||||
markFinished, &finishedBECreate);
|
||||
}
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
context->submit();
|
||||
dContext->submit();
|
||||
while (backendTex.isValid() && !finishedBECreate) {
|
||||
context->checkAsyncWorkCompletion();
|
||||
dContext->checkAsyncWorkCompletion();
|
||||
}
|
||||
|
||||
auto img = SkImage::MakeFromTexture(context, backendTex, kTopLeft_GrSurfaceOrigin,
|
||||
auto img = SkImage::MakeFromTexture(dContext, backendTex, kTopLeft_GrSurfaceOrigin,
|
||||
test.fColorType, test.fAlphaType, nullptr);
|
||||
REPORTER_ASSERT(reporter, SkToBool(img));
|
||||
|
||||
@ -232,8 +234,8 @@ static void gpu_tests(GrContext* context, skiatest::Reporter* reporter, const Te
|
||||
|
||||
// SkSurface::readPixels with the same colorType as the source pixels round trips
|
||||
// (when allowed)
|
||||
if (context->colorTypeSupportedAsSurface(test.fColorType)) {
|
||||
auto s = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, nativeII);
|
||||
if (dContext->colorTypeSupportedAsSurface(test.fColorType)) {
|
||||
auto s = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, nativeII);
|
||||
REPORTER_ASSERT(reporter, SkToBool(s));
|
||||
|
||||
{
|
||||
@ -272,7 +274,7 @@ static void gpu_tests(GrContext* context, skiatest::Reporter* reporter, const Te
|
||||
kRGBA_8888_SkColorType,
|
||||
kPremul_SkAlphaType);
|
||||
|
||||
auto s = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, rgba8888Premul);
|
||||
auto s = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, rgba8888Premul);
|
||||
REPORTER_ASSERT(reporter, SkToBool(s));
|
||||
|
||||
{
|
||||
@ -291,8 +293,8 @@ static void gpu_tests(GrContext* context, skiatest::Reporter* reporter, const Te
|
||||
}
|
||||
|
||||
img.reset();
|
||||
context->flushAndSubmit();
|
||||
context->deleteBackendTexture(backendTex);
|
||||
dContext->flushAndSubmit();
|
||||
dContext->deleteBackendTexture(backendTex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,13 +21,13 @@ static void testing_finished_proc(void* ctx) {
|
||||
*count += 1;
|
||||
}
|
||||
|
||||
static void busy_wait_for_callback(int* count, int expectedValue, GrContext* ctx,
|
||||
static void busy_wait_for_callback(int* count, int expectedValue, GrDirectContext* dContext,
|
||||
skiatest::Reporter* reporter) {
|
||||
// Busy waiting should detect that the work is done.
|
||||
auto begin = std::chrono::steady_clock::now();
|
||||
auto end = begin;
|
||||
do {
|
||||
ctx->checkAsyncWorkCompletion();
|
||||
dContext->checkAsyncWorkCompletion();
|
||||
end = std::chrono::steady_clock::now();
|
||||
} while (*count != expectedValue && (end - begin) < std::chrono::seconds(1));
|
||||
if (*count != expectedValue) {
|
||||
@ -37,18 +37,18 @@ static void busy_wait_for_callback(int* count, int expectedValue, GrContext* ctx
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
|
||||
auto ctx = ctxInfo.directContext();
|
||||
auto dContext = ctxInfo.directContext();
|
||||
|
||||
SkImageInfo info =
|
||||
SkImageInfo::Make(8, 8, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info);
|
||||
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, info);
|
||||
SkCanvas* canvas = surface->getCanvas();
|
||||
|
||||
canvas->clear(SK_ColorGREEN);
|
||||
auto image = surface->makeImageSnapshot();
|
||||
|
||||
ctx->flush();
|
||||
ctx->submit(true);
|
||||
dContext->flush();
|
||||
dContext->submit(true);
|
||||
|
||||
int count = 0;
|
||||
|
||||
@ -57,22 +57,23 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
|
||||
flushInfoFinishedProc.fFinishedContext = (void*)&count;
|
||||
// There is no work on the surface so flushing may immediately call the finished proc.
|
||||
surface->flush(flushInfoFinishedProc);
|
||||
ctx->submit();
|
||||
dContext->submit();
|
||||
REPORTER_ASSERT(reporter, count == 0 || count == 1);
|
||||
// Busy waiting should detect that the work is done.
|
||||
busy_wait_for_callback(&count, 1, ctx, reporter);
|
||||
busy_wait_for_callback(&count, 1, dContext, reporter);
|
||||
|
||||
canvas->clear(SK_ColorRED);
|
||||
|
||||
surface->flush(flushInfoFinishedProc);
|
||||
ctx->submit();
|
||||
dContext->submit();
|
||||
|
||||
bool fenceSupport = dContext->priv().caps()->fenceSyncSupport();
|
||||
bool expectAsyncCallback =
|
||||
ctx->backend() == GrBackendApi::kVulkan ||
|
||||
((ctx->backend() == GrBackendApi::kOpenGL) && ctx->priv().caps()->fenceSyncSupport()) ||
|
||||
((ctx->backend() == GrBackendApi::kMetal) && ctx->priv().caps()->fenceSyncSupport()) ||
|
||||
ctx->backend() == GrBackendApi::kDawn ||
|
||||
ctx->backend() == GrBackendApi::kDirect3D;
|
||||
dContext->backend() == GrBackendApi::kVulkan ||
|
||||
((dContext->backend() == GrBackendApi::kOpenGL) && fenceSupport) ||
|
||||
((dContext->backend() == GrBackendApi::kMetal) && fenceSupport) ||
|
||||
dContext->backend() == GrBackendApi::kDawn ||
|
||||
dContext->backend() == GrBackendApi::kDirect3D;
|
||||
if (expectAsyncCallback) {
|
||||
// On Vulkan the command buffer we just submitted may or may not have finished immediately
|
||||
// so the finish proc may not have been called.
|
||||
@ -80,14 +81,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
|
||||
} else {
|
||||
REPORTER_ASSERT(reporter, count == 2);
|
||||
}
|
||||
ctx->flush();
|
||||
ctx->submit(true);
|
||||
dContext->flush();
|
||||
dContext->submit(true);
|
||||
REPORTER_ASSERT(reporter, count == 2);
|
||||
|
||||
// Test flushing via the SkImage
|
||||
canvas->drawImage(image, 0, 0);
|
||||
image->flush(ctx, flushInfoFinishedProc);
|
||||
ctx->submit();
|
||||
image->flush(dContext, flushInfoFinishedProc);
|
||||
dContext->submit();
|
||||
if (expectAsyncCallback) {
|
||||
// On Vulkan the command buffer we just submitted may or may not have finished immediately
|
||||
// so the finish proc may not have been called.
|
||||
@ -95,14 +96,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
|
||||
} else {
|
||||
REPORTER_ASSERT(reporter, count == 3);
|
||||
}
|
||||
ctx->flush();
|
||||
ctx->submit(true);
|
||||
dContext->flush();
|
||||
dContext->submit(true);
|
||||
REPORTER_ASSERT(reporter, count == 3);
|
||||
|
||||
// Test flushing via the GrContext
|
||||
// Test flushing via the GrDirectContext
|
||||
canvas->clear(SK_ColorBLUE);
|
||||
ctx->flush(flushInfoFinishedProc);
|
||||
ctx->submit();
|
||||
dContext->flush(flushInfoFinishedProc);
|
||||
dContext->submit();
|
||||
if (expectAsyncCallback) {
|
||||
// On Vulkan the command buffer we just submitted may or may not have finished immediately
|
||||
// so the finish proc may not have been called.
|
||||
@ -110,30 +111,30 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
|
||||
} else {
|
||||
REPORTER_ASSERT(reporter, count == 4);
|
||||
}
|
||||
ctx->flush();
|
||||
ctx->submit(true);
|
||||
dContext->flush();
|
||||
dContext->submit(true);
|
||||
REPORTER_ASSERT(reporter, count == 4);
|
||||
|
||||
// There is no work on the surface so flushing may immediately call the finished proc.
|
||||
ctx->flush(flushInfoFinishedProc);
|
||||
ctx->submit();
|
||||
dContext->flush(flushInfoFinishedProc);
|
||||
dContext->submit();
|
||||
REPORTER_ASSERT(reporter, count == 4 || count == 5);
|
||||
busy_wait_for_callback(&count, 5, ctx, reporter);
|
||||
busy_wait_for_callback(&count, 5, dContext, reporter);
|
||||
|
||||
count = 0;
|
||||
int count2 = 0;
|
||||
canvas->clear(SK_ColorGREEN);
|
||||
surface->flush(flushInfoFinishedProc);
|
||||
ctx->submit();
|
||||
dContext->submit();
|
||||
// There is no work to be flushed here so this will return immediately, but make sure the
|
||||
// finished call from this proc isn't called till the previous surface flush also is finished.
|
||||
flushInfoFinishedProc.fFinishedContext = (void*)&count2;
|
||||
ctx->flush(flushInfoFinishedProc);
|
||||
ctx->submit();
|
||||
dContext->flush(flushInfoFinishedProc);
|
||||
dContext->submit();
|
||||
REPORTER_ASSERT(reporter, count <= 1 && count2 <= count);
|
||||
|
||||
ctx->flush();
|
||||
ctx->submit(true);
|
||||
dContext->flush();
|
||||
dContext->submit(true);
|
||||
|
||||
REPORTER_ASSERT(reporter, count == 1);
|
||||
REPORTER_ASSERT(reporter, count == count2);
|
||||
|
@ -22,18 +22,18 @@
|
||||
#include "tools/gpu/GrContextFactory.h"
|
||||
#include "tools/gpu/vk/VkTestHelper.h"
|
||||
|
||||
static sk_sp<SkSurface> create_protected_sksurface(GrDirectContext* direct,
|
||||
static sk_sp<SkSurface> create_protected_sksurface(GrDirectContext* dContext,
|
||||
skiatest::Reporter* reporter) {
|
||||
const int kW = 8;
|
||||
const int kH = 8;
|
||||
GrBackendTexture backendTex = direct->createBackendTexture(
|
||||
GrBackendTexture backendTex = dContext->createBackendTexture(
|
||||
kW, kH, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kYes, GrProtected::kYes);
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
REPORTER_ASSERT(reporter, backendTex.isProtected());
|
||||
|
||||
SkSurfaceProps surfaceProps = SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(
|
||||
direct, backendTex, kTopLeft_GrSurfaceOrigin, 1,
|
||||
dContext, backendTex, kTopLeft_GrSurfaceOrigin, 1,
|
||||
kRGBA_8888_SkColorType, nullptr, &surfaceProps);
|
||||
REPORTER_ASSERT(reporter, surface);
|
||||
return surface;
|
||||
@ -56,24 +56,26 @@ DEF_GPUTEST(VkProtectedContext_CreateProtectedSkSurface, reporter, options) {
|
||||
if (!protectedTestHelper->init()) {
|
||||
return;
|
||||
}
|
||||
REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
|
||||
|
||||
auto dContext = protectedTestHelper->directContext();
|
||||
REPORTER_ASSERT(reporter, dContext != nullptr);
|
||||
|
||||
const int kW = 8;
|
||||
const int kH = 8;
|
||||
GrBackendTexture backendTex =
|
||||
protectedTestHelper->directContext()->createBackendTexture(
|
||||
kW, kH, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo,
|
||||
GrProtected::kYes);
|
||||
GrBackendTexture backendTex = dContext->createBackendTexture(kW, kH, kRGBA_8888_SkColorType,
|
||||
GrMipMapped::kNo,
|
||||
GrRenderable::kNo,
|
||||
GrProtected::kYes);
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
REPORTER_ASSERT(reporter, backendTex.isProtected());
|
||||
|
||||
SkSurfaceProps surfaceProps = SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
|
||||
protectedTestHelper->directContext(), backendTex, kTopLeft_GrSurfaceOrigin, 1,
|
||||
dContext, backendTex, kTopLeft_GrSurfaceOrigin, 1,
|
||||
kRGBA_8888_SkColorType, nullptr, &surfaceProps);
|
||||
REPORTER_ASSERT(reporter, surface);
|
||||
|
||||
protectedTestHelper->directContext()->deleteBackendTexture(backendTex);
|
||||
dContext->deleteBackendTexture(backendTex);
|
||||
}
|
||||
|
||||
DEF_GPUTEST(VkProtectedContext_CreateNonprotectedTextureInProtectedContext, reporter, options) {
|
||||
@ -144,11 +146,11 @@ DEF_GPUTEST(VkProtectedContext_AsyncReadFromProtectedSurface, reporter, options)
|
||||
return;
|
||||
}
|
||||
|
||||
auto direct = protectedTestHelper->directContext();
|
||||
auto dContext = protectedTestHelper->directContext();
|
||||
|
||||
REPORTER_ASSERT(reporter, direct != nullptr);
|
||||
REPORTER_ASSERT(reporter, dContext != nullptr);
|
||||
|
||||
auto surface = create_protected_sksurface(direct, reporter);
|
||||
auto surface = create_protected_sksurface(dContext, reporter);
|
||||
REPORTER_ASSERT(reporter, surface);
|
||||
AsyncContext cbContext;
|
||||
const auto image_info = SkImageInfo::Make(10, 10, kRGBA_8888_SkColorType, kPremul_SkAlphaType,
|
||||
@ -157,13 +159,13 @@ DEF_GPUTEST(VkProtectedContext_AsyncReadFromProtectedSurface, reporter, options)
|
||||
image_info.bounds(), image_info.dimensions(),
|
||||
SkSurface::RescaleGamma::kSrc, kNone_SkFilterQuality,
|
||||
&async_callback, &cbContext);
|
||||
direct->submit();
|
||||
dContext->submit();
|
||||
while (!cbContext.fCalled) {
|
||||
direct->checkAsyncWorkCompletion();
|
||||
dContext->checkAsyncWorkCompletion();
|
||||
}
|
||||
REPORTER_ASSERT(reporter, !cbContext.fResult);
|
||||
|
||||
direct->deleteBackendTexture(
|
||||
dContext->deleteBackendTexture(
|
||||
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
|
||||
}
|
||||
|
||||
@ -338,7 +340,7 @@ DEF_GPUTEST(VkProtectedContext_DrawProtectedImageOnProtectedSurface, reporter, o
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Test out DDLs using a protected Vulkan context
|
||||
|
||||
void DDLMakeRenderTargetTestImpl(GrContext* context, skiatest::Reporter* reporter);
|
||||
void DDLMakeRenderTargetTestImpl(GrDirectContext*, skiatest::Reporter*);
|
||||
|
||||
DEF_GPUTEST(VkProtectedContext_DDLMakeRenderTargetTest, reporter, ctxInfo) {
|
||||
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
||||
@ -350,7 +352,7 @@ DEF_GPUTEST(VkProtectedContext_DDLMakeRenderTargetTest, reporter, ctxInfo) {
|
||||
DDLMakeRenderTargetTestImpl(protectedTestHelper->directContext(), reporter);
|
||||
}
|
||||
|
||||
void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter* reporter);
|
||||
void DDLSurfaceCharacterizationTestImpl(GrDirectContext*, skiatest::Reporter*);
|
||||
|
||||
DEF_GPUTEST(VkProtectedContext_DDLSurfaceCharacterizationTest, reporter, ctxInfo) {
|
||||
auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
|
||||
|
Loading…
Reference in New Issue
Block a user