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

Unified Diff: tests/BitmapTest.cpp

Issue 357073003: correctly plumb through explicit rowbytes for allocPixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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/core/SkMallocPixelRef.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/BitmapTest.cpp
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp
index ef560aa6d63290385f58ca2fab9730899d574c9f..42ed8841b414dfd2a6807747ab9d74a233cbe8aa 100644
--- a/tests/BitmapTest.cpp
+++ b/tests/BitmapTest.cpp
@@ -9,6 +9,42 @@
#include "Test.h"
+static void test_allocpixels(skiatest::Reporter* reporter) {
+ const int width = 10;
+ const int height = 10;
+ const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
+ const size_t explicitRowBytes = info.minRowBytes() + 24;
+
+ SkBitmap bm;
+ bm.setInfo(info);
+ REPORTER_ASSERT(reporter, info.minRowBytes() == bm.rowBytes());
+ bm.allocPixels();
+ REPORTER_ASSERT(reporter, info.minRowBytes() == bm.rowBytes());
+ bm.reset();
+ bm.allocPixels(info);
+ REPORTER_ASSERT(reporter, info.minRowBytes() == bm.rowBytes());
+
+ bm.setInfo(info, explicitRowBytes);
+ REPORTER_ASSERT(reporter, explicitRowBytes == bm.rowBytes());
+ bm.allocPixels();
+ REPORTER_ASSERT(reporter, explicitRowBytes == bm.rowBytes());
+ bm.reset();
+ bm.allocPixels(info, explicitRowBytes);
+ REPORTER_ASSERT(reporter, explicitRowBytes == bm.rowBytes());
+
+ bm.reset();
+ bm.setInfo(info, 0);
+ REPORTER_ASSERT(reporter, info.minRowBytes() == bm.rowBytes());
+ bm.reset();
+ bm.allocPixels(info, 0);
+ REPORTER_ASSERT(reporter, info.minRowBytes() == bm.rowBytes());
+
+ bm.reset();
+ bool success = bm.setInfo(info, info.minRowBytes() - 1); // invalid for 32bit
+ REPORTER_ASSERT(reporter, !success);
+ REPORTER_ASSERT(reporter, bm.isNull());
+}
+
static void test_bigwidth(skiatest::Reporter* reporter) {
SkBitmap bm;
int width = 1 << 29; // *4 will be the high-bit of 32bit int
@@ -46,4 +82,5 @@ DEF_TEST(Bitmap, reporter) {
}
test_bigwidth(reporter);
+ test_allocpixels(reporter);
}
« no previous file with comments | « src/core/SkMallocPixelRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698