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 // This test only works with the GPU backend. | 9 // This test only works with the GPU backend. |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 /** | 23 /** |
24 * This GM directly exercises GrTextureDomainEffect. | 24 * This GM directly exercises GrTextureDomainEffect. |
25 */ | 25 */ |
26 class TextureDomainEffect : public GM { | 26 class TextureDomainEffect : public GM { |
27 public: | 27 public: |
28 TextureDomainEffect() { | 28 TextureDomainEffect() { |
29 this->setBGColor(0xFFFFFFFF); | 29 this->setBGColor(0xFFFFFFFF); |
30 } | 30 } |
31 | 31 |
32 protected: | 32 protected: |
33 SkString onShortName() SK_OVERRIDE { | 33 SkString onShortName() override { |
34 return SkString("texture_domain_effect"); | 34 return SkString("texture_domain_effect"); |
35 } | 35 } |
36 | 36 |
37 SkISize onISize() SK_OVERRIDE { | 37 SkISize onISize() override { |
38 const SkScalar canvasWidth = kDrawPad + | 38 const SkScalar canvasWidth = kDrawPad + |
39 (kTargetWidth + 2 * kDrawPad) * GrTextureDomain::kModeCount + | 39 (kTargetWidth + 2 * kDrawPad) * GrTextureDomain::kModeCount + |
40 kTestPad * GrTextureDomain::kModeCount; | 40 kTestPad * GrTextureDomain::kModeCount; |
41 return SkISize::Make(SkScalarCeilToInt(canvasWidth), 800); | 41 return SkISize::Make(SkScalarCeilToInt(canvasWidth), 800); |
42 } | 42 } |
43 | 43 |
44 void onOnceBeforeDraw() SK_OVERRIDE { | 44 void onOnceBeforeDraw() override { |
45 fBmp.allocN32Pixels(kTargetWidth, kTargetHeight); | 45 fBmp.allocN32Pixels(kTargetWidth, kTargetHeight); |
46 SkCanvas canvas(fBmp); | 46 SkCanvas canvas(fBmp); |
47 canvas.clear(0x00000000); | 47 canvas.clear(0x00000000); |
48 SkPaint paint; | 48 SkPaint paint; |
49 | 49 |
50 SkColor colors1[] = { SK_ColorCYAN, SK_ColorLTGRAY, SK_ColorGRAY }; | 50 SkColor colors1[] = { SK_ColorCYAN, SK_ColorLTGRAY, SK_ColorGRAY }; |
51 paint.setShader(SkGradientShader::CreateSweep(65.f, 75.f, colors1, | 51 paint.setShader(SkGradientShader::CreateSweep(65.f, 75.f, colors1, |
52 NULL, SK_ARRAY_COUNT(color
s1)))->unref(); | 52 NULL, SK_ARRAY_COUNT(color
s1)))->unref(); |
53 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, | 53 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, |
54 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); | 54 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); |
55 | 55 |
56 SkColor colors2[] = { SK_ColorMAGENTA, SK_ColorLTGRAY, SK_ColorYELLOW }; | 56 SkColor colors2[] = { SK_ColorMAGENTA, SK_ColorLTGRAY, SK_ColorYELLOW }; |
57 paint.setShader(SkGradientShader::CreateSweep(45.f, 55.f, colors2, NULL, | 57 paint.setShader(SkGradientShader::CreateSweep(45.f, 55.f, colors2, NULL, |
58 SK_ARRAY_COUNT(colors2)))-
>unref(); | 58 SK_ARRAY_COUNT(colors2)))-
>unref(); |
59 paint.setXfermodeMode(SkXfermode::kDarken_Mode); | 59 paint.setXfermodeMode(SkXfermode::kDarken_Mode); |
60 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, | 60 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, |
61 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); | 61 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); |
62 | 62 |
63 SkColor colors3[] = { SK_ColorBLUE, SK_ColorLTGRAY, SK_ColorGREEN }; | 63 SkColor colors3[] = { SK_ColorBLUE, SK_ColorLTGRAY, SK_ColorGREEN }; |
64 paint.setShader(SkGradientShader::CreateSweep(25.f, 35.f, colors3, NULL, | 64 paint.setShader(SkGradientShader::CreateSweep(25.f, 35.f, colors3, NULL, |
65 SK_ARRAY_COUNT(colors3)))-
>unref(); | 65 SK_ARRAY_COUNT(colors3)))-
>unref(); |
66 paint.setXfermodeMode(SkXfermode::kLighten_Mode); | 66 paint.setXfermodeMode(SkXfermode::kLighten_Mode); |
67 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, | 67 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, |
68 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); | 68 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); |
69 } | 69 } |
70 | 70 |
71 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 71 void onDraw(SkCanvas* canvas) override { |
72 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 72 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
73 if (NULL == rt) { | 73 if (NULL == rt) { |
74 return; | 74 return; |
75 } | 75 } |
76 GrContext* context = rt->getContext(); | 76 GrContext* context = rt->getContext(); |
77 if (NULL == context) { | 77 if (NULL == context) { |
78 this->drawGpuOnlyMessage(canvas); | 78 this->drawGpuOnlyMessage(canvas); |
79 return; | 79 return; |
80 } | 80 } |
81 | 81 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 }; | 152 }; |
153 | 153 |
154 // Windows builds did not like SkScalar initialization in class :( | 154 // Windows builds did not like SkScalar initialization in class :( |
155 const SkScalar TextureDomainEffect::kDrawPad = 10.f; | 155 const SkScalar TextureDomainEffect::kDrawPad = 10.f; |
156 const SkScalar TextureDomainEffect::kTestPad = 10.f; | 156 const SkScalar TextureDomainEffect::kTestPad = 10.f; |
157 | 157 |
158 DEF_GM( return SkNEW(TextureDomainEffect); ) | 158 DEF_GM( return SkNEW(TextureDomainEffect); ) |
159 } | 159 } |
160 | 160 |
161 #endif | 161 #endif |
OLD | NEW |