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

Side by Side Diff: gm/bitmappremul.cpp

Issue 140593005: add legacy/helper allocN32Pixels, and convert gm to use it (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gm/bitmapmatrix.cpp ('k') | gm/bitmaprect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 12
13 /** 13 /**
14 * This GM checks that bitmap pixels are unpremultiplied before being exported 14 * This GM checks that bitmap pixels are unpremultiplied before being exported
15 * to other formats. If unpremultiplication is implemented properly, this 15 * to other formats. If unpremultiplication is implemented properly, this
16 * GM should come out completely white. If not, this GM looks like a row of two 16 * GM should come out completely white. If not, this GM looks like a row of two
17 * greyscale gradients above a row of grey lines. 17 * greyscale gradients above a row of grey lines.
18 * This tests both the ARGB4444 and ARGB8888 bitmap configurations. 18 * This tests both the ARGB4444 and ARGB8888 bitmap configurations.
19 */ 19 */
20 20
21 static const int SLIDE_SIZE = 256; 21 static const int SLIDE_SIZE = 256;
22 static const int PIXEL_SIZE_8888 = SLIDE_SIZE / 256; 22 static const int PIXEL_SIZE_8888 = SLIDE_SIZE / 256;
23 static const int PIXEL_SIZE_4444 = SLIDE_SIZE / 16; 23 static const int PIXEL_SIZE_4444 = SLIDE_SIZE / 16;
24 24
25 static void init_bitmap(SkBitmap::Config config, SkBitmap* bitmap) { 25 static void init_bitmap(SkBitmap::Config config, SkBitmap* bitmap) {
26 bitmap->setConfig(config, SLIDE_SIZE, SLIDE_SIZE); 26 bitmap->allocConfigPixels(config, SLIDE_SIZE, SLIDE_SIZE);
27 bitmap->allocPixels();
28 bitmap->eraseColor(SK_ColorWHITE); 27 bitmap->eraseColor(SK_ColorWHITE);
29 } 28 }
30 29
31 static SkBitmap make_argb8888_gradient() { 30 static SkBitmap make_argb8888_gradient() {
32 SkBitmap bitmap; 31 SkBitmap bitmap;
33 init_bitmap(SkBitmap::kARGB_8888_Config, &bitmap); 32 init_bitmap(SkBitmap::kARGB_8888_Config, &bitmap);
34 uint8_t rowColor = 0; 33 uint8_t rowColor = 0;
35 for (int y = 0; y < SLIDE_SIZE; y++) { 34 for (int y = 0; y < SLIDE_SIZE; y++) {
36 uint32_t* dst = bitmap.getAddr32(0, y); 35 uint32_t* dst = bitmap.getAddr32(0, y);
37 for (int x = 0; x < SLIDE_SIZE; x++) { 36 for (int x = 0; x < SLIDE_SIZE; x++) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 canvas->drawBitmap(make_argb8888_stripes(), 0, slideSize); 123 canvas->drawBitmap(make_argb8888_stripes(), 0, slideSize);
125 canvas->drawBitmap(make_argb4444_stripes(), slideSize, slideSize); 124 canvas->drawBitmap(make_argb4444_stripes(), slideSize, slideSize);
126 } 125 }
127 126
128 private: 127 private:
129 typedef GM INHERITED; 128 typedef GM INHERITED;
130 }; 129 };
131 130
132 DEF_GM( return new BitmapPremulGM; ) 131 DEF_GM( return new BitmapPremulGM; )
133 } 132 }
OLDNEW
« no previous file with comments | « gm/bitmapmatrix.cpp ('k') | gm/bitmaprect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698