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 "gm.h" | 8 #include "gm.h" |
9 #include "SkMatrixImageFilter.h" | 9 #include "SkMatrixImageFilter.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
11 | 11 |
12 #define WIDTH 640 | 12 #define WIDTH 640 |
13 #define HEIGHT 480 | 13 #define HEIGHT 480 |
14 | 14 |
15 #define RESIZE_FACTOR SkIntToScalar(2) | 15 #define RESIZE_FACTOR SkIntToScalar(2) |
16 | 16 |
17 namespace skiagm { | 17 namespace skiagm { |
18 | 18 |
19 class ImageResizeTiledGM : public GM { | 19 class ImageResizeTiledGM : public GM { |
20 public: | 20 public: |
21 ImageResizeTiledGM() { | 21 ImageResizeTiledGM() { |
22 } | 22 } |
23 | 23 |
24 protected: | 24 protected: |
25 virtual uint32_t onGetFlags() const SK_OVERRIDE { return kNoBBH_Flag; } | 25 uint32_t onGetFlags() const SK_OVERRIDE { return kNoBBH_Flag; } |
26 | 26 |
27 virtual SkString onShortName() SK_OVERRIDE { | 27 SkString onShortName() SK_OVERRIDE { |
28 return SkString("imageresizetiled"); | 28 return SkString("imageresizetiled"); |
29 } | 29 } |
30 | 30 |
31 virtual SkISize onISize() SK_OVERRIDE { | 31 SkISize onISize() SK_OVERRIDE { |
32 return SkISize::Make(WIDTH, HEIGHT); | 32 return SkISize::Make(WIDTH, HEIGHT); |
33 } | 33 } |
34 | 34 |
35 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 35 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
36 SkPaint paint; | 36 SkPaint paint; |
37 SkMatrix matrix; | 37 SkMatrix matrix; |
38 matrix.setScale(RESIZE_FACTOR, RESIZE_FACTOR); | 38 matrix.setScale(RESIZE_FACTOR, RESIZE_FACTOR); |
39 SkAutoTUnref<SkImageFilter> imageFilter( | 39 SkAutoTUnref<SkImageFilter> imageFilter( |
40 SkMatrixImageFilter::Create(matrix, SkPaint::kNone_FilterLevel)); | 40 SkMatrixImageFilter::Create(matrix, SkPaint::kNone_FilterLevel)); |
41 paint.setImageFilter(imageFilter.get()); | 41 paint.setImageFilter(imageFilter.get()); |
42 const SkScalar tile_size = SkIntToScalar(100); | 42 const SkScalar tile_size = SkIntToScalar(100); |
43 SkRect bounds; | 43 SkRect bounds; |
44 canvas->getClipBounds(&bounds); | 44 canvas->getClipBounds(&bounds); |
45 for (SkScalar y = 0; y < HEIGHT; y += tile_size) { | 45 for (SkScalar y = 0; y < HEIGHT; y += tile_size) { |
(...skipping 27 matching lines...) Expand all Loading... |
73 | 73 |
74 private: | 74 private: |
75 typedef GM INHERITED; | 75 typedef GM INHERITED; |
76 }; | 76 }; |
77 | 77 |
78 ////////////////////////////////////////////////////////////////////////////// | 78 ////////////////////////////////////////////////////////////////////////////// |
79 | 79 |
80 DEF_GM(return new ImageResizeTiledGM(); ) | 80 DEF_GM(return new ImageResizeTiledGM(); ) |
81 | 81 |
82 } | 82 } |
OLD | NEW |