OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 | 8 |
9 #include "gm.h" | 9 #include "gm.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
11 #include "SkPatchUtils.h" | 11 #include "SkPatchUtils.h" |
12 | 12 |
13 static SkShader* make_shader() { | 13 static SkShader* make_shader() { |
14 const SkColor colors[] = { | 14 const SkColor colors[] = { |
15 SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, SK_ColorMAGENTA
, SK_ColorBLUE, | 15 SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, SK_ColorMAGENTA
, SK_ColorBLUE, |
16 SK_ColorYELLOW, | 16 SK_ColorYELLOW, |
17 }; | 17 }; |
18 const SkPoint pts[] = { { 100.f / 4.f, 0.f }, { 3.f * 100.f / 4.f, 100.f } }
; | 18 const SkPoint pts[] = { { 100.f / 4.f, 0.f }, { 3.f * 100.f / 4.f, 100.f } }
; |
19 | 19 |
20 return SkGradientShader::CreateLinear(pts, colors, NULL, SK_ARRAY_COUNT(colo
rs), | 20 return SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_COUNT(c
olors), |
21 SkShader::kMirror_TileMode); | 21 SkShader::kMirror_TileMode); |
22 } | 22 } |
23 | 23 |
24 static void draw_control_points(SkCanvas* canvas, const SkPoint cubics[12]) { | 24 static void draw_control_points(SkCanvas* canvas, const SkPoint cubics[12]) { |
25 //draw control points | 25 //draw control points |
26 SkPaint paint; | 26 SkPaint paint; |
27 SkPoint bottom[SkPatchUtils::kNumPtsCubic]; | 27 SkPoint bottom[SkPatchUtils::kNumPtsCubic]; |
28 SkPatchUtils::getBottomCubic(cubics, bottom); | 28 SkPatchUtils::getBottomCubic(cubics, bottom); |
29 SkPoint top[SkPatchUtils::kNumPtsCubic]; | 29 SkPoint top[SkPatchUtils::kNumPtsCubic]; |
30 SkPatchUtils::getTopCubic(cubics, top); | 30 SkPatchUtils::getTopCubic(cubics, top); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 canvas->save(); | 118 canvas->save(); |
119 for (int y = 0; y < 3; y++) { | 119 for (int y = 0; y < 3; y++) { |
120 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(modes[y])); | 120 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(modes[y])); |
121 | 121 |
122 for (int x = 0; x < 4; x++) { | 122 for (int x = 0; x < 4; x++) { |
123 canvas->save(); | 123 canvas->save(); |
124 canvas->translate(x * 350.0f, y * 350.0f); | 124 canvas->translate(x * 350.0f, y * 350.0f); |
125 switch (x) { | 125 switch (x) { |
126 case 0: | 126 case 0: |
127 canvas->drawPatch(cubics, NULL, NULL, xfer, paint); | 127 canvas->drawPatch(cubics, nullptr, nullptr, xfer, paint)
; |
128 break; | 128 break; |
129 case 1: | 129 case 1: |
130 canvas->drawPatch(cubics, colors, NULL, xfer, paint); | 130 canvas->drawPatch(cubics, colors, nullptr, xfer, paint); |
131 break; | 131 break; |
132 case 2: | 132 case 2: |
133 paint.setShader(shader); | 133 paint.setShader(shader); |
134 canvas->drawPatch(cubics, NULL, texCoords, xfer, paint); | 134 canvas->drawPatch(cubics, nullptr, texCoords, xfer, pain
t); |
135 paint.setShader(NULL); | 135 paint.setShader(nullptr); |
136 break; | 136 break; |
137 case 3: | 137 case 3: |
138 paint.setShader(shader); | 138 paint.setShader(shader); |
139 canvas->drawPatch(cubics, colors, texCoords, xfer, paint
); | 139 canvas->drawPatch(cubics, colors, texCoords, xfer, paint
); |
140 paint.setShader(NULL); | 140 paint.setShader(nullptr); |
141 break; | 141 break; |
142 default: | 142 default: |
143 break; | 143 break; |
144 } | 144 } |
145 | 145 |
146 draw_control_points(canvas, cubics); | 146 draw_control_points(canvas, cubics); |
147 canvas->restore(); | 147 canvas->restore(); |
148 } | 148 } |
149 } | 149 } |
150 canvas->restore(); | 150 canvas->restore(); |
151 } | 151 } |
152 | 152 |
153 private: | 153 private: |
154 typedef GM INHERITED; | 154 typedef GM INHERITED; |
155 }; | 155 }; |
156 | 156 |
157 DEF_GM(return new SkPatchGM;) | 157 DEF_GM(return new SkPatchGM;) |
158 } | 158 } |
OLD | NEW |