aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/BitmapTest.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-07-01 12:48:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-01 12:48:11 -0700
commitf0aed97aec3fa1c7f6460d8d6327358f3dcbabe6 (patch)
treebed25aabeca446338941bdf4fa9d2725ae9c4f52 /tests/BitmapTest.cpp
parentc846f4a96bcde1ffeaf17afc1469db6f2cbd1ad3 (diff)
correctly plumb through explicit rowbytes for allocPixels
BUG=skia: R=caryclark@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/357073003
Diffstat (limited to 'tests/BitmapTest.cpp')
-rw-r--r--tests/BitmapTest.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp
index ef560aa6d6..42ed8841b4 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);
}