OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "sk_tool_utils.h" | 9 #include "sk_tool_utils.h" |
10 | 10 |
11 static void make_bm(SkBitmap* bm) { | 11 static void make_bm(SkBitmap* bm) { |
12 const SkColor colors[4] = { | 12 const SkColor colors[4] = { |
13 SK_ColorRED, SK_ColorGREEN, | 13 SK_ColorRED, SK_ColorGREEN, |
14 SK_ColorBLUE, SK_ColorWHITE | 14 SK_ColorBLUE, SK_ColorWHITE |
15 }; | 15 }; |
16 SkPMColor colorsPM[4]; | 16 SkPMColor colorsPM[4]; |
17 for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) { | 17 for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) { |
18 colorsPM[i] = SkPreMultiplyColor(colors[i]); | 18 colorsPM[i] = SkPreMultiplyColor(colors[i]); |
19 } | 19 } |
20 SkColorTable* ctable = new SkColorTable(colorsPM, 4); | 20 SkColorTable* ctable = new SkColorTable(colorsPM, 4); |
21 | 21 |
22 bm->allocPixels(SkImageInfo::Make(2, 2, kIndex_8_SkColorType, | 22 bm->allocPixels(SkImageInfo::Make(2, 2, kIndex_8_SkColorType, |
23 kPremul_SkAlphaType), | 23 kPremul_SkAlphaType), |
24 NULL, ctable); | 24 nullptr, ctable); |
25 ctable->unref(); | 25 ctable->unref(); |
26 | 26 |
27 *bm->getAddr8(0, 0) = 0; | 27 *bm->getAddr8(0, 0) = 0; |
28 *bm->getAddr8(1, 0) = 1; | 28 *bm->getAddr8(1, 0) = 1; |
29 *bm->getAddr8(0, 1) = 2; | 29 *bm->getAddr8(0, 1) = 2; |
30 *bm->getAddr8(1, 1) = 3; | 30 *bm->getAddr8(1, 1) = 3; |
31 } | 31 } |
32 | 32 |
33 static SkScalar draw_bm(SkCanvas* canvas, const SkBitmap& bm, | 33 static SkScalar draw_bm(SkCanvas* canvas, const SkBitmap& bm, |
34 SkScalar x, SkScalar y, SkPaint* paint) { | 34 SkScalar x, SkScalar y, SkPaint* paint) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 canvas->drawBitmap(fBitmap, 10, 10, &paint); // should stay blue (ign
ore paint's color) | 153 canvas->drawBitmap(fBitmap, 10, 10, &paint); // should stay blue (ign
ore paint's color) |
154 canvas->drawBitmap(fAlpha, 120, 10, &paint); // should draw red | 154 canvas->drawBitmap(fAlpha, 120, 10, &paint); // should draw red |
155 } | 155 } |
156 | 156 |
157 private: | 157 private: |
158 typedef skiagm::GM INHERITED; | 158 typedef skiagm::GM INHERITED; |
159 }; | 159 }; |
160 DEF_GM( return new TestExtractAlphaGM; ) | 160 DEF_GM( return new TestExtractAlphaGM; ) |
161 | 161 |
OLD | NEW |