| 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 virtual SkString onShortName() SK_OVERRIDE { | 33 SkString onShortName() SK_OVERRIDE { |
| 34 return SkString("texture_domain_effect"); | 34 return SkString("texture_domain_effect"); |
| 35 } | 35 } |
| 36 | 36 |
| 37 virtual SkISize onISize() SK_OVERRIDE { | 37 SkISize onISize() SK_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 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 44 uint32_t onGetFlags() const SK_OVERRIDE { |
| 45 // This is a GPU-specific GM. | 45 // This is a GPU-specific GM. |
| 46 return kGPUOnly_Flag; | 46 return kGPUOnly_Flag; |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 49 void onOnceBeforeDraw() SK_OVERRIDE { |
| 50 fBmp.allocN32Pixels(kTargetWidth, kTargetHeight); | 50 fBmp.allocN32Pixels(kTargetWidth, kTargetHeight); |
| 51 SkCanvas canvas(fBmp); | 51 SkCanvas canvas(fBmp); |
| 52 canvas.clear(0x00000000); | 52 canvas.clear(0x00000000); |
| 53 SkPaint paint; | 53 SkPaint paint; |
| 54 | 54 |
| 55 SkColor colors1[] = { SK_ColorCYAN, SK_ColorLTGRAY, SK_ColorGRAY }; | 55 SkColor colors1[] = { SK_ColorCYAN, SK_ColorLTGRAY, SK_ColorGRAY }; |
| 56 paint.setShader(SkGradientShader::CreateSweep(65.f, 75.f, colors1, | 56 paint.setShader(SkGradientShader::CreateSweep(65.f, 75.f, colors1, |
| 57 NULL, SK_ARRAY_COUNT(color
s1)))->unref(); | 57 NULL, SK_ARRAY_COUNT(color
s1)))->unref(); |
| 58 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, | 58 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, |
| 59 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); | 59 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); |
| 60 | 60 |
| 61 SkColor colors2[] = { SK_ColorMAGENTA, SK_ColorLTGRAY, SK_ColorYELLOW }; | 61 SkColor colors2[] = { SK_ColorMAGENTA, SK_ColorLTGRAY, SK_ColorYELLOW }; |
| 62 paint.setShader(SkGradientShader::CreateSweep(45.f, 55.f, colors2, NULL, | 62 paint.setShader(SkGradientShader::CreateSweep(45.f, 55.f, colors2, NULL, |
| 63 SK_ARRAY_COUNT(colors2)))-
>unref(); | 63 SK_ARRAY_COUNT(colors2)))-
>unref(); |
| 64 paint.setXfermodeMode(SkXfermode::kDarken_Mode); | 64 paint.setXfermodeMode(SkXfermode::kDarken_Mode); |
| 65 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, | 65 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, |
| 66 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); | 66 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); |
| 67 | 67 |
| 68 SkColor colors3[] = { SK_ColorBLUE, SK_ColorLTGRAY, SK_ColorGREEN }; | 68 SkColor colors3[] = { SK_ColorBLUE, SK_ColorLTGRAY, SK_ColorGREEN }; |
| 69 paint.setShader(SkGradientShader::CreateSweep(25.f, 35.f, colors3, NULL, | 69 paint.setShader(SkGradientShader::CreateSweep(25.f, 35.f, colors3, NULL, |
| 70 SK_ARRAY_COUNT(colors3)))-
>unref(); | 70 SK_ARRAY_COUNT(colors3)))-
>unref(); |
| 71 paint.setXfermodeMode(SkXfermode::kLighten_Mode); | 71 paint.setXfermodeMode(SkXfermode::kLighten_Mode); |
| 72 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, | 72 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, |
| 73 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); | 73 fBmp.width() + 10.f, fBmp.height() + 10
.f), paint); |
| 74 } | 74 } |
| 75 | 75 |
| 76 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 76 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 77 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 77 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
| 78 if (NULL == rt) { | 78 if (NULL == rt) { |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 GrContext* context = rt->getContext(); | 81 GrContext* context = rt->getContext(); |
| 82 if (NULL == context) { | 82 if (NULL == context) { |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 | 85 |
| 86 GrTestTarget tt; | 86 GrTestTarget tt; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 // Windows builds did not like SkScalar initialization in class :( | 155 // Windows builds did not like SkScalar initialization in class :( |
| 156 const SkScalar TextureDomainEffect::kDrawPad = 10.f; | 156 const SkScalar TextureDomainEffect::kDrawPad = 10.f; |
| 157 const SkScalar TextureDomainEffect::kTestPad = 10.f; | 157 const SkScalar TextureDomainEffect::kTestPad = 10.f; |
| 158 | 158 |
| 159 DEF_GM( return SkNEW(TextureDomainEffect); ) | 159 DEF_GM( return SkNEW(TextureDomainEffect); ) |
| 160 } | 160 } |
| 161 | 161 |
| 162 #endif | 162 #endif |
| OLD | NEW |