diff options
author | Robert Phillips <robertphillips@google.com> | 2017-01-27 14:28:29 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-27 14:28:40 +0000 |
commit | 2b270e566263e93bcdfe00f858dba1970f5091f4 (patch) | |
tree | 533e6d0f750c4cb908ebb9593293fc4b2e57bd23 /tests/TestUtils.cpp | |
parent | 837e74365e511853df534cc23bd2128c7c235e2f (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/TestUtils.cpp')
-rw-r--r-- | tests/TestUtils.cpp | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp deleted file mode 100644 index 61f4636f66..0000000000 --- a/tests/TestUtils.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "TestUtils.h" - -#if SK_SUPPORT_GPU - -#include "GrSurfaceContext.h" -#include "GrSurfaceProxy.h" - -void test_read_pixels(skiatest::Reporter* reporter, GrContext* context, - GrSurfaceContext* srcContext, uint32_t expectedPixelValues[], - const char* testName) { - int pixelCnt = srcContext->width() * srcContext->height(); - SkAutoTMalloc<uint32_t> pixels(pixelCnt); - memset(pixels.get(), 0, sizeof(uint32_t)*pixelCnt); - - SkImageInfo ii = SkImageInfo::Make(srcContext->width(), srcContext->height(), - kRGBA_8888_SkColorType, kPremul_SkAlphaType); - bool read = srcContext->readPixels(ii, pixels.get(), 0, 0, 0); - if (!read) { - ERRORF(reporter, "%s: Error reading from texture.", testName); - } - - for (int i = 0; i < pixelCnt; ++i) { - if (pixels.get()[i] != expectedPixelValues[i]) { - ERRORF(reporter, "%s: Error, pixel value %d should be 0x%08x, got 0x%08x.", - testName, i, expectedPixelValues[i], pixels.get()[i]); - break; - } - } -} - -void test_write_pixels(skiatest::Reporter* reporter, GrContext* context, - GrSurfaceContext* dstContext, bool expectedToWork, - const char* testName) { - int pixelCnt = dstContext->width() * dstContext->height(); - SkAutoTMalloc<uint32_t> pixels(pixelCnt); - for (int y = 0; y < dstContext->width(); ++y) { - for (int x = 0; x < dstContext->height(); ++x) { - pixels.get()[y * dstContext->width() + x] = GrColorPackRGBA(x, y, x + y, x * y); - } - } - - SkImageInfo ii = SkImageInfo::Make(dstContext->width(), dstContext->height(), - kRGBA_8888_SkColorType, kPremul_SkAlphaType); - bool write = dstContext->writePixels(ii, pixels.get(), 0, 0, 0); - if (!write) { - if (expectedToWork) { - ERRORF(reporter, "%s: Error writing to texture.", testName); - } - return; - } - - if (write && !expectedToWork) { - ERRORF(reporter, "%s: writePixels succeeded when it wasn't supposed to.", testName); - return; - } - - test_read_pixels(reporter, context, dstContext, pixels.get(), testName); -} - -void test_copy_from_surface(skiatest::Reporter* reporter, GrContext* context, - GrSurfaceProxy* proxy, uint32_t expectedPixelValues[], - bool onlyTestRTConfig, const char* testName) { - GrSurfaceDesc copyDstDesc; - copyDstDesc.fConfig = kRGBA_8888_GrPixelConfig; - copyDstDesc.fWidth = proxy->width(); - copyDstDesc.fHeight = proxy->height(); - - for (auto flags : { kNone_GrSurfaceFlags, kRenderTarget_GrSurfaceFlag }) { - if (kNone_GrSurfaceFlags == flags && onlyTestRTConfig) { - continue; - } - - copyDstDesc.fFlags = flags; - - sk_sp<GrSurfaceContext> dstContext(GrSurfaceProxy::TestCopy(context, copyDstDesc, proxy)); - - test_read_pixels(reporter, context, dstContext.get(), expectedPixelValues, testName); - } -} - -void test_copy_to_surface(skiatest::Reporter* reporter, GrContext* context, - GrSurfaceContext* dstContext, const char* testName) { - - int pixelCnt = dstContext->width() * dstContext->height(); - SkAutoTMalloc<uint32_t> pixels(pixelCnt); - for (int y = 0; y < dstContext->width(); ++y) { - for (int x = 0; x < dstContext->height(); ++x) { - pixels.get()[y * dstContext->width() + x] = GrColorPackRGBA(y, x, x * y, x *+ y); - } - } - - GrSurfaceDesc copySrcDesc; - copySrcDesc.fConfig = kRGBA_8888_GrPixelConfig; - copySrcDesc.fWidth = dstContext->width(); - copySrcDesc.fHeight = dstContext->height(); - - for (auto flags : { kNone_GrSurfaceFlags, kRenderTarget_GrSurfaceFlag }) { - copySrcDesc.fFlags = flags; - - sk_sp<GrSurfaceProxy> src(GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), - copySrcDesc, - SkBudgeted::kYes, pixels.get(), 0)); - dstContext->copy(src.get()); - - test_read_pixels(reporter, context, dstContext, pixels.get(), testName); - } -} - -#endif |