OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 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 // This test only works with the GPU backend. | 9 // This test only works with the GPU backend. |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 return SkString("const_color_processor"); | 33 return SkString("const_color_processor"); |
34 } | 34 } |
35 | 35 |
36 SkISize onISize() override { | 36 SkISize onISize() override { |
37 return SkISize::Make(kWidth, kHeight); | 37 return SkISize::Make(kWidth, kHeight); |
38 } | 38 } |
39 | 39 |
40 void onOnceBeforeDraw() override { | 40 void onOnceBeforeDraw() override { |
41 SkColor colors[] = { 0xFFFF0000, 0x2000FF00, 0xFF0000FF}; | 41 SkColor colors[] = { 0xFFFF0000, 0x2000FF00, 0xFF0000FF}; |
42 SkPoint pts[] = { SkPoint::Make(0, 0), SkPoint::Make(kRectSize, kRectSiz
e) }; | 42 SkPoint pts[] = { SkPoint::Make(0, 0), SkPoint::Make(kRectSize, kRectSiz
e) }; |
43 fShader.reset(SkGradientShader::CreateLinear(pts, colors, NULL, SK_ARRAY
_COUNT(colors), | 43 fShader.reset(SkGradientShader::CreateLinear(pts, colors, nullptr, SK_AR
RAY_COUNT(colors), |
44 SkShader::kClamp_TileMode)); | 44 SkShader::kClamp_TileMode)); |
45 } | 45 } |
46 | 46 |
47 void onDraw(SkCanvas* canvas) override { | 47 void onDraw(SkCanvas* canvas) override { |
48 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 48 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
49 if (NULL == rt) { | 49 if (nullptr == rt) { |
50 return; | 50 return; |
51 } | 51 } |
52 GrContext* context = rt->getContext(); | 52 GrContext* context = rt->getContext(); |
53 if (NULL == context) { | 53 if (nullptr == context) { |
54 this->drawGpuOnlyMessage(canvas); | 54 this->drawGpuOnlyMessage(canvas); |
55 return; | 55 return; |
56 } | 56 } |
57 | 57 |
58 static const GrColor kColors[] = { | 58 static const GrColor kColors[] = { |
59 0xFFFFFFFF, | 59 0xFFFFFFFF, |
60 0xFFFF00FF, | 60 0xFFFF00FF, |
61 0x80000000, | 61 0x80000000, |
62 0x00000000, | 62 0x00000000, |
63 }; | 63 }; |
(...skipping 21 matching lines...) Expand all Loading... |
85 // translate by x,y for the canvas draws and the test target
draws. | 85 // translate by x,y for the canvas draws and the test target
draws. |
86 canvas->save(); | 86 canvas->save(); |
87 canvas->translate(x, y); | 87 canvas->translate(x, y); |
88 const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y); | 88 const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y); |
89 | 89 |
90 // rect to draw | 90 // rect to draw |
91 SkRect renderRect = SkRect::MakeXYWH(0, 0, kRectSize, kRectS
ize); | 91 SkRect renderRect = SkRect::MakeXYWH(0, 0, kRectSize, kRectS
ize); |
92 | 92 |
93 GrTestTarget tt; | 93 GrTestTarget tt; |
94 context->getTestTarget(&tt); | 94 context->getTestTarget(&tt); |
95 if (NULL == tt.target()) { | 95 if (nullptr == tt.target()) { |
96 SkDEBUGFAIL("Couldn't get Gr test target."); | 96 SkDEBUGFAIL("Couldn't get Gr test target."); |
97 return; | 97 return; |
98 } | 98 } |
99 | 99 |
100 GrPaint grPaint; | 100 GrPaint grPaint; |
101 SkPaint skPaint; | 101 SkPaint skPaint; |
102 if (paintType >= SK_ARRAY_COUNT(kPaintColors)) { | 102 if (paintType >= SK_ARRAY_COUNT(kPaintColors)) { |
103 skPaint.setShader(fShader); | 103 skPaint.setShader(fShader); |
104 } else { | 104 } else { |
105 skPaint.setColor(kPaintColors[paintType]); | 105 skPaint.setColor(kPaintColors[paintType]); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 typedef GM INHERITED; | 189 typedef GM INHERITED; |
190 }; | 190 }; |
191 | 191 |
192 const SkScalar ConstColorProcessor::kPad = 10.f; | 192 const SkScalar ConstColorProcessor::kPad = 10.f; |
193 const SkScalar ConstColorProcessor::kRectSize = 20.f; | 193 const SkScalar ConstColorProcessor::kRectSize = 20.f; |
194 | 194 |
195 DEF_GM(return new ConstColorProcessor;) | 195 DEF_GM(return new ConstColorProcessor;) |
196 } | 196 } |
197 | 197 |
198 #endif | 198 #endif |
OLD | NEW |