aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-04-17 10:53:29 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-17 15:22:42 +0000
commit12e946b4bfdf598bffb276776ea6e25439e25265 (patch)
tree3431130a5008af573c497da13243da360d147918 /tests
parent81340c65e0e507ca544e32c0fa0c6880f371eaff (diff)
deprecate odd variants of SkCanvas::readPixels
Bug: skia:6513 Change-Id: I51179a85f0912d3f899c368c30a943d346dd1d05 Reviewed-on: https://skia-review.googlesource.com/13589 Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/BlurTest.cpp5
-rw-r--r--tests/DrawPathTest.cpp4
-rw-r--r--tests/ImageNewShaderTest.cpp11
-rw-r--r--tests/PremulAlphaRoundTripTest.cpp4
-rw-r--r--tests/ReadPixelsTest.cpp17
-rw-r--r--tests/ResourceCacheTest.cpp2
-rw-r--r--tests/WritePixelsTest.cpp3
7 files changed, 19 insertions, 27 deletions
diff --git a/tests/BlurTest.cpp b/tests/BlurTest.cpp
index 744e2025b9..985917f1c0 100644
--- a/tests/BlurTest.cpp
+++ b/tests/BlurTest.cpp
@@ -242,10 +242,7 @@ static void blur_path(SkCanvas* canvas, const SkPath& path,
static void readback(SkCanvas* canvas, int* result, int resultCount) {
SkBitmap readback;
readback.allocN32Pixels(resultCount, 30);
-
- SkIRect readBackRect = { 0, 0, resultCount, 30 };
-
- canvas->readPixels(readBackRect, &readback);
+ canvas->readPixels(readback, 0, 0);
readback.lockPixels();
SkPMColor* pixels = (SkPMColor*) readback.getAddr32(0, 15);
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index 87d51b100e..2434bdfccd 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -26,7 +26,7 @@ static void test_big_aa_rect(skiatest::Reporter* reporter) {
int y = SkScalarRoundToInt(r.top());
// check that the pixel in question starts as transparent (by the surface)
- if (canvas->readPixels(&output, x, y)) {
+ if (canvas->readPixels(output, x, y)) {
REPORTER_ASSERT(reporter, 0 == pixel[0]);
} else {
REPORTER_ASSERT_MESSAGE(reporter, false, "readPixels failed");
@@ -39,7 +39,7 @@ static void test_big_aa_rect(skiatest::Reporter* reporter) {
canvas->drawRect(r, paint);
// Now check that it is BLACK
- if (canvas->readPixels(&output, x, y)) {
+ if (canvas->readPixels(output, x, y)) {
// don't know what swizzling PMColor did, but white should always
// appear the same.
REPORTER_ASSERT(reporter, 0xFFFFFFFF == pixel[0]);
diff --git a/tests/ImageNewShaderTest.cpp b/tests/ImageNewShaderTest.cpp
index 4091db0d9b..37e1e301ee 100644
--- a/tests/ImageNewShaderTest.cpp
+++ b/tests/ImageNewShaderTest.cpp
@@ -57,14 +57,14 @@ static void run_shader_test(skiatest::Reporter* reporter, SkSurface* sourceSurfa
destinationCanvas->clear(SK_ColorTRANSPARENT);
destinationCanvas->drawPaint(paint);
- SkIRect rect = info.bounds();
-
SkBitmap bmOrig;
- sourceSurface->getCanvas()->readPixels(rect, &bmOrig);
+ bmOrig.allocN32Pixels(info.width(), info.height());
+ sourceSurface->getCanvas()->readPixels(bmOrig, 0, 0);
SkBitmap bm;
- destinationCanvas->readPixels(rect, &bm);
+ bm.allocN32Pixels(info.width(), info.height());
+ destinationCanvas->readPixels(bm, 0, 0);
test_bitmap_equality(reporter, bmOrig, bm);
@@ -85,7 +85,8 @@ static void run_shader_test(skiatest::Reporter* reporter, SkSurface* sourceSurfa
destinationCanvas->drawPaint(paintTranslated);
SkBitmap bmt;
- destinationCanvas->readPixels(rect, &bmt);
+ bmt.allocN32Pixels(info.width(), info.height());
+ destinationCanvas->readPixels(bmt, 0, 0);
// Test correctness
{
diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp
index b1310e3681..7719ad88ab 100644
--- a/tests/PremulAlphaRoundTripTest.cpp
+++ b/tests/PremulAlphaRoundTripTest.cpp
@@ -76,10 +76,10 @@ static void test_premul_alpha_roundtrip(skiatest::Reporter* reporter, SkSurface*
readBmp1.eraseColor(0);
readBmp2.eraseColor(0);
- canvas->readPixels(&readBmp1, 0, 0);
+ canvas->readPixels(readBmp1, 0, 0);
sk_tool_utils::write_pixels(canvas, readBmp1, 0, 0, gUnpremul[upmaIdx].fColorType,
kUnpremul_SkAlphaType);
- canvas->readPixels(&readBmp2, 0, 0);
+ canvas->readPixels(readBmp2, 0, 0);
bool success = true;
for (int y = 0; y < 256 && success; ++y) {
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 10462c9140..697d3ee99e 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -247,8 +247,7 @@ static bool check_read(skiatest::Reporter* reporter,
enum BitmapInit {
kFirstBitmapInit = 0,
- kNoPixels_BitmapInit = kFirstBitmapInit,
- kTight_BitmapInit,
+ kTight_BitmapInit = kFirstBitmapInit,
kRowBytes_BitmapInit,
kRowBytesOdd_BitmapInit,
@@ -270,10 +269,7 @@ static void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, BitmapInit init,
SkAlphaType at) {
SkImageInfo info = SkImageInfo::Make(rect.width(), rect.height(), ct, at);
size_t rowBytes = 0;
- bool alloc = true;
switch (init) {
- case kNoPixels_BitmapInit:
- alloc = false;
case kTight_BitmapInit:
break;
case kRowBytes_BitmapInit:
@@ -286,12 +282,7 @@ static void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, BitmapInit init,
SkASSERT(0);
break;
}
-
- if (alloc) {
- bitmap->allocPixels(info, rowBytes);
- } else {
- bitmap->setInfo(info, rowBytes);
- }
+ bitmap->allocPixels(info, rowBytes);
}
static const struct {
@@ -370,7 +361,7 @@ static void test_readpixels(skiatest::Reporter* reporter, const sk_sp<SkSurface>
fill_dst_bmp_with_init_data(&bmp);
}
uint32_t idBefore = surface->generationID();
- bool success = canvas->readPixels(&bmp, srcRect.fLeft, srcRect.fTop);
+ bool success = canvas->readPixels(bmp, srcRect.fLeft, srcRect.fTop);
uint32_t idAfter = surface->generationID();
// we expect to succeed when the read isn't fully clipped
@@ -391,6 +382,7 @@ static void test_readpixels(skiatest::Reporter* reporter, const sk_sp<SkSurface>
REPORTER_ASSERT(reporter, bmp.isNull());
}
}
+#ifdef SK_SUPPORT_LEGACY_CANVAS_READPIXELS
// check the old webkit version of readPixels that clips the
// bitmap size
SkBitmap wkbmp;
@@ -406,6 +398,7 @@ static void test_readpixels(skiatest::Reporter* reporter, const sk_sp<SkSurface>
} else {
REPORTER_ASSERT(reporter, !success);
}
+#endif
}
}
}
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index fcf3fe88f3..07369380af 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -66,7 +66,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheCache, reporter, ctxInfo) {
for (int i = 0; i < 100; ++i) {
canvas->drawBitmap(src, 0, 0);
- canvas->readPixels(size, &readback);
+ canvas->readPixels(readback, 0, 0);
// "modify" the src texture
src.notifyPixelsChanged();
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index cace6b196e..bf2e64efc1 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -191,7 +191,8 @@ static bool check_write(skiatest::Reporter* reporter, SkCanvas* canvas, const Sk
// At some point this will be unsupported, as we won't allow accessBitmap() to magically call
// readPixels for the client.
SkBitmap secretDevBitmap;
- if (!canvas->readPixels(canvasInfo.bounds(), &secretDevBitmap)) {
+ secretDevBitmap.allocN32Pixels(canvasInfo.width(), canvasInfo.height());
+ if (!canvas->readPixels(secretDevBitmap, 0, 0)) {
return false;
}