aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/DeferredDisplayListTest.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-02-13 10:20:13 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-13 16:03:50 +0000
commitd76e56d93c27856b10d6636882a5ffcd79a9d967 (patch)
treee20c54f11793cfbc57fa4b878d95931ae80a020d /tests/DeferredDisplayListTest.cpp
parent366093f2124c38fa5c590c9ed2d1811817fed8ee (diff)
Add SkCharacterization creation helper to GrContextThreadSafeProxy
Change-Id: I8ad7cf335f2b586cf501eaa70573690fbbd53efa Reviewed-on: https://skia-review.googlesource.com/106105 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/DeferredDisplayListTest.cpp')
-rw-r--r--tests/DeferredDisplayListTest.cpp65
1 files changed, 60 insertions, 5 deletions
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp
index 468a3695e9..13989a18d7 100644
--- a/tests/DeferredDisplayListTest.cpp
+++ b/tests/DeferredDisplayListTest.cpp
@@ -20,6 +20,51 @@
#include "SkSurfaceProps.h"
#include "Test.h"
+#include "gl/GrGLDefines.h"
+#ifdef SK_VULKAN
+#include "vk/GrVkDefines.h"
+#endif
+
+static GrBackendFormat create_backend_format(GrContext* context, SkColorType colorType) {
+ const GrCaps* caps = context->caps();
+
+ switch (context->contextPriv().getBackend()) {
+ case kOpenGL_GrBackend:
+ if (kRGBA_8888_SkColorType == colorType) {
+ GrGLenum format = caps->srgbSupport() ? GR_GL_SRGB8_ALPHA8 : GR_GL_RGBA8;
+ return GrBackendFormat::MakeGL(format, GR_GL_TEXTURE_2D);
+ } else if (kRGBA_F16_SkColorType == colorType) {
+ return GrBackendFormat::MakeGL(GR_GL_RGBA16F, GR_GL_TEXTURE_2D);
+ }
+ break;
+#ifdef SK_VULKAN
+ case kVulkan_GrBackend:
+ if (kRGBA_8888_SkColorType == colorType) {
+ VkFormat format = caps->srgbSupport() ? VK_FORMAT_R8G8B8A8_SRGB
+ : VK_FORMAT_B8G8R8A8_UNORM;
+ return GrBackendFormat::MakeVK(format);
+ } else if (kRGBA_F16_SkColorType == colorType) {
+ return GrBackendFormat::MakeVK(VK_FORMAT_R16G16B16A16_SFLOAT);
+ }
+ break;
+#endif
+ case kMock_GrBackend:
+ if (kRGBA_8888_SkColorType == colorType) {
+ GrPixelConfig config = caps->srgbSupport() ? kSRGBA_8888_GrPixelConfig
+ : kRGBA_8888_GrPixelConfig;
+ return GrBackendFormat::MakeMock(config);
+ } else if (kRGBA_F16_SkColorType == colorType) {
+ return GrBackendFormat::MakeMock(kRGBA_half_GrPixelConfig);
+ }
+ break;
+ default:
+ return GrBackendFormat(); // return an invalid format
+ }
+
+ return GrBackendFormat(); // return an invalid format
+}
+
+
class SurfaceParameters {
public:
static const int kNumParams = 9;
@@ -80,8 +125,20 @@ public:
return nullptr;
}
- SkSurfaceCharacterization c;
- SkAssertResult(s->characterize(&c));
+ int maxResourceCount;
+ size_t maxResourceBytes;
+ context->getResourceCacheLimits(&maxResourceCount, &maxResourceBytes);
+
+ // Note that Ganesh doesn't make use of the SkImageInfo's alphaType
+ SkImageInfo ii = SkImageInfo::Make(fWidth, fHeight, fColorType,
+ kPremul_SkAlphaType, fColorSpace);
+
+ GrBackendFormat backendFormat = create_backend_format(context, fColorType);
+
+ SkSurfaceCharacterization c = context->threadSafeProxy()->createCharacterization(
+ maxResourceBytes, ii, backendFormat, fSampleCount,
+ fOrigin, fSurfaceProps, fShouldCreateMipMaps);
+ SkAssertResult(c.isValid());
SkDeferredDisplayListRecorder r(c);
SkCanvas* canvas = r.getCanvas();
@@ -161,6 +218,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctxInfo)
SurfaceParameters params;
ddl = params.createDDL(context);
+ SkAssertResult(ddl);
// The DDL should draw into an SkSurface created with the same parameters
sk_sp<SkSurface> s = params.make(context);
@@ -212,9 +270,6 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctxInfo)
size_t maxResourceBytes;
context->getResourceCacheLimits(&maxResourceCount, &maxResourceBytes);
- context->setResourceCacheLimits(maxResourceCount/2, maxResourceBytes);
- REPORTER_ASSERT(reporter, !s->draw(ddl.get()));
-
context->setResourceCacheLimits(maxResourceCount, maxResourceBytes/2);
REPORTER_ASSERT(reporter, !s->draw(ddl.get()));