aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/EGLImageTest.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-01-27 14:28:29 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-27 14:28:40 +0000
commit2b270e566263e93bcdfe00f858dba1970f5091f4 (patch)
tree533e6d0f750c4cb908ebb9593293fc4b2e57bd23 /tests/EGLImageTest.cpp
parent837e74365e511853df534cc23bd2128c7c235e2f (diff)
Revert "Consolidate read/write-Pixels testing code"
This reverts commit 0bd4a23ef40d74ef051eb7f457c133d5febc377d. Reason for revert: What?!? Original change's description: > Consolidate read/write-Pixels testing code > > Change-Id: I853f8f747ed0040333473fbc722cabac84e6ac83 > Reviewed-on: https://skia-review.googlesource.com/7560 > Commit-Queue: Robert Phillips <robertphillips@google.com> > Reviewed-by: Brian Osman <brianosman@google.com> > TBR=robertphillips@google.com,brianosman@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I9cb049a4f86350f849d00839a55b55fb07e861b0 Reviewed-on: https://skia-review.googlesource.com/7648 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/EGLImageTest.cpp')
-rw-r--r--tests/EGLImageTest.cpp66
1 files changed, 56 insertions, 10 deletions
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index 02ba4a82df..79d326156a 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -6,7 +6,6 @@
*/
#include "Test.h"
-#include "TestUtils.h"
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextPriv.h"
@@ -42,6 +41,58 @@ 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();
@@ -172,17 +223,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
externalDesc.fSampleCnt = 0;
}
- test_read_pixels(reporter, context0, externalTextureContext.get(), pixels.get(),
- "EGLImageTest-read");
+ test_read_pixels(reporter, context0, externalTextureContext.get(), pixels.get());
- // We should not be able to write to a EXTERNAL texture
- test_write_pixels(reporter, context0, externalTextureContext.get(), false,
- "EGLImageTest-write");
+ test_write_pixels(reporter, context0, externalTextureContext.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");
+ test_copy_surface(reporter, context0, externalTextureContext->asDeferredSurface(),
+ pixels.get());
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, backendTexture1, image);
}