Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1000)

Unified Diff: tests/ImageNewShaderTest.cpp

Issue 1352293002: Revert[2] of add ImageShader, sharing code with its Bitmap cousin (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: undo change to test, check in Image_Gpu for nopt support Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageNewShaderTest.cpp
diff --git a/tests/ImageNewShaderTest.cpp b/tests/ImageNewShaderTest.cpp
index c01fbe7ee8bdab01e60c612d3c65cfbfe549f18d..90405365820cde1dae2cb21032bcd1b7815a90e1 100644
--- a/tests/ImageNewShaderTest.cpp
+++ b/tests/ImageNewShaderTest.cpp
@@ -16,12 +16,21 @@
#include "Test.h"
-void testBitmapEquality(skiatest::Reporter* reporter, SkBitmap& bm1, SkBitmap& bm2) {
- SkAutoLockPixels lockBm1(bm1);
- SkAutoLockPixels lockBm2(bm2);
-
- REPORTER_ASSERT(reporter, bm1.getSize() == bm2.getSize());
- REPORTER_ASSERT(reporter, 0 == memcmp(bm1.getPixels(), bm2.getPixels(), bm1.getSize()));
+void testBitmapEquality(skiatest::Reporter* reporter, const SkBitmap& src, const SkBitmap& dst,
+ const char label[]) {
+ SkAutoLockPixels lockBm1(src);
+ SkAutoLockPixels lockBm2(dst);
+
+ REPORTER_ASSERT(reporter, src.getSize() == dst.getSize());
+ if (memcmp(src.getPixels(), dst.getPixels(), dst.getSize())) {
+ SkDebugf("testBitmapEquality %s\n", label);
+ for (int y = 0; y < src.height(); ++y) {
+ for (int x = 0; x < src.width(); ++x) {
+ SkDebugf("(%d %d) src=%08X dst=%08X\n", x, y, src.getColor(x, y), dst.getColor(x, y));
+ }
+ }
+ REPORTER_ASSERT(reporter, false);
+ }
}
void paintSource(SkSurface* sourceSurface) {
@@ -41,7 +50,8 @@ void paintSource(SkSurface* sourceSurface) {
sourceCanvas->drawRect(rect, paintColor);
}
-void runShaderTest(skiatest::Reporter* reporter, SkSurface* sourceSurface, SkSurface* destinationSurface, SkImageInfo& info) {
+void runShaderTest(skiatest::Reporter* reporter, SkSurface* sourceSurface,
+ SkSurface* destinationSurface, SkImageInfo& info, const char label[]) {
paintSource(sourceSurface);
SkAutoTUnref<SkImage> sourceImage(sourceSurface->newImageSnapshot());
@@ -58,14 +68,14 @@ void runShaderTest(skiatest::Reporter* reporter, SkSurface* sourceSurface, SkSur
SkIRect rect = info.bounds();
- SkBitmap bmOrig;
- sourceSurface->getCanvas()->readPixels(rect, &bmOrig);
+ SkBitmap srcBM;
+ sourceSurface->getCanvas()->readPixels(rect, &srcBM);
- SkBitmap bm;
- destinationCanvas->readPixels(rect, &bm);
+ SkBitmap dstBM;
+ destinationCanvas->readPixels(rect, &dstBM);
- testBitmapEquality(reporter, bmOrig, bm);
+ testBitmapEquality(reporter, srcBM, dstBM, label);
@@ -92,9 +102,15 @@ void runShaderTest(skiatest::Reporter* reporter, SkSurface* sourceSurface, SkSur
{
SkAutoLockPixels lockBm(bmt);
for (int y = 0; y < info.height(); y++) {
- REPORTER_ASSERT(reporter, 0xFFFF0000 == bmt.getColor(0, y));
+ if (0xFFFF0000 != bmt.getColor(0, y)) {
+ SkDebugf("y = %d for %s\n", y, label);
+ REPORTER_ASSERT(reporter, 0xFFFF0000 == bmt.getColor(0, y));
+ }
for (int x = 1; x < info.width(); x++) {
+ if (0xFFDEDEDE != bmt.getColor(x, y)) {
+ SkDebugf("(%d %d) color = %x for %s\n", x, y, bmt.getColor(x, y), label);
+ }
REPORTER_ASSERT(reporter, 0xFFDEDEDE == bmt.getColor(x, y));
}
}
@@ -107,12 +123,13 @@ DEF_TEST(ImageNewShader, reporter) {
SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRaster(info));
SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRaster(info));
- runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
+ runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info, "raster");
}
#if SK_SUPPORT_GPU
void gpuToGpu(skiatest::Reporter* reporter, GrContext* context) {
+ // if we change these to 5,5, this fails on Nexus 7 w/ Tegra 3. See skbug.com/4365
reed1 2015/09/21 21:02:06 Will remove this comment.
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
SkAutoTUnref<SkSurface> sourceSurface(
@@ -120,7 +137,7 @@ void gpuToGpu(skiatest::Reporter* reporter, GrContext* context) {
SkAutoTUnref<SkSurface> destinationSurface(
SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info));
- runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
+ runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info, "gpu");
}
void gpuToRaster(skiatest::Reporter* reporter, GrContext* context) {
@@ -130,7 +147,7 @@ void gpuToRaster(skiatest::Reporter* reporter, GrContext* context) {
SkSurface::kNo_Budgeted, info));
SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRaster(info));
- runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
+ runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info, "gpu-raster");
}
void rasterToGpu(skiatest::Reporter* reporter, GrContext* context) {
@@ -140,7 +157,7 @@ void rasterToGpu(skiatest::Reporter* reporter, GrContext* context) {
SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRenderTarget(context,
SkSurface::kNo_Budgeted, info));
- runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
+ runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info, "raster-gpu");
}
DEF_GPUTEST(ImageNewShader_GPU, reporter, factory) {
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698