aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-03-30 13:57:00 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-30 19:12:26 +0000
commit6b6fcc78620270ec2dcd57bd520ec500f60f4505 (patch)
tree4a08bccfd3485a582aa4e10c1e73047ef705fdac /tests
parent26339bf9a86b5f06747afe8e8bd92e3e6d8b703f (diff)
Add SkSurface factory that takes an SkSurfaceCharacterization
TBR=bsalomon@google.com Change-Id: Ie38123dc7c35005bfe8500bf4a16e0d16bbf36bd Reviewed-on: https://skia-review.googlesource.com/117236 Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/DeferredDisplayListTest.cpp49
1 files changed, 42 insertions, 7 deletions
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp
index d9aa522125..ddbb4a84c0 100644
--- a/tests/DeferredDisplayListTest.cpp
+++ b/tests/DeferredDisplayListTest.cpp
@@ -121,13 +121,7 @@ public:
}
}
- // Create a DDL whose characterization captures the current settings
- std::unique_ptr<SkDeferredDisplayList> createDDL(GrContext* context) const {
- sk_sp<SkSurface> s = this->make(context);
- if (!s) {
- return nullptr;
- }
-
+ SkSurfaceCharacterization createCharacterization(GrContext* context) const {
int maxResourceCount;
size_t maxResourceBytes;
context->getResourceCacheLimits(&maxResourceCount, &maxResourceBytes);
@@ -141,6 +135,12 @@ public:
SkSurfaceCharacterization c = context->threadSafeProxy()->createCharacterization(
maxResourceBytes, ii, backendFormat, fSampleCount,
fOrigin, fSurfaceProps, fShouldCreateMipMaps);
+ return c;
+ }
+
+ // Create a DDL whose characterization captures the current settings
+ std::unique_ptr<SkDeferredDisplayList> createDDL(GrContext* context) const {
+ SkSurfaceCharacterization c = this->createCharacterization(context);
SkAssertResult(c.isValid());
SkDeferredDisplayListRecorder r(c);
@@ -205,6 +205,7 @@ private:
bool fShouldCreateMipMaps;
};
+////////////////////////////////////////////////////////////////////////////////
// This tests SkSurfaceCharacterization/SkSurface compatibility
DEF_GPUTEST_FOR_ALL_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
@@ -258,6 +259,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctxInfo)
}
if (SurfaceParameters::kMipMipCount == i && !context->caps()->mipMapSupport()) {
+ // If changing the mipmap setting won't result in a different surface characterization,
+ // skip this step
continue;
}
@@ -345,6 +348,35 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctxInfo)
}
}
+////////////////////////////////////////////////////////////////////////////////
+// This tests the SkSurface::MakeRenderTarget variant that takes an SkSurfaceCharacterization.
+// In particular, the SkSurface and the SkSurfaceCharacterization should always be compatible.
+DEF_GPUTEST_FOR_ALL_CONTEXTS(DDLMakeRenderTargetTest, reporter, ctxInfo) {
+ GrContext* context = ctxInfo.grContext();
+
+ for (int i = 0; i < SurfaceParameters::kNumParams; ++i) {
+ SurfaceParameters params;
+ params.modify(i);
+
+ SkSurfaceCharacterization c = params.createCharacterization(context);
+
+ sk_sp<SkSurface> s = params.make(context);
+ if (!s) {
+ REPORTER_ASSERT(reporter, !c.isValid());
+ continue;
+ }
+
+ REPORTER_ASSERT(reporter, c.isValid());
+
+ s = SkSurface::MakeRenderTarget(context, c, SkBudgeted::kYes);
+ REPORTER_ASSERT(reporter, s);
+
+ SkSurface_Gpu* g = static_cast<SkSurface_Gpu*>(s.get());
+ REPORTER_ASSERT(reporter, g->isCompatible(c));
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
static constexpr int kSize = 8;
struct TextureReleaseChecker {
@@ -411,6 +443,7 @@ static void dummy_fulfill_proc(void*, GrBackendTexture*) { SkASSERT(0); }
static void dummy_release_proc(void*) { SkASSERT(0); }
static void dummy_done_proc(void*) { }
+////////////////////////////////////////////////////////////////////////////////
// Test out the behavior of an invalid DDLRecorder
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLInvalidRecorder, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
@@ -450,6 +483,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLInvalidRecorder, reporter, ctxInfo) {
}
+////////////////////////////////////////////////////////////////////////////////
// Ensure that flushing while DDL recording doesn't cause a crash
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLFlushWhileRecording, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
@@ -467,6 +501,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLFlushWhileRecording, reporter, ctxInfo) {
canvas->getGrContext()->flush();
}
+////////////////////////////////////////////////////////////////////////////////
// Check that the texture-specific flags (i.e., for external & rectangle textures) work
// for promise images. As such, this is a GL-only test.
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DDLTextureFlagsTest, reporter, ctxInfo) {