OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 namespace skiagm { | 10 namespace skiagm { |
11 | 11 |
12 static void make_bm(SkBitmap* bm) { | 12 static void make_bm(SkBitmap* bm) { |
13 const SkColor colors[4] = { | 13 const SkColor colors[4] = { |
14 SK_ColorRED, SK_ColorGREEN, | 14 SK_ColorRED, SK_ColorGREEN, |
15 SK_ColorBLUE, SK_ColorWHITE | 15 SK_ColorBLUE, SK_ColorWHITE |
16 }; | 16 }; |
17 SkPMColor colorsPM[4]; | 17 SkPMColor colorsPM[4]; |
18 for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) { | 18 for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) { |
19 colorsPM[i] = SkPreMultiplyColor(colors[i]); | 19 colorsPM[i] = SkPreMultiplyColor(colors[i]); |
20 } | 20 } |
21 SkColorTable* ctable = new SkColorTable(colorsPM, 4); | 21 SkColorTable* ctable = new SkColorTable(colorsPM, 4); |
22 | 22 |
23 bm->setConfig(SkBitmap::kIndex8_Config, 2, 2); | 23 bm->allocPixels(SkImageInfo::Make(2, 2, kIndex_8_SkColorType, |
24 bm->allocPixels(ctable); | 24 kPremul_SkAlphaType), |
| 25 NULL, ctable); |
25 ctable->unref(); | 26 ctable->unref(); |
26 | 27 |
27 *bm->getAddr8(0, 0) = 0; | 28 *bm->getAddr8(0, 0) = 0; |
28 *bm->getAddr8(1, 0) = 1; | 29 *bm->getAddr8(1, 0) = 1; |
29 *bm->getAddr8(0, 1) = 2; | 30 *bm->getAddr8(0, 1) = 2; |
30 *bm->getAddr8(1, 1) = 3; | 31 *bm->getAddr8(1, 1) = 3; |
31 } | 32 } |
32 | 33 |
33 static SkScalar draw_bm(SkCanvas* canvas, const SkBitmap& bm, | 34 static SkScalar draw_bm(SkCanvas* canvas, const SkBitmap& bm, |
34 SkScalar x, SkScalar y, SkPaint* paint) { | 35 SkScalar x, SkScalar y, SkPaint* paint) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 private: | 124 private: |
124 typedef GM INHERITED; | 125 typedef GM INHERITED; |
125 }; | 126 }; |
126 | 127 |
127 ////////////////////////////////////////////////////////////////////////////// | 128 ////////////////////////////////////////////////////////////////////////////// |
128 | 129 |
129 static GM* MyFactory(void*) { return new FilterGM; } | 130 static GM* MyFactory(void*) { return new FilterGM; } |
130 static GMRegistry reg(MyFactory); | 131 static GMRegistry reg(MyFactory); |
131 | 132 |
132 } | 133 } |
OLD | NEW |