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 "SkTileImageFilter.h" | 9 #include "SkTileImageFilter.h" |
10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 virtual SkISize onISize() { | 66 virtual SkISize onISize() { |
67 return make_isize(WIDTH, HEIGHT); | 67 return make_isize(WIDTH, HEIGHT); |
68 } | 68 } |
69 | 69 |
70 void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPai
nt& paint, | 70 void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPai
nt& paint, |
71 SkScalar x, SkScalar y) { | 71 SkScalar x, SkScalar y) { |
72 canvas->save(); | 72 canvas->save(); |
73 canvas->translate(x, y); | 73 canvas->clipRect(SkRect::MakeXYWH(x, y, |
74 canvas->clipRect(SkRect::MakeXYWH(0, 0, | |
75 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()))); | 74 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()))); |
76 canvas->drawBitmap(bitmap, 0, 0, &paint); | 75 canvas->drawBitmap(bitmap, x, y, &paint); |
77 canvas->restore(); | 76 canvas->restore(); |
78 } | 77 } |
79 | 78 |
80 virtual void onDraw(SkCanvas* canvas) { | 79 virtual void onDraw(SkCanvas* canvas) { |
81 if (!fInitialized) { | 80 if (!fInitialized) { |
82 make_bitmap(); | 81 make_bitmap(); |
83 make_checkerboard(); | 82 make_checkerboard(); |
84 fInitialized = true; | 83 fInitialized = true; |
85 } | 84 } |
86 canvas->clear(0x00000000); | 85 canvas->clear(0x00000000); |
(...skipping 27 matching lines...) Expand all Loading... |
114 SkBitmap fBitmap, fCheckerboard; | 113 SkBitmap fBitmap, fCheckerboard; |
115 bool fInitialized; | 114 bool fInitialized; |
116 }; | 115 }; |
117 | 116 |
118 ////////////////////////////////////////////////////////////////////////////// | 117 ////////////////////////////////////////////////////////////////////////////// |
119 | 118 |
120 static GM* MyFactory(void*) { return new TileImageFilterGM; } | 119 static GM* MyFactory(void*) { return new TileImageFilterGM; } |
121 static GMRegistry reg(MyFactory); | 120 static GMRegistry reg(MyFactory); |
122 | 121 |
123 } | 122 } |
OLD | NEW |