aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ReadWriteAlphaTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-03-07 13:01:25 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-07 18:22:40 +0000
commit58389b90cd387533021c109eb28da40c08e0ead5 (patch)
tree7744ee9c23c74c61aa00a3cc01eff74cedb8f541 /tests/ReadWriteAlphaTest.cpp
parentab6fd7ef91aeca8a3fbbc6c6670cb89a5a7b6d53 (diff)
Initial texture data is never flipped when uploaded.
The first bytes of the data always refer to the pixel accessed by texture coord (0, 0). Change-Id: I708702d90f35b3bc896a48c3c3fd6a0be73f505a Reviewed-on: https://skia-review.googlesource.com/112261 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/ReadWriteAlphaTest.cpp')
-rw-r--r--tests/ReadWriteAlphaTest.cpp44
1 files changed, 19 insertions, 25 deletions
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index f495fc2b08..eaad411d5a 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -9,7 +9,6 @@
// This test is specific to the GPU backend.
#if SK_SUPPORT_GPU
-
#include "GrContext.h"
#include "GrContextPriv.h"
#include "GrProxyProvider.h"
@@ -17,6 +16,7 @@
#include "GrSurfaceContext.h"
#include "GrSurfaceProxy.h"
#include "GrTextureProxy.h"
+#include "ProxyUtils.h"
#include "SkCanvas.h"
#include "SkSurface.h"
@@ -26,12 +26,12 @@ static const int Y_SIZE = 13;
static void validate_alpha_data(skiatest::Reporter* reporter, int w, int h, const uint8_t* actual,
size_t actualRowBytes, const uint8_t* expected, SkString extraMsg,
- GrPixelConfig config) {
+ GrColorType colorType) {
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
uint8_t a = actual[y * actualRowBytes + x];
uint8_t e = expected[y * w + x];
- if (kRGBA_1010102_GrPixelConfig == config) {
+ if (GrColorType::kRGBA_1010102 == colorType) {
// This config only preserves two bits of alpha
a >>= 6;
e >>= 6;
@@ -66,8 +66,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
// We are initializing the texture with zeros here
memset(alphaData, 0, X_SIZE * Y_SIZE);
- sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
- desc, kTopLeft_GrSurfaceOrigin, SkBudgeted::kNo, alphaData, 0);
+ sk_sp<GrTextureProxy> proxy =
+ proxyProvider->createTextureProxy(desc, SkBudgeted::kNo, alphaData, 0);
if (!proxy) {
ERRORF(reporter, "Could not create alpha texture.");
return;
@@ -105,7 +105,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
SkString msg;
msg.printf("rb:%d A8", SkToU32(rowBytes));
validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes,
- alphaData, msg, kAlpha_8_GrPixelConfig);
+ alphaData, msg, GrColorType::kAlpha_8);
// Now try writing to a single channel surface (if we could create one).
if (surf) {
@@ -146,11 +146,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
}
}
- static const GrPixelConfig kRGBAConfigs[] {
- kRGBA_8888_GrPixelConfig,
- kBGRA_8888_GrPixelConfig,
- kSRGBA_8888_GrPixelConfig,
- kRGBA_1010102_GrPixelConfig,
+ static constexpr struct {
+ GrColorType fColorType;
+ GrSRGBEncoded fSRGBEncoded;
+ } kInfos[] = {
+ {GrColorType::kRGBA_8888, GrSRGBEncoded::kNo},
+ {GrColorType::kBGRA_8888, GrSRGBEncoded::kNo},
+ {GrColorType::kRGBA_8888, GrSRGBEncoded::kYes},
+ {GrColorType::kRGBA_1010102, GrSRGBEncoded::kNo},
};
for (int y = 0; y < Y_SIZE; ++y) {
@@ -165,14 +168,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
// Attempt to read back just alpha from a RGBA/BGRA texture. Once with a texture-only src and
// once with a render target.
- for (auto config : kRGBAConfigs) {
+ for (auto info : kInfos) {
for (int rt = 0; rt < 2; ++rt) {
- GrSurfaceDesc desc;
- desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
- desc.fConfig = config;
- desc.fWidth = X_SIZE;
- desc.fHeight = Y_SIZE;
-
uint32_t rgbaData[X_SIZE * Y_SIZE];
// Make the alpha channel of the rgba texture come from alphaData.
for (int y = 0; y < Y_SIZE; ++y) {
@@ -182,13 +179,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
}
auto origin = rt ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
- sk_sp<GrTextureProxy> proxy =
- proxyProvider->createTextureProxy(desc, origin, SkBudgeted::kNo, rgbaData, 0);
+ auto proxy = sk_gpu_test::MakeTextureProxyFromData(context, rt, X_SIZE, Y_SIZE,
+ info.fColorType, info.fSRGBEncoded,
+ origin, rgbaData, 0);
if (!proxy) {
- // We always expect to be able to create a RGBA texture
- if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) {
- ERRORF(reporter, "Failed to create RGBA texture.");
- }
continue;
}
@@ -214,7 +208,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
SkString msg;
msg.printf("rt:%d, rb:%d 8888", rt, SkToU32(rowBytes));
validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes,
- alphaData, msg, config);
+ alphaData, msg, info.fColorType);
}
}
}