aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/DeferredDisplayListTest.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-03-15 16:53:06 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-15 21:25:16 +0000
commit6ceaafa7b9292ba2db52c105cc9692bda9970f08 (patch)
tree68ec7437add944561675451738717677cd8be415 /tests/DeferredDisplayListTest.cpp
parentaf18f22da6c53346a326dcb0c1b237e20ca44fe4 (diff)
Handle GrContext creation failure in DDL
TBR=bsalomon@google.com Change-Id: Ib34448a60cb127ef89bcb0b1f85d07abc91af582 Reviewed-on: https://skia-review.googlesource.com/114569 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/DeferredDisplayListTest.cpp')
-rw-r--r--tests/DeferredDisplayListTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp
index 896a64a5a9..b85388f9c9 100644
--- a/tests/DeferredDisplayListTest.cpp
+++ b/tests/DeferredDisplayListTest.cpp
@@ -404,5 +404,46 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
gpu->deleteTestingOnlyBackendTexture(backendTex);
}
+static void dummy_fulfill_proc(void*, GrBackendTexture*) { SkASSERT(0); }
+static void dummy_release_proc(void*) { SkASSERT(0); }
+
+// Test out the behavior of an invalid DDLRecorder
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLInvalidRecorder, reporter, ctxInfo) {
+ GrContext* context = ctxInfo.grContext();
+
+ {
+ SkImageInfo ii = SkImageInfo::MakeN32Premul(32, 32);
+ sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii);
+
+ SkSurfaceCharacterization characterization;
+ SkAssertResult(s->characterize(&characterization));
+
+ // never calling getCanvas means the backing surface is never allocated
+ SkDeferredDisplayListRecorder recorder(characterization);
+ }
+
+ {
+ SkSurfaceCharacterization invalid;
+
+ SkDeferredDisplayListRecorder recorder(invalid);
+
+ const SkSurfaceCharacterization c = recorder.characterization();
+ REPORTER_ASSERT(reporter, !c.isValid());
+ REPORTER_ASSERT(reporter, !recorder.getCanvas());
+ REPORTER_ASSERT(reporter, !recorder.detach());
+
+ GrBackendFormat format;
+ sk_sp<SkImage> image = recorder.makePromiseTexture(format, 32, 32, GrMipMapped::kNo,
+ kTopLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType,
+ kPremul_SkAlphaType, nullptr,
+ dummy_fulfill_proc,
+ dummy_release_proc,
+ nullptr);
+ REPORTER_ASSERT(reporter, !image);
+ }
+
+}
+
#endif