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

Unified Diff: tests/ReadPixelsTest.cpp

Issue 164203003: replace setConfig+allocPixels with alloc-or-install-pixels (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | « tests/DrawPathTest.cpp ('k') | tests/WritePixelsTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ReadPixelsTest.cpp
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 5f25007d4b8b1267c2e3f22752af35fac5adfaa9..50f55fd8f0abb62fe3849929687ff67357cbc15e 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -107,8 +107,7 @@ static SkPMColor convertConfig8888ToPMColor(SkCanvas::Config8888 config8888,
static void fillCanvas(SkCanvas* canvas) {
static SkBitmap bmp;
if (bmp.isNull()) {
- bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H);
- SkDEBUGCODE(bool alloc =) bmp.allocPixels();
+ SkDEBUGCODE(bool alloc =) bmp.allocN32Pixels(DEV_W, DEV_H);
SkASSERT(alloc);
SkAutoLockPixels alp(bmp);
intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels());
@@ -230,9 +229,8 @@ static BitmapInit nextBMI(BitmapInit bmi) {
}
static void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, BitmapInit init) {
- int w = rect.width();
- int h = rect.height();
- int rowBytes = 0;
+ SkImageInfo info = SkImageInfo::MakeN32Premul(rect.width(), rect.height());
+ size_t rowBytes = 0;
bool alloc = true;
switch (init) {
case kNoPixels_BitmapInit:
@@ -240,15 +238,17 @@ static void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, BitmapInit init)
case kTight_BitmapInit:
break;
case kRowBytes_BitmapInit:
- rowBytes = w * sizeof(SkPMColor) + 16 * sizeof(SkPMColor);
+ rowBytes = (info.width() + 16) * sizeof(SkPMColor);
break;
default:
SkASSERT(0);
break;
}
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h, rowBytes);
+
if (alloc) {
- bitmap->allocPixels();
+ bitmap->allocPixels(info);
+ } else {
+ bitmap->setConfig(info, rowBytes);
}
}
« no previous file with comments | « tests/DrawPathTest.cpp ('k') | tests/WritePixelsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698