diff options
author | Robert Phillips <robertphillips@google.com> | 2018-03-21 12:13:37 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-21 17:04:18 +0000 |
commit | abf7b763e2c1ba069942dedec914494817fd27a8 (patch) | |
tree | c956480efd2273f0371823d3ebf0a3af46c09cab /tests/DeferredDisplayListTest.cpp | |
parent | e65a5cd3fc34ab90743056ace2ef0a3a01bf6346 (diff) |
Add texture-specific flags for External & Rectangle textures
For DDLs, Ganesh needs to know about External & Rectangle textures prior to instantiation (or PromiseImage fulfillment). These new flags allow the client to provide this information when the lazyProxy is created.
The new texture flags work analogously to the render target flags:
GrSurface and GrSurfaceProxy get a new set of accessors for the new flags
The new flags are set appropriately on a GrGLTexture when it is created
For wrapped texture proxies the flags are just copied off of the GrSurface
For lazy-proxies/promise-images the flags are computed up front and passed to the proxy
The GrSurfaceProxy/GrSurface flags equivalence is verified in GrSurfaceProxy::assign
Change-Id: Ia8e1998aa0a36ce4481bfd9e56be21f990e83148
Reviewed-on: https://skia-review.googlesource.com/114985
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.cpp | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp index 9abe5f9ff4..d9aa522125 100644 --- a/tests/DeferredDisplayListTest.cpp +++ b/tests/DeferredDisplayListTest.cpp @@ -11,9 +11,12 @@ #include "GrBackendSurface.h" #include "GrGpu.h" +#include "GrTextureProxyPriv.h" + #include "SkCanvas.h" #include "SkDeferredDisplayListRecorder.h" #include "SkGpuDevice.h" +#include "SkImage_Gpu.h" #include "SkSurface.h" #include "SkSurface_Gpu.h" #include "SkSurfaceCharacterization.h" @@ -406,7 +409,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) { static void dummy_fulfill_proc(void*, GrBackendTexture*) { SkASSERT(0); } static void dummy_release_proc(void*) { SkASSERT(0); } -static void dummy_done_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) { @@ -433,7 +436,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLInvalidRecorder, reporter, ctxInfo) { REPORTER_ASSERT(reporter, !recorder.getCanvas()); REPORTER_ASSERT(reporter, !recorder.detach()); - GrBackendFormat format; + GrBackendFormat format = create_backend_format(context, kRGBA_8888_SkColorType); sk_sp<SkImage> image = recorder.makePromiseTexture(format, 32, 32, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, @@ -464,4 +467,42 @@ 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) { + 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)); + + SkDeferredDisplayListRecorder recorder(characterization); + + for (GrGLenum target : { GR_GL_TEXTURE_EXTERNAL, GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_2D } ) { + GrBackendFormat format = GrBackendFormat::MakeGL(GR_GL_RGBA8, target); + + 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, + dummy_done_proc, + nullptr); + REPORTER_ASSERT(reporter, image); + + GrTextureProxy* backingProxy = ((SkImage_Gpu*) image.get())->peekProxy(); + + if (GR_GL_TEXTURE_2D == target) { + REPORTER_ASSERT(reporter, !backingProxy->texPriv().doesNotSupportMipMaps()); + REPORTER_ASSERT(reporter, !backingProxy->texPriv().isClampOnly()); + } else { + REPORTER_ASSERT(reporter, backingProxy->texPriv().doesNotSupportMipMaps()); + REPORTER_ASSERT(reporter, backingProxy->texPriv().isClampOnly()); + } + } + +} #endif |