Skip to content

Commit

Permalink
Rename functions in TestUtils.h
Browse files Browse the repository at this point in the history
Change-Id: Iaa8a4ac57e967c6429473fb3a738d377a47fc2c7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/250799
Commit-Queue: Brian Salomon <[email protected]>
Auto-Submit: Brian Salomon <[email protected]>
Reviewed-by: Robert Phillips <[email protected]>
  • Loading branch information
bsalomon authored and Skia Commit-Bot committed Oct 25, 2019
1 parent 342fbc5 commit 28a8f28
Show file tree
Hide file tree
Showing 18 changed files with 152 additions and 151 deletions.
4 changes: 2 additions & 2 deletions dm/DMSrcSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1303,14 +1303,14 @@ static Error compare_bitmaps(const SkBitmap& reference, const SkBitmap& bitmap)
if (0 != memcmp(reference.getPixels(), bitmap.getPixels(), reference.computeByteSize())) {
SkString encoded;
SkString errString("Pixels don't match reference");
if (bitmap_to_base64_data_uri(reference, &encoded)) {
if (BipmapToBase64DataURI(reference, &encoded)) {
errString.append("\nExpected: ");
errString.append(encoded);
} else {
errString.append("\nExpected image failed to encode: ");
errString.append(encoded);
}
if (bitmap_to_base64_data_uri(bitmap, &encoded)) {
if (BipmapToBase64DataURI(bitmap, &encoded)) {
errString.append("\nActual: ");
errString.append(encoded);
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/BackendAllocationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static void check_solid_pixmap(skiatest::Reporter* reporter,
diffs[0], diffs[1], diffs[2], diffs[3]);
});

check_solid_pixels(expected, actual, tols, error);
CheckSolidPixels(expected, actual, tols, error);
}

// What would raster do?
Expand Down
6 changes: 3 additions & 3 deletions tests/DeferredDisplayListTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSkSurfaceFlush, reporter, ctxInfo) {

GrBackendTexture backendTexture;

if (!create_backend_texture(context, &backendTexture, ii, SkColors::kCyan,
GrMipMapped::kNo, GrRenderable::kNo)) {
if (!CreateBackendTexture(context, &backendTexture, ii, SkColors::kCyan, GrMipMapped::kNo,
GrRenderable::kNo)) {
REPORTER_ASSERT(reporter, false);
return;
}
Expand Down Expand Up @@ -940,7 +940,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSkSurfaceFlush, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, fulfillInfo.fTex->unique());
fulfillInfo.fTex.reset();

delete_backend_texture(context, backendTexture);
DeleteBackendTexture(context, backendTexture);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 4 additions & 4 deletions tests/EGLImageTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
}
}

test_read_pixels(reporter, surfaceContext.get(), pixels.get(), "EGLImageTest-read");
TestReadPixels(reporter, surfaceContext.get(), pixels.get(), "EGLImageTest-read");

// We should not be able to write to a EXTERNAL texture
test_write_pixels(reporter, surfaceContext.get(), false, "EGLImageTest-write");
TestWritePixels(reporter, surfaceContext.get(), false, "EGLImageTest-write");

// Only test RT-config
// TODO: why do we always need to draw to copy from an external texture?
test_copy_from_surface(reporter, context0, surfaceContext->asSurfaceProxy(),
GrColorType::kRGBA_8888, pixels.get(), "EGLImageTest-copy");
TestCopyFromSurface(reporter, context0, surfaceContext->asSurfaceProxy(),
GrColorType::kRGBA_8888, pixels.get(), "EGLImageTest-copy");

cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
}
2 changes: 1 addition & 1 deletion tests/ExtendedSkColorTypeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static void compare_pixmaps(skiatest::Reporter* reporter,
diffs[0], diffs[1], diffs[2], diffs[3]);
});

compare_pixels(expected, actual, tols, error);
ComparePixels(expected, actual, tols, error);
}

static void gpu_tests(GrContext* context, skiatest::Reporter* reporter, const TestCase& test) {
Expand Down
10 changes: 5 additions & 5 deletions tests/GrSurfaceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {

// Mip regen should not work with a read only texture.
if (context->priv().caps()->mipMapSupport()) {
delete_backend_texture(context, backendTex);
DeleteBackendTexture(context, backendTex);
backendTex = context->createBackendTexture(
kSize, kSize, kRGBA_8888_SkColorType,
SkColors::kTransparent, GrMipMapped::kYes, GrRenderable::kYes,
Expand All @@ -462,7 +462,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
context->priv().getGpu()->regenerateMipMapLevels(proxy->peekTexture());
REPORTER_ASSERT(reporter, regenResult == (ioType == kRW_GrIOType));
}
delete_backend_texture(context, backendTex);
DeleteBackendTexture(context, backendTex);
}
}

Expand Down Expand Up @@ -764,8 +764,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleProcFlushTest, reporter, contextInfo) {

GrBackendTexture backendTexture;

if (!create_backend_texture(context, &backendTexture, info, SkColors::kBlack,
GrMipMapped::kNo, GrRenderable::kNo)) {
if (!CreateBackendTexture(context, &backendTexture, info, SkColors::kBlack,
GrMipMapped::kNo, GrRenderable::kNo)) {
REPORTER_ASSERT(reporter, false);
continue;
}
Expand All @@ -776,7 +776,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleProcFlushTest, reporter, contextInfo) {
surf->getCanvas()->drawImage(std::move(img2), 1, 1);
idleTexture.reset();

delete_backend_texture(context, backendTexture);
DeleteBackendTexture(context, backendTexture);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/GrTestingBackendTextureUploadTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void testing_only_texture_test(skiatest::Reporter* reporter, GrContext* context,
if (doDataUpload) {
SkASSERT(GrMipMapped::kNo == mipMapped);

fill_pixel_data(kWidth, kHeight, expectedPixels.writable_addr32(0, 0));
FillPixelData(kWidth, kHeight, expectedPixels.writable_addr32(0, 0));

backendTex = context->createBackendTexture(&expectedPixels, 1,
renderable, GrProtected::kNo);
Expand Down Expand Up @@ -81,9 +81,9 @@ void testing_only_texture_test(skiatest::Reporter* reporter, GrContext* context,
{0, 0}, context);

REPORTER_ASSERT(reporter, result);
REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(expectedPixels.addr32(),
actualPixels.addr32(),
kWidth, kHeight));
REPORTER_ASSERT(reporter,
DoesFullBufferContainCorrectColor(expectedPixels.addr32(),
actualPixels.addr32(), kWidth, kHeight));
}

DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrTestingBackendTextureUploadTest, reporter, ctxInfo) {
Expand Down
24 changes: 7 additions & 17 deletions tests/GrUploadPixelsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColo
SkAutoTMalloc<GrColor> srcBuffer(kWidth*kHeight);
SkAutoTMalloc<GrColor> dstBuffer(kWidth*kHeight);

fill_pixel_data(kWidth, kHeight, srcBuffer.get());
FillPixelData(kWidth, kHeight, srcBuffer.get());

auto grCT = SkColorTypeToGrColorType(ct);
auto proxy = sk_gpu_test::MakeTextureProxyFromData(
Expand All @@ -42,10 +42,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColo

bool result = sContext->readPixels(dstInfo, dstBuffer, 0, {0, 0});
REPORTER_ASSERT(reporter, result);
REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
dstBuffer,
kWidth,
kHeight));
REPORTER_ASSERT(reporter,
DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, kWidth, kHeight));

dstInfo = SkImageInfo::Make(10, 2, ct, kPremul_SkAlphaType);
result = sContext->writePixels(dstInfo, srcBuffer, 0, {2, 10});
Expand All @@ -56,10 +54,7 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColo
result = sContext->readPixels(dstInfo, dstBuffer, 0, {2, 10});
REPORTER_ASSERT(reporter, result);

REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
dstBuffer,
10,
2));
REPORTER_ASSERT(reporter, DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, 10, 2));
}

proxy = sk_gpu_test::MakeTextureProxyFromData(
Expand All @@ -74,10 +69,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColo

bool result = sContext->readPixels(dstInfo, dstBuffer, 0, {0, 0});
REPORTER_ASSERT(reporter, result);
REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
dstBuffer,
kWidth,
kHeight));
REPORTER_ASSERT(reporter,
DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, kWidth, kHeight));

dstInfo = SkImageInfo::Make(4, 5, ct, kPremul_SkAlphaType);
result = sContext->writePixels(dstInfo, srcBuffer, 0, {5, 4});
Expand All @@ -88,10 +81,7 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColo
result = sContext->readPixels(dstInfo, dstBuffer, 0, {5, 4});
REPORTER_ASSERT(reporter, result);

REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
dstBuffer,
4,
5));
REPORTER_ASSERT(reporter, DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, 4, 5));

}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/ImageTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTextureRelease, reporter, c
kPremul_SkAlphaType);
GrBackendTexture backendTex;

if (!create_backend_texture(ctx, &backendTex, ii, SkColors::kRed,
GrMipMapped::kNo, GrRenderable::kNo)) {
if (!CreateBackendTexture(ctx, &backendTex, ii, SkColors::kRed, GrMipMapped::kNo,
GrRenderable::kNo)) {
ERRORF(reporter, "couldn't create backend texture\n");
}

Expand All @@ -849,7 +849,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTextureRelease, reporter, c
refImg.reset(nullptr); // force a release of the image
REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);

delete_backend_texture(ctx, backendTex);
DeleteBackendTexture(ctx, backendTex);
}

static void test_cross_context_image(skiatest::Reporter* reporter, const GrContextOptions& options,
Expand Down
2 changes: 1 addition & 1 deletion tests/OnFlushCallbackTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class AtlasObject final : public GrOnFlushCallbackObject {
// 1 ref from the 'fAtlasProxy' sk_sp
// 9 refs from the 9 AtlasedRectOps
// The backing GrSurface should have only 1 though bc there is only one proxy
check_single_threaded_proxy_refs(fReporter, fAtlasProxy.get(), 10, 1);
CheckSingleThreadedProxyRefs(fReporter, fAtlasProxy.get(), 10, 1);
auto rtc = resourceProvider->makeRenderTargetContext(fAtlasProxy, GrColorType::kRGBA_8888,
nullptr, nullptr);

Expand Down
8 changes: 4 additions & 4 deletions tests/ProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) {
// If the fp is cloned the number of refs should increase by one (for the clone)
int expectedProxyRefs = makeClone ? 3 : 2;

check_single_threaded_proxy_refs(reporter, proxy.get(), expectedProxyRefs, -1);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), expectedProxyRefs, -1);

context->flush();

// just one from the 'proxy' sk_sp
check_single_threaded_proxy_refs(reporter, proxy.get(), 1, 1);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 1, 1);
}
}
}
Expand Down Expand Up @@ -331,7 +331,7 @@ bool log_pixels(GrColor* pixels, int widthHeight, SkString* dst) {
auto info = SkImageInfo::Make(widthHeight, widthHeight, kRGBA_8888_SkColorType, kLogAlphaType);
SkBitmap bmp;
bmp.installPixels(info, pixels, widthHeight * sizeof(GrColor));
return bitmap_to_base64_data_uri(bmp, dst);
return BipmapToBase64DataURI(bmp, dst);
}

bool log_texture_proxy(GrContext* context, sk_sp<GrTextureProxy> src, SkString* dst) {
Expand All @@ -341,7 +341,7 @@ bool log_texture_proxy(GrContext* context, sk_sp<GrTextureProxy> src, SkString*
SkBitmap bm;
SkAssertResult(bm.tryAllocPixels(ii));
SkAssertResult(sContext->readPixels(ii, bm.getPixels(), bm.rowBytes(), {0, 0}));
return bitmap_to_base64_data_uri(bm, dst);
return BipmapToBase64DataURI(bm, dst);
}

bool fuzzy_color_equals(const SkPMColor4f& c1, const SkPMColor4f& c2) {
Expand Down
20 changes: 10 additions & 10 deletions tests/ProxyRefTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {

int backingRefs = proxy->isInstantiated() ? 1 : -1;

check_single_threaded_proxy_refs(reporter, proxy.get(), 2, backingRefs);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 2, backingRefs);

proxy->instantiate(resourceProvider);

check_single_threaded_proxy_refs(reporter, proxy.get(), 2, 1);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 2, 1);
}
check_single_threaded_proxy_refs(reporter, proxy.get(), 1, 1);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 1, 1);
}

// Multiple normal refs
Expand All @@ -74,16 +74,16 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {

int backingRefs = proxy->isInstantiated() ? 1 : -1;

check_single_threaded_proxy_refs(reporter, proxy.get(), 3, backingRefs);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 3, backingRefs);

proxy->instantiate(resourceProvider);

check_single_threaded_proxy_refs(reporter, proxy.get(), 3, 1);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 3, 1);

proxy->unref();
proxy->unref();
}
check_single_threaded_proxy_refs(reporter, proxy.get(), 1, 1);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 1, 1);
}

// Continue using (reffing) proxy after instantiation
Expand All @@ -94,16 +94,16 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {

int backingRefs = proxy->isInstantiated() ? 1 : -1;

check_single_threaded_proxy_refs(reporter, proxy.get(), 2, backingRefs);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 2, backingRefs);

proxy->instantiate(resourceProvider);

check_single_threaded_proxy_refs(reporter, proxy.get(), 2, 1);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 2, 1);

sk_sp<GrTextureProxy> secondExtraRef(proxy);
check_single_threaded_proxy_refs(reporter, proxy.get(), 3, 1);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 3, 1);
}
check_single_threaded_proxy_refs(reporter, proxy.get(), 1, 1);
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 1, 1);
}
}
}
2 changes: 1 addition & 1 deletion tests/ReadPixelsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ static void gpu_read_pixels_test_driver(skiatest::Reporter* reporter,
// This is the part of dstPixels that should have been updated.
SkPixmap actual;
SkAssertResult(dstPixels.extractSubset(&actual, dstWriteRect));
compare_pixels(ref, actual, tols, error);
ComparePixels(ref, actual, tols, error);

const auto* v = dstData.get();
const auto* end = dstData.get() + dstSize;
Expand Down
16 changes: 8 additions & 8 deletions tests/RectangleTextureTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* cont
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp));
rtContext->drawPaint(GrNoClip(), std::move(paint), SkMatrix::I());
test_read_pixels(reporter, rtContext.get(), expectedPixelValues,
"RectangleTexture-basic-draw");
TestReadPixels(reporter, rtContext.get(), expectedPixelValues,
"RectangleTexture-basic-draw");
}
}

Expand Down Expand Up @@ -85,7 +85,7 @@ static void test_clear(skiatest::Reporter* reporter, GrSurfaceContext* rectConte
}
}

test_read_pixels(reporter, rtc, expectedPixels.get(), "RectangleTexture-clear");
TestReadPixels(reporter, rtc, expectedPixels.get(), "RectangleTexture-clear");
}
}

Expand Down Expand Up @@ -113,7 +113,7 @@ static void test_copy_to_surface(skiatest::Reporter* reporter,
// If this assert ever fails we can add a fallback to do copy as draw, but until then we can
// be more restrictive.
SkAssertResult(dstContext->testCopy(src.get()));
test_read_pixels(reporter, dstContext, pixels.get(), testName);
TestReadPixels(reporter, dstContext, pixels.get(), testName);
}
}

Expand Down Expand Up @@ -183,18 +183,18 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
test_basic_draw_as_src(reporter, context, rectProxy, GrColorType::kRGBA_8888, refPixels);

// Test copy to both a texture and RT
test_copy_from_surface(reporter, context, rectProxy.get(), GrColorType::kRGBA_8888,
refPixels, "RectangleTexture-copy-from");
TestCopyFromSurface(reporter, context, rectProxy.get(), GrColorType::kRGBA_8888, refPixels,
"RectangleTexture-copy-from");

auto rectContext = context->priv().makeWrappedSurfaceContext(
std::move(rectProxy), GrColorType::kRGBA_8888, kPremul_SkAlphaType);
SkASSERT(rectContext);

test_read_pixels(reporter, rectContext.get(), refPixels, "RectangleTexture-read");
TestReadPixels(reporter, rectContext.get(), refPixels, "RectangleTexture-read");

test_copy_to_surface(reporter, context, rectContext.get(), "RectangleTexture-copy-to");

test_write_pixels(reporter, rectContext.get(), true, "RectangleTexture-write");
TestWritePixels(reporter, rectContext.get(), true, "RectangleTexture-write");

test_clear(reporter, rectContext.get());

Expand Down
Loading

0 comments on commit 28a8f28

Please sign in to comment.