diff options
author | Robert Phillips <robertphillips@google.com> | 2017-01-27 10:11:42 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-27 15:52:20 +0000 |
commit | 3500b77f7d08dbe4c17811733cc3e4dbab889f0a (patch) | |
tree | e9e7582c09ddd926d9486a1e5a0497e8cb0831b6 /tests/EGLImageTest.cpp | |
parent | 052fd5158f7f85e478a9f87c45fecaacf7d0f5f3 (diff) |
Consolidate read/write-Pixels testing code - take 2
Change-Id: I0de058a9eec749a7086138ac2eb79732f06ce55e
Reviewed-on: https://skia-review.googlesource.com/7650
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/EGLImageTest.cpp')
-rw-r--r-- | tests/EGLImageTest.cpp | 66 |
1 files changed, 10 insertions, 56 deletions
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp index 79d326156a..02ba4a82df 100644 --- a/tests/EGLImageTest.cpp +++ b/tests/EGLImageTest.cpp @@ -6,6 +6,7 @@ */ #include "Test.h" +#include "TestUtils.h" #if SK_SUPPORT_GPU #include "GrContext.h" #include "GrContextPriv.h" @@ -41,58 +42,6 @@ static void cleanup(GLTestContext* glctx0, GrGLuint texID0, GLTestContext* glctx } } -static void test_read_pixels(skiatest::Reporter* reporter, GrContext* context, - GrSurfaceContext* externalTextureContext, - uint32_t expectedPixelValues[]) { - int pixelCnt = externalTextureContext->width() * externalTextureContext->height(); - SkAutoTMalloc<uint32_t> pixels(pixelCnt); - memset(pixels.get(), 0, sizeof(uint32_t)*pixelCnt); - - SkImageInfo ii = SkImageInfo::Make(externalTextureContext->width(), - externalTextureContext->height(), - kRGBA_8888_SkColorType, kPremul_SkAlphaType); - bool read = externalTextureContext->readPixels(ii, pixels.get(), 0, 0, 0); - if (!read) { - ERRORF(reporter, "Error reading external texture."); - } - for (int i = 0; i < pixelCnt; ++i) { - if (pixels.get()[i] != expectedPixelValues[i]) { - ERRORF(reporter, "Error, external texture pixel value %d should be 0x%08x," - " got 0x%08x.", i, expectedPixelValues[i], pixels.get()[i]); - break; - } - } -} - -static void test_write_pixels(skiatest::Reporter* reporter, GrContext* context, - GrSurfaceContext* externalTextureContext) { - int pixelCnt = externalTextureContext->width() * externalTextureContext->height(); - SkAutoTMalloc<uint32_t> pixels(pixelCnt); - memset(pixels.get(), 0, sizeof(uint32_t)*pixelCnt); - - SkImageInfo ii = SkImageInfo::Make(externalTextureContext->width(), - externalTextureContext->height(), - kRGBA_8888_SkColorType, kPremul_SkAlphaType); - bool write = externalTextureContext->writePixels(ii, pixels.get(), 0, 0, 0); - REPORTER_ASSERT_MESSAGE(reporter, !write, "Should not be able to write to a EXTERNAL" - " texture."); -} - -static void test_copy_surface(skiatest::Reporter* reporter, GrContext* context, - GrSurfaceProxy* externalTextureProxy, - uint32_t expectedPixelValues[]) { - GrSurfaceDesc copyDesc; - copyDesc.fConfig = kRGBA_8888_GrPixelConfig; - copyDesc.fWidth = externalTextureProxy->width(); - copyDesc.fHeight = externalTextureProxy->height(); - copyDesc.fFlags = kRenderTarget_GrSurfaceFlag; - - sk_sp<GrSurfaceContext> copyContext(GrSurfaceProxy::TestCopy(context, copyDesc, - externalTextureProxy)); - - test_read_pixels(reporter, context, copyContext.get(), expectedPixelValues); -} - DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) { GrContext* context0 = ctxInfo.grContext(); sk_gpu_test::GLTestContext* glCtx0 = ctxInfo.glContext(); @@ -223,12 +172,17 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) { externalDesc.fSampleCnt = 0; } - test_read_pixels(reporter, context0, externalTextureContext.get(), pixels.get()); + test_read_pixels(reporter, context0, externalTextureContext.get(), pixels.get(), + "EGLImageTest-read"); - test_write_pixels(reporter, context0, externalTextureContext.get()); + // We should not be able to write to a EXTERNAL texture + test_write_pixels(reporter, context0, externalTextureContext.get(), false, + "EGLImageTest-write"); - test_copy_surface(reporter, context0, externalTextureContext->asDeferredSurface(), - pixels.get()); + // Only test RT-config + // TODO: why do we always need to draw to copy from an external texture? + test_copy_from_surface(reporter, context0, externalTextureContext->asDeferredSurface(), + pixels.get(), true, "EGLImageTest-copy"); cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, backendTexture1, image); } |