| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
| 9 #include "SkBitmapSource.h" | 9 #include "SkBitmapSource.h" |
| 10 #include "SkBlurImageFilter.h" | 10 #include "SkBlurImageFilter.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace skiagm { | 25 namespace skiagm { |
| 26 | 26 |
| 27 class ImageFiltersClippedGM : public GM { | 27 class ImageFiltersClippedGM : public GM { |
| 28 public: | 28 public: |
| 29 ImageFiltersClippedGM() : fInitialized(false) { | 29 ImageFiltersClippedGM() : fInitialized(false) { |
| 30 this->setBGColor(0x00000000); | 30 this->setBGColor(0x00000000); |
| 31 } | 31 } |
| 32 | 32 |
| 33 protected: | 33 protected: |
| 34 | 34 |
| 35 SkString onShortName() SK_OVERRIDE { | 35 SkString onShortName() override { |
| 36 return SkString("imagefiltersclipped"); | 36 return SkString("imagefiltersclipped"); |
| 37 } | 37 } |
| 38 | 38 |
| 39 SkISize onISize() SK_OVERRIDE { | 39 SkISize onISize() override { |
| 40 return SkISize::Make(860, 500); | 40 return SkISize::Make(860, 500); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void make_gradient_circle(int width, int height) { | 43 void make_gradient_circle(int width, int height) { |
| 44 SkScalar x = SkIntToScalar(width / 2); | 44 SkScalar x = SkIntToScalar(width / 2); |
| 45 SkScalar y = SkIntToScalar(height / 2); | 45 SkScalar y = SkIntToScalar(height / 2); |
| 46 SkScalar radius = SkMinScalar(x, y) * 0.8f; | 46 SkScalar radius = SkMinScalar(x, y) * 0.8f; |
| 47 fGradientCircle.allocN32Pixels(width, height); | 47 fGradientCircle.allocN32Pixels(width, height); |
| 48 SkCanvas canvas(fGradientCircle); | 48 SkCanvas canvas(fGradientCircle); |
| 49 canvas.clear(0x00000000); | 49 canvas.clear(0x00000000); |
| 50 SkColor colors[2]; | 50 SkColor colors[2]; |
| 51 colors[0] = SK_ColorWHITE; | 51 colors[0] = SK_ColorWHITE; |
| 52 colors[1] = SK_ColorBLACK; | 52 colors[1] = SK_ColorBLACK; |
| 53 SkAutoTUnref<SkShader> shader( | 53 SkAutoTUnref<SkShader> shader( |
| 54 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors,
NULL, 2, | 54 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors,
NULL, 2, |
| 55 SkShader::kClamp_TileMode) | 55 SkShader::kClamp_TileMode) |
| 56 ); | 56 ); |
| 57 SkPaint paint; | 57 SkPaint paint; |
| 58 paint.setShader(shader); | 58 paint.setShader(shader); |
| 59 canvas.drawCircle(x, y, radius, paint); | 59 canvas.drawCircle(x, y, radius, paint); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 62 void onDraw(SkCanvas* canvas) override { |
| 63 if (!fInitialized) { | 63 if (!fInitialized) { |
| 64 fCheckerboard.allocN32Pixels(64, 64); | 64 fCheckerboard.allocN32Pixels(64, 64); |
| 65 SkCanvas checkerboardCanvas(fCheckerboard); | 65 SkCanvas checkerboardCanvas(fCheckerboard); |
| 66 sk_tool_utils::draw_checkerboard(&checkerboardCanvas, 0xFFA0A0A0, 0x
FF404040, 8); | 66 sk_tool_utils::draw_checkerboard(&checkerboardCanvas, 0xFFA0A0A0, 0x
FF404040, 8); |
| 67 | 67 |
| 68 this->make_gradient_circle(64, 64); | 68 this->make_gradient_circle(64, 64); |
| 69 fInitialized = true; | 69 fInitialized = true; |
| 70 } | 70 } |
| 71 canvas->clear(0x00000000); | 71 canvas->clear(0x00000000); |
| 72 | 72 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 SkBitmap fGradientCircle; | 135 SkBitmap fGradientCircle; |
| 136 typedef GM INHERITED; | 136 typedef GM INHERITED; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 ////////////////////////////////////////////////////////////////////////////// | 139 ////////////////////////////////////////////////////////////////////////////// |
| 140 | 140 |
| 141 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } | 141 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } |
| 142 static GMRegistry reg(MyFactory); | 142 static GMRegistry reg(MyFactory); |
| 143 | 143 |
| 144 } | 144 } |
| OLD | NEW |