OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 | 9 |
10 DEF_SIMPLE_GM(blend, canvas, 300, 100) { | 10 DEF_SIMPLE_GM(blend, canvas, 300, 100) { |
(...skipping 15 matching lines...) Expand all Loading... |
26 canvas->drawRect(SkRect::MakeXYWH(1,0,1,1), p); | 26 canvas->drawRect(SkRect::MakeXYWH(1,0,1,1), p); |
27 canvas->restore(); | 27 canvas->restore(); |
28 | 28 |
29 p.setColor(SK_ColorRED); | 29 p.setColor(SK_ColorRED); |
30 canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p); | 30 canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p); |
31 canvas->saveLayerAlpha(nullptr, 0xFC); | 31 canvas->saveLayerAlpha(nullptr, 0xFC); |
32 p.setColor(sk_tool_utils::color_to_565(0xFF008000)); | 32 p.setColor(sk_tool_utils::color_to_565(0xFF008000)); |
33 canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p); | 33 canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p); |
34 canvas->restore(); | 34 canvas->restore(); |
35 canvas->restore(); | 35 canvas->restore(); |
36 | |
37 // Print out the colors in each block (if we're looking at 8888 raster). | |
38 if (canvas->imageInfo().colorType() == kN32_SkColorType) { | |
39 SkPixmap pmap; | |
40 if (const SkPMColor* px = canvas->peekPixels(&pmap) ? pmap.addr32() : nu
llptr) { | |
41 p.setColor(SK_ColorWHITE); | |
42 for (int i = 0; i < 3; i++) { | |
43 SkPMColor c = px[i * 100]; | |
44 SkString text = SkStringPrintf("0x%08x", c); | |
45 canvas->drawText(text.c_str(), text.size(), i * 100.0f + 20.0f,
50.0f, p); | |
46 } | |
47 } | |
48 } | |
49 } | 36 } |
OLD | NEW |