OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 | 12 |
13 // This GM tests out the quick reject bounds of the blur mask filter. It draws | 13 // This GM tests out the quick reject bounds of the blur mask filter. It draws |
14 // four blurred rects around a central clip. The blurred rect geometry outset | 14 // four blurred rects around a central clip. The blurred rect geometry outset |
15 // by the blur radius does not overlap the clip rect so, if the blur clipping | 15 // by the blur radius does not overlap the clip rect so, if the blur clipping |
16 // just uses the radius, they will be clipped out (and the result will differ | 16 // just uses the radius, they will be clipped out (and the result will differ |
17 // from the result if quick reject were disabled. If the blur clipping uses | 17 // from the result if quick reject were disabled. If the blur clipping uses |
18 // the correct 3 sigma bound then the images with and without quick rejecting | 18 // the correct 3 sigma bound then the images with and without quick rejecting |
19 // will be the same. | 19 // will be the same. |
20 class BlurQuickRejectGM : public skiagm::GM { | 20 class BlurQuickRejectGM : public skiagm::GM { |
21 public: | 21 public: |
22 BlurQuickRejectGM() {} | 22 BlurQuickRejectGM() {} |
23 | 23 |
24 protected: | 24 protected: |
25 SkString onShortName() SK_OVERRIDE { | 25 SkString onShortName() override { |
26 return SkString("blurquickreject"); | 26 return SkString("blurquickreject"); |
27 } | 27 } |
28 | 28 |
29 SkISize onISize() SK_OVERRIDE { | 29 SkISize onISize() override { |
30 return SkISize::Make(kWidth, kHeight); | 30 return SkISize::Make(kWidth, kHeight); |
31 } | 31 } |
32 | 32 |
33 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 33 void onDraw(SkCanvas* canvas) override { |
34 static const SkScalar kBlurRadius = SkIntToScalar(20); | 34 static const SkScalar kBlurRadius = SkIntToScalar(20); |
35 static const SkScalar kBoxSize = SkIntToScalar(100); | 35 static const SkScalar kBoxSize = SkIntToScalar(100); |
36 | 36 |
37 SkRect clipRect = SkRect::MakeXYWH(0, 0, kBoxSize, kBoxSize); | 37 SkRect clipRect = SkRect::MakeXYWH(0, 0, kBoxSize, kBoxSize); |
38 SkRect blurRects[] = { | 38 SkRect blurRects[] = { |
39 { -kBoxSize - (kBlurRadius+1), 0, -(kBlurRadius+1), kBoxSize }, | 39 { -kBoxSize - (kBlurRadius+1), 0, -(kBlurRadius+1), kBoxSize }, |
40 { 0, -kBoxSize - (kBlurRadius+1), kBoxSize, -(kBlurRadius+1) }, | 40 { 0, -kBoxSize - (kBlurRadius+1), kBoxSize, -(kBlurRadius+1) }, |
41 { kBoxSize+kBlurRadius+1, 0, 2*kBoxSize+kBlurRadius+1, kBoxSize }, | 41 { kBoxSize+kBlurRadius+1, 0, 2*kBoxSize+kBlurRadius+1, kBoxSize }, |
42 { 0, kBoxSize+kBlurRadius+1, kBoxSize, 2*kBoxSize+kBlurRadius+1 } | 42 { 0, kBoxSize+kBlurRadius+1, kBoxSize, 2*kBoxSize+kBlurRadius+1 } |
43 }; | 43 }; |
(...skipping 30 matching lines...) Expand all Loading... |
74 } | 74 } |
75 | 75 |
76 private: | 76 private: |
77 static const int kWidth = 300; | 77 static const int kWidth = 300; |
78 static const int kHeight = 300; | 78 static const int kHeight = 300; |
79 | 79 |
80 typedef GM INHERITED; | 80 typedef GM INHERITED; |
81 }; | 81 }; |
82 | 82 |
83 DEF_GM( return new BlurQuickRejectGM(); ) | 83 DEF_GM( return new BlurQuickRejectGM(); ) |
OLD | NEW |