aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2018-03-02 11:01:10 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-02 18:19:50 +0000
commit10fc6fddf24878f4f34e75c1bcc11e4499edfcc0 (patch)
treeb3bd1d9263dbcf53c688d412e1e719fa97674b23 /tests
parentfde6fa0903b3cedc463c1a753268ffcf30ad7a38 (diff)
Revert "Revert "Add 1010102 support to Ganesh""
This reverts commit ded47a50143470d1acdafa03e878cc7da5608038. Bug: skia: Change-Id: I7d7552e6ccc8591cae91426407ab13b628b93b68 Reviewed-on: https://skia-review.googlesource.com/111760 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/GrSurfaceTest.cpp1
-rw-r--r--tests/ImageGeneratorTest.cpp2
-rw-r--r--tests/ProxyTest.cpp5
-rw-r--r--tests/ReadWriteAlphaTest.cpp29
-rw-r--r--tests/SpecialSurfaceTest.cpp15
-rw-r--r--tests/SurfaceTest.cpp14
-rw-r--r--tests/TestConfigParsing.cpp6
7 files changed, 52 insertions, 20 deletions
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index eb975852d1..a645f99c3e 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -92,6 +92,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
kBGRA_8888_GrPixelConfig,
kSRGBA_8888_GrPixelConfig,
kSBGRA_8888_GrPixelConfig,
+ kRGBA_1010102_GrPixelConfig,
kRGBA_float_GrPixelConfig,
kRG_float_GrPixelConfig,
kAlpha_half_GrPixelConfig,
diff --git a/tests/ImageGeneratorTest.cpp b/tests/ImageGeneratorTest.cpp
index 8a7f0decec..574c8e8728 100644
--- a/tests/ImageGeneratorTest.cpp
+++ b/tests/ImageGeneratorTest.cpp
@@ -90,10 +90,12 @@ DEF_TEST(PictureImageGenerator, reporter) {
{ kRGBA_8888_SkColorType, kPremul_SkAlphaType, kRGBA_8888_SkColorType == kN32_SkColorType },
{ kBGRA_8888_SkColorType, kPremul_SkAlphaType, kBGRA_8888_SkColorType == kN32_SkColorType },
{ kRGBA_F16_SkColorType, kPremul_SkAlphaType, true },
+ { kRGBA_1010102_SkColorType, kPremul_SkAlphaType, true },
{ kRGBA_8888_SkColorType, kUnpremul_SkAlphaType, false },
{ kBGRA_8888_SkColorType, kUnpremul_SkAlphaType, false },
{ kRGBA_F16_SkColorType, kUnpremul_SkAlphaType, false },
+ { kRGBA_1010102_SkColorType, kUnpremul_SkAlphaType, false },
};
auto colorspace = SkColorSpace::MakeSRGB();
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index f48e2a090f..6ad8199849 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -104,7 +104,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
for (auto widthHeight : { 100, 128, 1048576 }) {
for (auto config : { kAlpha_8_GrPixelConfig, kRGB_565_GrPixelConfig,
- kRGBA_8888_GrPixelConfig }) {
+ kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig }) {
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
for (auto numSamples : {1, 4, 16, 128}) {
@@ -196,7 +196,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
return;
}
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
- for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType }) {
+ for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType,
+ kRGBA_1010102_SkColorType }) {
for (auto numSamples : {1, 4}) {
GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, caps);
SkASSERT(kUnknown_GrPixelConfig != config);
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 68a3ee0983..de9422d70e 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -25,11 +25,17 @@ static const int X_SIZE = 13;
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) {
+ size_t actualRowBytes, const uint8_t* expected, SkString extraMsg,
+ GrPixelConfig config) {
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) {
+ // This config only preserves two bits of alpha
+ a >>= 6;
+ e >>= 6;
+ }
if (e != a) {
ERRORF(reporter,
"Failed alpha readback. Expected: 0x%02x, Got: 0x%02x at (%d,%d), %s",
@@ -87,9 +93,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, result, "Initial A8 writePixels failed");
size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE;
- std::unique_ptr<uint8_t[]> readback(new uint8_t[nonZeroRowBytes * Y_SIZE]);
+ size_t bufLen = nonZeroRowBytes * Y_SIZE;
+ std::unique_ptr<uint8_t[]> readback(new uint8_t[bufLen]);
// clear readback to something non-zero so we can detect readback failures
- memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE);
+ memset(readback.get(), kClearValue, bufLen);
// read the texture back
result = sContext->readPixels(ii, readback.get(), rowBytes, 0, 0);
@@ -99,7 +106,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);
+ alphaData, msg, kAlpha_8_GrPixelConfig);
// Now try writing to a single channel surface (if we could create one).
if (surf) {
@@ -113,7 +120,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
canvas->drawRect(rect, paint);
- memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE);
+ // Workaround for a bug in old GCC/glibc used in our Chromecast toolchain:
+ // error: call to '__warn_memset_zero_len' declared with attribute warning:
+ // memset used with constant zero length parameter; this could be due
+ // to transposed parameters
+ // See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294
+ if (bufLen > 0) {
+ memset(readback.get(), kClearValue, bufLen);
+ }
result = surf->readPixels(ii, readback.get(), nonZeroRowBytes, 0, 0);
REPORTER_ASSERT(reporter, result, "A8 readPixels after clear failed");
@@ -136,7 +150,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
static const GrPixelConfig kRGBAConfigs[] {
kRGBA_8888_GrPixelConfig,
kBGRA_8888_GrPixelConfig,
- kSRGBA_8888_GrPixelConfig
+ kSRGBA_8888_GrPixelConfig,
+ kRGBA_1010102_GrPixelConfig,
};
for (int y = 0; y < Y_SIZE; ++y) {
@@ -200,7 +215,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);
+ alphaData, msg, config);
}
}
}
diff --git a/tests/SpecialSurfaceTest.cpp b/tests/SpecialSurfaceTest.cpp
index a336cf669d..40de08de85 100644
--- a/tests/SpecialSurfaceTest.cpp
+++ b/tests/SpecialSurfaceTest.cpp
@@ -80,12 +80,15 @@ DEF_TEST(SpecialSurface_Raster2, reporter) {
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu1, reporter, ctxInfo) {
- sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(ctxInfo.grContext(),
- kSmallerSize, kSmallerSize,
- kRGBA_8888_GrPixelConfig,
- nullptr));
-
- test_surface(surf, reporter, 0);
+ for (auto config : { kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig }) {
+ if (!ctxInfo.grContext()->caps()->isConfigRenderable(config)) {
+ continue;
+ }
+ sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(ctxInfo.grContext(),
+ kSmallerSize, kSmallerSize,
+ config, nullptr));
+ test_surface(surf, reporter, 0);
+ }
}
#endif
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index ab91061094..35b72a972e 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -932,6 +932,7 @@ static void test_surface_creation_and_snapshot_with_color_space(
skiatest::Reporter* reporter,
const char* prefix,
bool f16Support,
+ bool supports1010102,
std::function<sk_sp<SkSurface>(const SkImageInfo&)> surfaceMaker) {
auto srgbColorSpace = SkColorSpace::MakeSRGB();
@@ -960,6 +961,7 @@ static void test_surface_creation_and_snapshot_with_color_space(
{ kRGBA_F16_SkColorType, oddColorSpace, false, "F16-odd" },
{ kRGB_565_SkColorType, srgbColorSpace, false, "565-srgb" },
{ kAlpha_8_SkColorType, srgbColorSpace, false, "A8-srgb" },
+ { kRGBA_1010102_SkColorType, nullptr, true, "1010102-nullptr" },
};
for (auto& testConfig : testConfigs) {
@@ -970,7 +972,8 @@ static void test_surface_creation_and_snapshot_with_color_space(
// For some GPU contexts (eg ANGLE), we don't have f16 support, so we should fail to create
// any surface of that type:
bool shouldWork = testConfig.fShouldWork &&
- (f16Support || kRGBA_F16_SkColorType != testConfig.fColorType);
+ (f16Support || kRGBA_F16_SkColorType != testConfig.fColorType) &&
+ (supports1010102 || kRGBA_1010102_SkColorType != testConfig.fColorType);
auto surface(surfaceMaker(info));
REPORTER_ASSERT(reporter, SkToBool(surface) == shouldWork, fullTestName.c_str());
@@ -990,7 +993,8 @@ DEF_TEST(SurfaceCreationWithColorSpace, reporter) {
return SkSurface::MakeRaster(info);
};
- test_surface_creation_and_snapshot_with_color_space(reporter, "raster", true, surfaceMaker);
+ test_surface_creation_and_snapshot_with_color_space(reporter, "raster", true, true,
+ surfaceMaker);
}
#if SK_SUPPORT_GPU
@@ -998,11 +1002,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter,
GrContext* context = ctxInfo.grContext();
bool f16Support = context->caps()->isConfigRenderable(kRGBA_half_GrPixelConfig);
+ bool supports1010102 = context->caps()->isConfigRenderable(kRGBA_1010102_GrPixelConfig);
auto surfaceMaker = [context](const SkImageInfo& info) {
return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
};
- test_surface_creation_and_snapshot_with_color_space(reporter, "gpu", f16Support, surfaceMaker);
+ test_surface_creation_and_snapshot_with_color_space(reporter, "gpu", f16Support,
+ supports1010102, surfaceMaker);
std::vector<GrBackendTexture> backendTextures;
auto wrappedSurfaceMaker = [ context, &backendTextures ](const SkImageInfo& info) {
@@ -1028,7 +1034,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter,
};
test_surface_creation_and_snapshot_with_color_space(reporter, "wrapped", f16Support,
- wrappedSurfaceMaker);
+ supports1010102, wrappedSurfaceMaker);
context->flush();
diff --git a/tests/TestConfigParsing.cpp b/tests/TestConfigParsing.cpp
index ec69235ccc..6ff1fd830f 100644
--- a/tests/TestConfigParsing.cpp
+++ b/tests/TestConfigParsing.cpp
@@ -110,7 +110,8 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
"mtl",
"gl4444",
"gl565",
- "gltestthreading"
+ "gltestthreading",
+ "gl1010102",
});
SkCommandLineConfigArray configs;
@@ -200,6 +201,9 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
REPORTER_ASSERT(reporter, configs[35]->asConfigGpu()->getAlphaType() == kOpaque_SkAlphaType);
REPORTER_ASSERT(reporter, configs[36]->asConfigGpu());
REPORTER_ASSERT(reporter, configs[36]->asConfigGpu()->getTestThreading());
+ REPORTER_ASSERT(reporter, configs[37]->asConfigGpu());
+ REPORTER_ASSERT(reporter, configs[37]->asConfigGpu()->getColorType() ==
+ kRGBA_1010102_SkColorType);
#endif
}