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 29 matching lines...) Expand all Loading... |
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)); |
45 SkCanvas* canvas = surface->getCanvas(); | 45 SkCanvas* canvas = surface->getCanvas(); |
46 | 46 |
47 int curColor = 0; | 47 int curColor = 0; |
48 | 48 |
49 for (int x = 0; x < kImageSize; x += 3) { | 49 for (int x = 0; x < kImageSize; x += 3) { |
50 SkRect r = SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(0), | 50 SkRect r = SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(0), |
51 SkIntToScalar(3), SkIntToScalar(kImageSi
ze)); | 51 SkIntToScalar(3), SkIntToScalar(kImageSi
ze)); |
52 SkPaint p; | 52 SkPaint p; |
53 p.setColor(gColors[curColor]); | 53 p.setColor(gColors[curColor]); |
54 canvas->drawRect(r, p); | 54 canvas->drawRect(r, p); |
55 | 55 |
56 curColor = (curColor+1) % SK_ARRAY_COUNT(gColors); | 56 curColor = (curColor+1) % SK_ARRAY_COUNT(gColors); |
57 } | 57 } |
58 | 58 |
59 fImage = surface->makeImageSnapshot(); | 59 fImage = surface->makeImageSnapshot(); |
60 } | 60 } |
(...skipping 23 matching lines...) Expand all Loading... |
84 typedef GM INHERITED; | 84 typedef GM INHERITED; |
85 }; | 85 }; |
86 | 86 |
87 ////////////////////////////////////////////////////////////////////////////// | 87 ////////////////////////////////////////////////////////////////////////////// |
88 | 88 |
89 DEF_GM(return new ImageSourceGM("none", kNone_SkFilterQuality);) | 89 DEF_GM(return new ImageSourceGM("none", kNone_SkFilterQuality);) |
90 DEF_GM(return new ImageSourceGM("low", kLow_SkFilterQuality);) | 90 DEF_GM(return new ImageSourceGM("low", kLow_SkFilterQuality);) |
91 DEF_GM(return new ImageSourceGM("med", kMedium_SkFilterQuality);) | 91 DEF_GM(return new ImageSourceGM("med", kMedium_SkFilterQuality);) |
92 DEF_GM(return new ImageSourceGM("high", kHigh_SkFilterQuality);) | 92 DEF_GM(return new ImageSourceGM("high", kHigh_SkFilterQuality);) |
93 } | 93 } |
OLD | NEW |