diff options
author | Timothy Liang <timliang@google.com> | 2018-07-17 13:28:20 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-18 18:17:32 +0000 |
commit | 760dbc4b53499f891a9e2057524956f8381535e3 (patch) | |
tree | 1fd1d7ba614122c5532e985594c202084f635098 /tests/GrTestingBackendTextureUploadTest.cpp | |
parent | 8f8bf8880d9d9fe8280fa29304063ecc7207e59f (diff) |
Reland "implemented metal gpu backend texture upload testing"
This reverts commit a80a012456a95a6996a8901268ec34ed0cc3aecb.
Reason for revert: Fix bot failure.
Original change's description:
> Revert "implemented metal gpu backend texture upload testing"
>
> This reverts commit 36848f6b30ddaca461c98e13b9976b2c449ca547.
>
> Reason for revert: Test-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Debug-All-Android_CCPR failing.
>
> Original change's description:
> > implemented metal gpu backend texture upload testing
> >
> > Bug: skia:
> > Change-Id: Ia3af58a0710f7f9792b37682a3cc45dd14282b71
> > Reviewed-on: https://skia-review.googlesource.com/140248
> > Commit-Queue: Timothy Liang <timliang@google.com>
> > Reviewed-by: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,ethannicholas@google.com,timliang@google.com
>
> Change-Id: Idf40fc78b82aec1efbcc64221b6d2bbf63353960
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:
> Reviewed-on: https://skia-review.googlesource.com/141182
> Reviewed-by: Timothy Liang <timliang@google.com>
> Commit-Queue: Timothy Liang <timliang@google.com>
Bug: skia:
Change-Id: Ib8c5b2e0cf9de25c11c14741a32846bcc874d712
Reviewed-on: https://skia-review.googlesource.com/141183
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Timothy Liang <timliang@google.com>
Diffstat (limited to 'tests/GrTestingBackendTextureUploadTest.cpp')
-rw-r--r-- | tests/GrTestingBackendTextureUploadTest.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/GrTestingBackendTextureUploadTest.cpp b/tests/GrTestingBackendTextureUploadTest.cpp new file mode 100644 index 0000000000..e4fec187dc --- /dev/null +++ b/tests/GrTestingBackendTextureUploadTest.cpp @@ -0,0 +1,84 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkTypes.h" + +#include "GrGpu.h" +#include "GrContextPriv.h" +#include "GrTexture.h" +#include "SkConvertPixels.h" +#include "Test.h" +#include "TestUtils.h" + +void testing_only_texture_test(skiatest::Reporter* reporter, GrContext* context, GrColorType ct, + bool renderTarget, bool doDataUpload, GrMipMapped mipMapped) { + const int kWidth = 16; + const int kHeight = 16; + SkAutoTMalloc<GrColor> srcBuffer; + if (doDataUpload) { + srcBuffer.reset(kWidth * kHeight); + fill_pixel_data(kWidth, kHeight, srcBuffer.get()); + } + SkAutoTMalloc<GrColor> dstBuffer(kWidth * kHeight); + + GrGpu* gpu = context->contextPriv().getGpu(); + + GrPixelConfig config = GrColorTypeToPixelConfig(ct, GrSRGBEncoded::kNo); + if (!gpu->caps()->isConfigTexturable(config)) { + return; + } + if (gpu->caps()->supportedReadPixelsColorType(config, ct) != ct) { + return; + } + + GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(srcBuffer, + kWidth, + kHeight, + config, + renderTarget, + mipMapped); + sk_sp<GrTexture> wrappedTex; + if (renderTarget) { + wrappedTex = gpu->wrapRenderableBackendTexture(backendTex, 1, + GrWrapOwnership::kAdopt_GrWrapOwnership); + } else { + wrappedTex = gpu->wrapBackendTexture(backendTex, + GrWrapOwnership::kAdopt_GrWrapOwnership); + } + REPORTER_ASSERT(reporter, wrappedTex); + + int rowBytes = GrColorTypeBytesPerPixel(ct) * kWidth; + bool result = gpu->readPixels(wrappedTex.get(), 0, 0, kWidth, + kHeight, ct, dstBuffer, rowBytes); + + if (!doDataUpload) { + // createTestingOnlyBackendTexture will fill the texture with 0's if no data is provided, so + // we set the expected result likewise. + srcBuffer.reset(kWidth * kHeight); + memset(srcBuffer, 0, kWidth * kHeight * sizeof(GrColor)); + } + REPORTER_ASSERT(reporter, result); + REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer, dstBuffer, + kWidth, kHeight)); +} + +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrTestingBackendTextureUploadTest, reporter, ctxInfo) { + for (auto colorType: {GrColorType::kRGBA_8888, GrColorType::kBGRA_8888}) { + for (bool renderable: {true, false}) { + for (bool doDataUpload: {true, false}) { + testing_only_texture_test(reporter, ctxInfo.grContext(), colorType, + renderable, doDataUpload, GrMipMapped::kNo); + + if (!doDataUpload) { + testing_only_texture_test(reporter, ctxInfo.grContext(), colorType, + renderable, doDataUpload, GrMipMapped::kYes); + } + } + } + } +} + |