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 #include "SkImage.h" | 9 #include "SkImage.h" |
10 #include "SkImageSource.h" | 10 #include "SkImageSource.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 SkString onShortName() override { | 24 SkString onShortName() override { |
25 SkString name("imagesrc2_"); | 25 SkString name("imagesrc2_"); |
26 name.append(fSuffix); | 26 name.append(fSuffix); |
27 return name; | 27 return name; |
28 } | 28 } |
29 | 29 |
30 SkISize onISize() override { return SkISize::Make(256, 256); } | 30 SkISize onISize() override { return SkISize::Make(256, 256); } |
31 | 31 |
32 // Create an image with high frequency vertical stripes | 32 // Create an image with high frequency vertical stripes |
33 void onOnceBeforeDraw() override { | 33 void onOnceBeforeDraw() override { |
34 static const SkPMColor gColors[] = { | 34 constexpr SkPMColor gColors[] = { |
35 SK_ColorRED, SK_ColorGRAY, | 35 SK_ColorRED, SK_ColorGRAY, |
36 SK_ColorGREEN, SK_ColorGRAY, | 36 SK_ColorGREEN, SK_ColorGRAY, |
37 SK_ColorBLUE, SK_ColorGRAY, | 37 SK_ColorBLUE, SK_ColorGRAY, |
38 SK_ColorCYAN, SK_ColorGRAY, | 38 SK_ColorCYAN, SK_ColorGRAY, |
39 SK_ColorMAGENTA, SK_ColorGRAY, | 39 SK_ColorMAGENTA, SK_ColorGRAY, |
40 SK_ColorYELLOW, SK_ColorGRAY, | 40 SK_ColorYELLOW, SK_ColorGRAY, |
41 SK_ColorWHITE, SK_ColorGRAY, | 41 SK_ColorWHITE, SK_ColorGRAY, |
42 }; | 42 }; |
43 | 43 |
44 auto surface(SkSurface::MakeRasterN32Premul(kImageSize, kImageSize)); | 44 auto surface(SkSurface::MakeRasterN32Premul(kImageSize, kImageSize)); |
(...skipping 21 matching lines...) Expand all Loading... |
66 const SkRect dstRect = SkRect::MakeLTRB(0.75f, 0.75f, 225.75f, 225.75f); | 66 const SkRect dstRect = SkRect::MakeLTRB(0.75f, 0.75f, 225.75f, 225.75f); |
67 | 67 |
68 SkPaint p; | 68 SkPaint p; |
69 p.setImageFilter(SkImageSource::Make(fImage, srcRect, dstRect, fFilter))
; | 69 p.setImageFilter(SkImageSource::Make(fImage, srcRect, dstRect, fFilter))
; |
70 | 70 |
71 canvas->saveLayer(nullptr, &p); | 71 canvas->saveLayer(nullptr, &p); |
72 canvas->restore(); | 72 canvas->restore(); |
73 } | 73 } |
74 | 74 |
75 private: | 75 private: |
76 static const int kImageSize = 503; | 76 static constexpr int kImageSize = 503; |
77 | 77 |
78 SkString fSuffix; | 78 SkString fSuffix; |
79 SkFilterQuality fFilter; | 79 SkFilterQuality fFilter; |
80 sk_sp<SkImage> fImage; | 80 sk_sp<SkImage> fImage; |
81 | 81 |
82 typedef GM INHERITED; | 82 typedef GM INHERITED; |
83 }; | 83 }; |
84 | 84 |
85 ////////////////////////////////////////////////////////////////////////////// | 85 ////////////////////////////////////////////////////////////////////////////// |
86 | 86 |
87 DEF_GM(return new ImageSourceGM("none", kNone_SkFilterQuality);) | 87 DEF_GM(return new ImageSourceGM("none", kNone_SkFilterQuality);) |
88 DEF_GM(return new ImageSourceGM("low", kLow_SkFilterQuality);) | 88 DEF_GM(return new ImageSourceGM("low", kLow_SkFilterQuality);) |
89 DEF_GM(return new ImageSourceGM("med", kMedium_SkFilterQuality);) | 89 DEF_GM(return new ImageSourceGM("med", kMedium_SkFilterQuality);) |
90 DEF_GM(return new ImageSourceGM("high", kHigh_SkFilterQuality);) | 90 DEF_GM(return new ImageSourceGM("high", kHigh_SkFilterQuality);) |
91 } | 91 } |
OLD | NEW |