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 "SkGradientShader.h" | 8 #include "SkGradientShader.h" |
9 #include "SkSurface.h" | 9 #include "SkSurface.h" |
10 #include "gm.h" | 10 #include "gm.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 SK_ColorCYAN, | 25 SK_ColorCYAN, |
26 SK_ColorBLUE, | 26 SK_ColorBLUE, |
27 SK_ColorMAGENTA, | 27 SK_ColorMAGENTA, |
28 }; | 28 }; |
29 const SkScalar kRowHeight = height / SK_ARRAY_COUNT(kColors); | 29 const SkScalar kRowHeight = height / SK_ARRAY_COUNT(kColors); |
30 for (size_t i = 0; i < SK_ARRAY_COUNT(kColors); ++i) { | 30 for (size_t i = 0; i < SK_ARRAY_COUNT(kColors); ++i) { |
31 SkColor shaderColors[2]; | 31 SkColor shaderColors[2]; |
32 shaderColors[0] = SK_AlphaTRANSPARENT; | 32 shaderColors[0] = SK_AlphaTRANSPARENT; |
33 shaderColors[1] = kColors[i]; | 33 shaderColors[1] = kColors[i]; |
34 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear( | 34 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear( |
35 pts, shaderColors, NULL, 2, SkShader::kClamp_TileMode)); | 35 pts, shaderColors, nullptr, 2, SkShader::kClamp_TileMode)); |
36 SkRect r = SkRect::MakeXYWH(0, i * kRowHeight, width, kRowHeight); | 36 SkRect r = SkRect::MakeXYWH(0, i * kRowHeight, width, kRowHeight); |
37 SkPaint p; | 37 SkPaint p; |
38 p.setShader(shader); | 38 p.setShader(shader); |
39 canvas->drawRect(r, p); | 39 canvas->drawRect(r, p); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 // http://crrev.com/834303005 | 43 // http://crrev.com/834303005 |
44 static SkShader* create_checkerboard_shader(SkColor c1, SkColor c2, int size) { | 44 static SkShader* create_checkerboard_shader(SkColor c1, SkColor c2, int size) { |
45 SkBitmap bm; | 45 SkBitmap bm; |
(...skipping 17 matching lines...) Expand all Loading... |
63 * checkerboard pattern looks correct. | 63 * checkerboard pattern looks correct. |
64 */ | 64 */ |
65 DEF_SIMPLE_GM(transparency_check, canvas, 1792, 1080) { | 65 DEF_SIMPLE_GM(transparency_check, canvas, 1792, 1080) { |
66 checkerboard(canvas, sk_tool_utils::color_to_565(0xFF999999), | 66 checkerboard(canvas, sk_tool_utils::color_to_565(0xFF999999), |
67 sk_tool_utils::color_to_565(0xFF666666), 8); | 67 sk_tool_utils::color_to_565(0xFF666666), 8); |
68 { | 68 { |
69 SkAutoCanvasRestore autoCanvasRestore(canvas, true); | 69 SkAutoCanvasRestore autoCanvasRestore(canvas, true); |
70 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(256, 9)); | 70 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(256, 9)); |
71 make_transparency(surface->getCanvas(), 256.0f, 9.0f); | 71 make_transparency(surface->getCanvas(), 256.0f, 9.0f); |
72 canvas->scale(7.0f, 120.0f); | 72 canvas->scale(7.0f, 120.0f); |
73 surface->draw(canvas, 0, 0, NULL); | 73 surface->draw(canvas, 0, 0, nullptr); |
74 } | 74 } |
75 } | 75 } |
OLD | NEW |