| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 | 9 |
| 10 namespace skiagm { | 10 namespace skiagm { |
| 11 | 11 |
| 12 // This GM exercises HighQuality anisotropic filtering. | 12 // This GM exercises HighQuality anisotropic filtering. |
| 13 class AnisotropicGM : public GM { | 13 class AnisotropicGM : public GM { |
| 14 public: | 14 public: |
| 15 AnisotropicGM() : fFilterQuality(kHigh_SkFilterQuality) { | 15 AnisotropicGM() : fFilterQuality(kHigh_SkFilterQuality) { |
| 16 this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); | 16 this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); |
| 17 } | 17 } |
| 18 | 18 |
| 19 protected: | 19 protected: |
| 20 | 20 |
| 21 SkString onShortName() override { return SkString("anisotropic_hq"); } | 21 SkString onShortName() override { return SkString("anisotropic_hq"); } |
| 22 | 22 |
| 23 SkISize onISize() override { | 23 SkISize onISize() override { |
| 24 return SkISize::Make(2*kImageSize + 3*kSpacer, | 24 return SkISize::Make(2*kImageSize + 3*kSpacer, |
| 25 kNumVertImages*kImageSize + (kNumVertImages+1)*kSpa
cer); | 25 kNumVertImages*kImageSize + (kNumVertImages+1)*kSpa
cer); |
| 26 } | 26 } |
| 27 | 27 |
| 28 // Create an image consisting of lines radiating from its center | 28 // Create an image consisting of lines radiating from its center |
| 29 void onOnceBeforeDraw() override { | 29 void onOnceBeforeDraw() override { |
| 30 static const int kNumLines = 100; | 30 constexpr int kNumLines = 100; |
| 31 static const SkScalar kAngleStep = 360.0f / kNumLines; | 31 constexpr SkScalar kAngleStep = 360.0f / kNumLines; |
| 32 static const int kInnerOffset = 10; | 32 constexpr int kInnerOffset = 10; |
| 33 | 33 |
| 34 fBM.allocN32Pixels(kImageSize, kImageSize, true); | 34 fBM.allocN32Pixels(kImageSize, kImageSize, true); |
| 35 | 35 |
| 36 SkCanvas canvas(fBM); | 36 SkCanvas canvas(fBM); |
| 37 | 37 |
| 38 canvas.clear(SK_ColorWHITE); | 38 canvas.clear(SK_ColorWHITE); |
| 39 | 39 |
| 40 SkPaint p; | 40 SkPaint p; |
| 41 p.setAntiAlias(true); | 41 p.setAntiAlias(true); |
| 42 | 42 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // Position the more highly squashed images with their less squa
shed counterparts | 90 // Position the more highly squashed images with their less squa
shed counterparts |
| 91 xOff = fBM.width() + 2*kSpacer + fBM.width() - width; | 91 xOff = fBM.width() + 2*kSpacer + fBM.width() - width; |
| 92 yOff = kSpacer + (SK_ARRAY_COUNT(gScales) - i - 1) * (fBM.height
() + kSpacer); | 92 yOff = kSpacer + (SK_ARRAY_COUNT(gScales) - i - 1) * (fBM.height
() + kSpacer); |
| 93 } | 93 } |
| 94 | 94 |
| 95 this->draw(canvas, xOff, yOff, width, fBM.height()); | 95 this->draw(canvas, xOff, yOff, width, fBM.height()); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 static const int kImageSize = 256; | 100 static constexpr int kImageSize = 256; |
| 101 static const int kSpacer = 10; | 101 static constexpr int kSpacer = 10; |
| 102 static const int kNumVertImages = 5; | 102 static constexpr int kNumVertImages = 5; |
| 103 | 103 |
| 104 SkBitmap fBM; | 104 SkBitmap fBM; |
| 105 SkFilterQuality fFilterQuality; | 105 SkFilterQuality fFilterQuality; |
| 106 | 106 |
| 107 typedef GM INHERITED; | 107 typedef GM INHERITED; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 ////////////////////////////////////////////////////////////////////////////// | 110 ////////////////////////////////////////////////////////////////////////////// |
| 111 | 111 |
| 112 DEF_GM(return new AnisotropicGM;) | 112 DEF_GM(return new AnisotropicGM;) |
| 113 } | 113 } |
| OLD | NEW |