Remove pixel write/read tests.

I found myself updating these for another change and realized they
are very limited tests that are redundant with more thorough tests.

Change-Id: I935da4d1da7ff3825a4042556845a8eb659b6ba8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346856
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2020-12-22 21:56:08 -05:00 committed by Skia Commit-Bot
parent 4e0e8d4124
commit 6bba3d8a5a
9 changed files with 15 additions and 548 deletions

View File

@ -121,7 +121,6 @@ tests_sources = [
"$_tests/GrTextBlobTest.cpp",
"$_tests/GrTextureMipMapInvalidationTest.cpp",
"$_tests/GrThreadSafeCacheTest.cpp",
"$_tests/GrUploadPixelsTests.cpp",
"$_tests/GrVxTest.cpp",
"$_tests/GradientTest.cpp",
"$_tests/HSVRoundTripTest.cpp",
@ -186,7 +185,6 @@ tests_sources = [
"$_tests/PDFTaggedTableTest.cpp",
"$_tests/PDFTaggedTest.cpp",
"$_tests/PackBitsTest.cpp",
"$_tests/PackedConfigsTextureTest.cpp",
"$_tests/PaintTest.cpp",
"$_tests/ParametricStageTest.cpp",
"$_tests/ParseColorTest.cpp",
@ -217,7 +215,6 @@ tests_sources = [
"$_tests/RTreeTest.cpp",
"$_tests/RandomTest.cpp",
"$_tests/ReadPixelsTest.cpp",
"$_tests/ReadWriteAlphaTest.cpp",
"$_tests/RecordDrawTest.cpp",
"$_tests/RecordOptsTest.cpp",
"$_tests/RecordPatternTest.cpp",

View File

@ -874,12 +874,6 @@ func (b *taskBuilder) dmFlags(internalHardwareLabel string) {
match = append(match, "~Once", "~Shared") // Not sure what's up with these tests.
}
if b.extraConfig("TSAN") {
match = append(match, "~ReadWriteAlpha") // Flaky on TSAN-covered on nvidia bots.
match = append(match, "~RGBA4444TextureTest", // Flakier than they are important.
"~RGB565TextureTest")
}
// By default, we test with GPU threading enabled, unless specifically
// disabled.
if b.extraConfig("NoGPUThreads") {

File diff suppressed because one or more lines are too long

View File

@ -1,104 +0,0 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
// This is a GPU-backend specific test. It relies on static intializers to work
#include "include/core/SkTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrSurfaceContext.h"
#include "src/gpu/GrSurfaceProxy.h"
#include "src/gpu/SkGr.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"
#include "tools/gpu/GrContextFactory.h"
#include "tools/gpu/ProxyUtils.h"
using sk_gpu_test::GrContextFactory;
void basic_texture_test(skiatest::Reporter* reporter, GrDirectContext* dContext, SkColorType ct,
GrRenderable renderable) {
const int kWidth = 16;
const int kHeight = 16;
SkAutoTMalloc<GrColor> srcBuffer(kWidth*kHeight);
SkAutoTMalloc<GrColor> dstBuffer(kWidth*kHeight);
FillPixelData(kWidth, kHeight, srcBuffer.get());
auto info = SkImageInfo::Make({kWidth, kHeight}, ct, kPremul_SkAlphaType, nullptr);
auto view = sk_gpu_test::MakeTextureProxyViewFromData(dContext,
renderable,
kTopLeft_GrSurfaceOrigin,
info,
srcBuffer,
/*row bytes*/ 0);
REPORTER_ASSERT(reporter, view);
if (view) {
auto sContext = GrSurfaceContext::Make(dContext, std::move(view), info.colorInfo());
SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
bool result = sContext->readPixels(dContext, dstInfo, dstBuffer, 0, {0, 0});
REPORTER_ASSERT(reporter, result);
REPORTER_ASSERT(reporter,
DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, kWidth, kHeight));
dstInfo = SkImageInfo::Make(10, 2, ct, kPremul_SkAlphaType);
result = sContext->writePixels(dContext, dstInfo, srcBuffer, 0, {2, 10});
REPORTER_ASSERT(reporter, result);
memset(dstBuffer, 0, kWidth*kHeight*sizeof(GrColor));
result = sContext->readPixels(dContext, dstInfo, dstBuffer, 0, {2, 10});
REPORTER_ASSERT(reporter, result);
REPORTER_ASSERT(reporter, DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, 10, 2));
}
view = sk_gpu_test::MakeTextureProxyViewFromData(dContext,
renderable,
kBottomLeft_GrSurfaceOrigin,
info,
srcBuffer,
0);
REPORTER_ASSERT(reporter, view);
if (view) {
auto sContext = GrSurfaceContext::Make(dContext, std::move(view), info.colorInfo());
SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
bool result = sContext->readPixels(dContext, dstInfo, dstBuffer, 0, {0, 0});
REPORTER_ASSERT(reporter, result);
REPORTER_ASSERT(reporter,
DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, kWidth, kHeight));
dstInfo = SkImageInfo::Make(4, 5, ct, kPremul_SkAlphaType);
result = sContext->writePixels(dContext, dstInfo, srcBuffer, 0, {5, 4});
REPORTER_ASSERT(reporter, result);
memset(dstBuffer, 0, kWidth*kHeight*sizeof(GrColor));
result = sContext->readPixels(dContext, dstInfo, dstBuffer, 0, {5, 4});
REPORTER_ASSERT(reporter, result);
REPORTER_ASSERT(reporter, DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, 4, 5));
}
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrUploadPixelsTests, reporter, ctxInfo) {
auto direct = ctxInfo.directContext();
// RGBA
basic_texture_test(reporter, direct, kRGBA_8888_SkColorType, GrRenderable::kNo);
basic_texture_test(reporter, direct, kRGBA_8888_SkColorType, GrRenderable::kYes);
// BGRA
basic_texture_test(reporter, direct, kBGRA_8888_SkColorType, GrRenderable::kNo);
basic_texture_test(reporter, direct, kBGRA_8888_SkColorType, GrRenderable::kYes);
}

View File

@ -1,159 +0,0 @@
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/*
* This is a straightforward test of using packed pixel configs (4444, 565).
* This test will make sure that these RGBA_4444 and RGB_565 are always supported
* as valid texturing configs.
*/
#include "tests/Test.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrSurfaceContext.h"
#include "src/gpu/GrTextureProxy.h"
#include "tools/gpu/ProxyUtils.h"
static const int DEV_W = 10, DEV_H = 10;
static const uint8_t TOL = 0x4;
static void check_component(skiatest::Reporter* reporter, uint8_t control, uint8_t test) {
uint8_t diff = 0;
if (control >= test) {
diff = control - test;
} else {
diff = test - control;
}
REPORTER_ASSERT(reporter, diff < TOL);
}
static uint8_t expand_value(uint8_t original, int sigBits) {
SkASSERT(sigBits >= 4);
uint8_t inSigBitShift = 8 - sigBits;
uint8_t duplBitShift = sigBits - inSigBitShift;
return (original << inSigBitShift) + (original >> duplBitShift);
}
static void check_4444(skiatest::Reporter* reporter,
const SkTDArray<uint16_t>& controlData,
const SkTDArray<uint32_t>& readBuffer) {
for (int j = 0; j < DEV_H; ++j) {
for (int i = 0; i < DEV_W; ++i) {
uint16_t control = controlData[i + j * DEV_H];
uint32_t test = readBuffer[i + j * DEV_H];
// Test alpha component
uint8_t ctrlComp = expand_value(control & 0xF, 4);
uint8_t testComp = GrColorUnpackA(test);
check_component(reporter, ctrlComp, testComp);
// Test blue component
ctrlComp = expand_value((control >> 4) & 0xF, 4);
testComp = GrColorUnpackB(test);
check_component(reporter, ctrlComp, testComp);
// Test green component
ctrlComp = expand_value((control >> 8) & 0xF, 4);
testComp = GrColorUnpackG(test);
check_component(reporter, ctrlComp, testComp);
// Test red component
ctrlComp = expand_value((control >> 12) & 0xF, 4);
testComp = GrColorUnpackR(test);
check_component(reporter, ctrlComp, testComp);
}
}
}
static void check_565(skiatest::Reporter* reporter,
const SkTDArray<uint16_t>& controlData,
const SkTDArray<GrColor>& readBuffer) {
for (int j = 0; j < DEV_H; ++j) {
for (int i = 0; i < DEV_W; ++i) {
uint16_t control = controlData[i + j * DEV_H];
GrColor test = readBuffer[i + j * DEV_H];
// Test blue component (5 bit control)
uint8_t ctrlComp = expand_value(control & 0x1F, 5);
uint8_t testComp = GrColorUnpackB(test);
check_component(reporter, ctrlComp, testComp);
// Test green component (6 bit control)
ctrlComp = expand_value((control >> 5) & 0x3F, 6);
testComp = GrColorUnpackG(test);
check_component(reporter, ctrlComp, testComp);
// Test red component (5 bit control)
ctrlComp = expand_value((control >> 11) & 0x1F, 5);
testComp = GrColorUnpackR(test);
check_component(reporter, ctrlComp, testComp);
}
}
}
static void run_test(skiatest::Reporter* reporter, GrDirectContext* dContext, int arraySize,
SkColorType colorType) {
SkTDArray<uint16_t> controlPixelData;
// We will read back into an 8888 buffer since 565/4444 read backs aren't supported
SkTDArray<GrColor> readBuffer;
controlPixelData.setCount(arraySize);
readBuffer.setCount(arraySize);
for (int i = 0; i < arraySize; i += 2) {
controlPixelData[i] = 0xF00F;
controlPixelData[i + 1] = 0xA62F;
}
const SkImageInfo dstInfo =
SkImageInfo::Make(DEV_W, DEV_H, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
for (auto origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
auto info = SkImageInfo::Make({DEV_W, DEV_H}, colorType, kPremul_SkAlphaType, nullptr);
auto view = sk_gpu_test::MakeTextureProxyViewFromData(dContext,
GrRenderable::kNo,
origin,
info,
controlPixelData.begin(),
0);
SkASSERT(view);
GrSurfaceContext sContext(dContext, std::move(view), info.colorInfo());
if (!sContext.readPixels(dContext, dstInfo, readBuffer.begin(), 0, {0, 0})) {
// We only require this to succeed if the format is renderable.
REPORTER_ASSERT(reporter, !dContext->colorTypeSupportedAsSurface(colorType));
return;
}
if (kARGB_4444_SkColorType == colorType) {
check_4444(reporter, controlPixelData, readBuffer);
} else {
SkASSERT(kRGB_565_SkColorType == colorType);
check_565(reporter, controlPixelData, readBuffer);
}
}
}
static const int CONTROL_ARRAY_SIZE = DEV_W * DEV_H;
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RGBA4444TextureTest, reporter, ctxInfo) {
auto direct = ctxInfo.directContext();
if (direct->colorTypeSupportedAsImage(kARGB_4444_SkColorType)) {
run_test(reporter, direct, CONTROL_ARRAY_SIZE, kARGB_4444_SkColorType);
}
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RGB565TextureTest, reporter, ctxInfo) {
auto direct = ctxInfo.directContext();
if (direct->colorTypeSupportedAsImage(kRGB_565_SkColorType)) {
run_test(reporter, direct, CONTROL_ARRAY_SIZE, kRGB_565_SkColorType);
}
}

View File

@ -1,223 +0,0 @@
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "tests/Test.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/private/SkTo.h"
#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrSurfaceContext.h"
#include "src/gpu/GrSurfaceProxy.h"
#include "src/gpu/GrTextureProxy.h"
#include "tools/gpu/ProxyUtils.h"
// This was made indivisible by 4 to ensure we test setting GL_PACK_ALIGNMENT properly.
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,
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 (GrColorType::kRGBA_1010102 == colorType ||
GrColorType::kBGRA_1010102 == colorType) {
// These configs 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",
e, a, x, y, extraMsg.c_str());
return;
}
}
}
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
auto dContext = ctxInfo.directContext();
unsigned char alphaData[X_SIZE * Y_SIZE];
static const int kClearValue = 0x2;
bool match;
static const size_t kRowBytes[] = {0, X_SIZE, X_SIZE + 1, 2 * X_SIZE - 1};
{
// We are initializing the texture with zeros here
memset(alphaData, 0, X_SIZE * Y_SIZE);
unsigned char alphaDataCopy[X_SIZE * Y_SIZE];
memcpy(alphaDataCopy, alphaData, X_SIZE * Y_SIZE);
const SkImageInfo ii = SkImageInfo::MakeA8(X_SIZE, Y_SIZE);
SkBitmap bitmap;
bitmap.installPixels(ii, alphaDataCopy, ii.minRowBytes());
bitmap.setImmutable();
GrBitmapTextureMaker maker(dContext, bitmap, GrImageTexGenPolicy::kNew_Uncached_Budgeted);
auto view = maker.view(GrMipmapped::kNo);
if (!view.proxy()) {
ERRORF(reporter, "Could not create alpha texture.");
return;
}
auto sContext = GrSurfaceContext::Make(dContext, std::move(view), maker.colorInfo());
sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, ii));
// create a distinctive texture
for (int y = 0; y < Y_SIZE; ++y) {
for (int x = 0; x < X_SIZE; ++x) {
alphaData[y * X_SIZE + x] = y*X_SIZE+x;
}
}
for (auto rowBytes : kRowBytes) {
// upload the texture (do per-rowbytes iteration because we may overwrite below).
bool result = sContext->writePixels(dContext, ii, alphaData, 0, {0, 0});
REPORTER_ASSERT(reporter, result, "Initial A8 writePixels failed");
size_t nonZeroRowBytes = rowBytes ? rowBytes : X_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, bufLen);
// read the texture back
result = sContext->readPixels(dContext, ii, readback.get(), rowBytes, {0, 0});
// We don't require reading from kAlpha_8 to be supported. TODO: At least make this work
// when kAlpha_8 is renderable.
if (!result) {
continue;
}
REPORTER_ASSERT(reporter, result, "Initial A8 readPixels failed");
// make sure the original & read back versions match
SkString msg;
msg.printf("rb:%d A8", SkToU32(rowBytes));
validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes,
alphaData, msg, GrColorType::kAlpha_8);
// Now try writing to a single channel surface (if we could create one).
if (surf) {
SkCanvas* canvas = surf->getCanvas();
SkPaint paint;
const SkRect rect = SkRect::MakeLTRB(-10, -10, X_SIZE + 10, Y_SIZE + 10);
paint.setColor(SK_ColorWHITE);
canvas->drawRect(rect, paint);
// 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");
match = true;
for (int y = 0; y < Y_SIZE && match; ++y) {
for (int x = 0; x < X_SIZE && match; ++x) {
uint8_t rbValue = readback.get()[y * nonZeroRowBytes + x];
if (0xFF != rbValue) {
ERRORF(reporter,
"Failed alpha readback after clear. Expected: 0xFF, Got: 0x%02x"
" at (%d,%d), rb:%d", rbValue, x, y, SkToU32(rowBytes));
match = false;
}
}
}
}
}
}
static constexpr struct {
GrColorType fColorType;
SkAlphaType fAlphaType;
} kInfos[] = {
{GrColorType::kRGBA_8888, kPremul_SkAlphaType},
{GrColorType::kBGRA_8888, kPremul_SkAlphaType},
{GrColorType::kRGBA_8888_SRGB, kPremul_SkAlphaType},
{GrColorType::kRGBA_1010102, kPremul_SkAlphaType},
};
for (int y = 0; y < Y_SIZE; ++y) {
for (int x = 0; x < X_SIZE; ++x) {
alphaData[y * X_SIZE + x] = y*X_SIZE+x;
}
}
const GrImageInfo dstInfo(GrColorType::kAlpha_8,
kPremul_SkAlphaType,
nullptr,
{X_SIZE, Y_SIZE});
// 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 info : kInfos) {
for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
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) {
for (int x = 0; x < X_SIZE; ++x) {
rgbaData[y * X_SIZE + x] = GrColorPackRGBA(6, 7, 8, alphaData[y * X_SIZE + x]);
}
}
auto origin = GrRenderable::kYes == renderable ? kBottomLeft_GrSurfaceOrigin
: kTopLeft_GrSurfaceOrigin;
GrImageInfo ii = dstInfo.makeColorType(info.fColorType).makeAlphaType(info.fAlphaType);
auto view = sk_gpu_test::MakeTextureProxyViewFromData(dContext,
renderable,
origin,
ii,
rgbaData,
/*row bytes*/ 0);
if (!view) {
continue;
}
auto sContext = GrSurfaceContext::Make(dContext, std::move(view), ii.colorInfo());
for (auto rowBytes : kRowBytes) {
size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE;
std::unique_ptr<uint8_t[]> readback(new uint8_t[nonZeroRowBytes * Y_SIZE]);
// Clear so we don't accidentally see values from previous iteration.
memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE);
// read the texture back
bool result = sContext->readPixels(dContext, dstInfo, readback.get(),
rowBytes, {0, 0});
REPORTER_ASSERT(reporter, result, "8888 readPixels failed");
// make sure the original & read back versions match
SkString msg;
msg.printf("rt:%d, rb:%d 8888", GrRenderable::kYes == renderable,
SkToU32(rowBytes));
validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes,
alphaData, msg, info.fColorType);
}
}
}
}

View File

@ -97,34 +97,6 @@ void TestCopyFromSurface(skiatest::Reporter* reporter,
TestReadPixels(reporter, dContext, dstContext.get(), expectedPixelValues, testName);
}
void FillPixelData(int width, int height, GrColor* data) {
for (int j = 0; j < height; ++j) {
for (int i = 0; i < width; ++i) {
unsigned int red = (unsigned int)(256.f * (i / (float)width));
unsigned int green = (unsigned int)(256.f * (j / (float)height));
data[i + j * width] = GrColorPackRGBA(red - (red >> 8), green - (green >> 8),
0xff, 0xff);
}
}
}
bool DoesFullBufferContainCorrectColor(const GrColor* srcBuffer,
const GrColor* dstBuffer,
int width, int height) {
const GrColor* srcPtr = srcBuffer;
const GrColor* dstPtr = dstBuffer;
for (int j = 0; j < height; ++j) {
for (int i = 0; i < width; ++i) {
if (srcPtr[i] != dstPtr[i]) {
return false;
}
}
srcPtr += width;
dstPtr += width;
}
return true;
}
bool BipmapToBase64DataURI(const SkBitmap& bitmap, SkString* dst) {
SkPixmap pm;
if (!bitmap.peekPixels(&pm)) {

View File

@ -31,14 +31,6 @@ void TestCopyFromSurface(skiatest::Reporter*, GrDirectContext*, GrSurfaceProxy*
GrSurfaceOrigin origin, GrColorType colorType,
uint32_t expectedPixelValues[], const char* testName);
// Fills data with a red-green gradient
void FillPixelData(int width, int height, GrColor* data);
// Checks srcBuffer and dstBuffer contain the same colors
bool DoesFullBufferContainCorrectColor(const GrColor* srcBuffer,
const GrColor* dstBuffer,
int width, int height);
// Encodes the bitmap into a data:/image/png;base64,... url suitable to view in a browser after
// printing to a log. If false is returned, dst holds an error message instead of a URI.
bool BipmapToBase64DataURI(const SkBitmap& bitmap, SkString* dst);

View File

@ -211,7 +211,6 @@ array of the test names and what they drew.
'GrTestingBackendTextureUploadTest',
'GrTextBlobMoveAround',
'GrTextBlobScaleAnimation',
'GrUploadPixelsTests',
'HalfFloatAlphaTextureTest',
'HalfFloatRGBATextureTest',
'ImageAsyncReadPixels',
@ -242,7 +241,6 @@ array of the test names and what they drew.
'RGBA4444TextureTest',
'ReadOnlyTexture',
'ReadPixels_Texture',
'ReadWriteAlpha',
'RectangleTexture',
'RefCnt',
'RenderTargetContextTest',