aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ImageTest.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-01-18 19:44:03 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-18 19:44:19 +0000
commit8461506c8b025522eb89cd754c63fb5dbf0cb7f1 (patch)
tree096a20ddf208bd84b0feefd388df0df12a44880e /tests/ImageTest.cpp
parent874a8725860cd2dc860967ee8069316d95de607c (diff)
Revert "Disallow readPixels() conversions from untagged srcs to tagged dsts"
This reverts commit ccfd1083a7b9d546735ddd1037f3240635cce72d. Reason for revert: Roll is failing. Original change's description: > Disallow readPixels() conversions from untagged srcs to tagged dsts > > This might break the roll into Chrome. But let's see how. > > BUG=skia:6021 > > Change-Id: I2698b5d6fe72d01bed0dc64703b592a03d441a80 > Reviewed-on: https://skia-review.googlesource.com/7127 > Reviewed-by: Mike Reed <reed@google.com> > Commit-Queue: Matt Sarett <msarett@google.com> > TBR=msarett@google.com,brianosman@google.com,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:6021 Change-Id: I4b62178fd7c23f43cf69ca69fc14526ecd503956 Reviewed-on: https://skia-review.googlesource.com/7205 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Matt Sarett <msarett@google.com>
Diffstat (limited to 'tests/ImageTest.cpp')
-rw-r--r--tests/ImageTest.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 904ca206e4..4f9d944d25 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -34,14 +34,6 @@
using namespace sk_gpu_test;
-SkImageInfo read_pixels_info(SkImage* image) {
- if (as_IB(image)->onImageInfo().colorSpace()) {
- return SkImageInfo::MakeS32(image->width(), image->height(), image->alphaType());
- }
-
- return SkImageInfo::MakeN32(image->width(), image->height(), image->alphaType());
-}
-
static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect* subsetA,
SkImage* b) {
const int widthA = subsetA ? subsetA->width() : a->width();
@@ -53,9 +45,11 @@ static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect
// see https://bug.skia.org/3965
//REPORTER_ASSERT(reporter, a->isOpaque() == b->isOpaque());
+ // The codecs may have given us back F16, we can't read from F16 raster to N32, only S32.
+ SkImageInfo info = SkImageInfo::MakeS32(widthA, heightA, a->alphaType());
SkAutoPixmapStorage pmapA, pmapB;
- pmapA.alloc(read_pixels_info(a));
- pmapB.alloc(read_pixels_info(b));
+ pmapA.alloc(info);
+ pmapB.alloc(info);
const int srcX = subsetA ? subsetA->x() : 0;
const int srcY = subsetA ? subsetA->y() : 0;
@@ -63,7 +57,7 @@ static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect
REPORTER_ASSERT(reporter, a->readPixels(pmapA, srcX, srcY));
REPORTER_ASSERT(reporter, b->readPixels(pmapB, 0, 0));
- const size_t widthBytes = widthA * 4;
+ const size_t widthBytes = widthA * info.bytesPerPixel();
for (int y = 0; y < heightA; ++y) {
REPORTER_ASSERT(reporter, !memcmp(pmapA.addr32(0, y), pmapB.addr32(0, y), widthBytes));
}