| 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 "SkOffsetImageFilter.h" | 9 #include "SkOffsetImageFilter.h" | 
| 10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 85         canvas->clear(0x00000000); | 85         canvas->clear(0x00000000); | 
| 86         SkPaint paint; | 86         SkPaint paint; | 
| 87 | 87 | 
| 88         int x = 0, y = 0; | 88         int x = 0, y = 0; | 
| 89         for (size_t i = 0; i < 4; i++) { | 89         for (size_t i = 0; i < 4; i++) { | 
| 90             SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap; | 90             SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap; | 
| 91             SkIRect cropRect = SkIRect::MakeXYWH(x + i * 12, | 91             SkIRect cropRect = SkIRect::MakeXYWH(x + i * 12, | 
| 92                                                  y + i * 8, | 92                                                  y + i * 8, | 
| 93                                                  bitmap->width() - i * 8, | 93                                                  bitmap->width() - i * 8, | 
| 94                                                  bitmap->height() - i * 12); | 94                                                  bitmap->height() - i * 12); | 
|  | 95 #ifdef SK_CROP_RECT_IS_INT | 
|  | 96             SkIRect rect = cropRect; | 
|  | 97 #else | 
|  | 98             SkImageFilter::CropRect rect(SkRect::Make(cropRect)); | 
|  | 99 #endif | 
| 95             SkAutoTUnref<SkImageFilter> tileInput(SkNEW_ARGS(SkBitmapSource, (*b
     itmap))); | 100             SkAutoTUnref<SkImageFilter> tileInput(SkNEW_ARGS(SkBitmapSource, (*b
     itmap))); | 
| 96             SkScalar dx = SkIntToScalar(i*5); | 101             SkScalar dx = SkIntToScalar(i*5); | 
| 97             SkScalar dy = SkIntToScalar(i*10); | 102             SkScalar dy = SkIntToScalar(i*10); | 
| 98             SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS( | 103             SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS( | 
| 99                 SkOffsetImageFilter, (dx, dy, tileInput, &cropRect))); | 104                 SkOffsetImageFilter, (dx, dy, tileInput, &rect))); | 
| 100             paint.setImageFilter(filter); | 105             paint.setImageFilter(filter); | 
| 101             drawClippedBitmap(canvas, *bitmap, paint, SkIntToScalar(x), SkIntToS
     calar(y)); | 106             drawClippedBitmap(canvas, *bitmap, paint, SkIntToScalar(x), SkIntToS
     calar(y)); | 
| 102             x += bitmap->width() + MARGIN; | 107             x += bitmap->width() + MARGIN; | 
| 103             if (x + bitmap->width() > WIDTH) { | 108             if (x + bitmap->width() > WIDTH) { | 
| 104                 x = 0; | 109                 x = 0; | 
| 105                 y += bitmap->height() + MARGIN; | 110                 y += bitmap->height() + MARGIN; | 
| 106             } | 111             } | 
| 107         } | 112         } | 
| 108     } | 113     } | 
| 109 private: | 114 private: | 
| 110     typedef GM INHERITED; | 115     typedef GM INHERITED; | 
| 111     SkBitmap fBitmap, fCheckerboard; | 116     SkBitmap fBitmap, fCheckerboard; | 
| 112     bool fInitialized; | 117     bool fInitialized; | 
| 113 }; | 118 }; | 
| 114 | 119 | 
| 115 ////////////////////////////////////////////////////////////////////////////// | 120 ////////////////////////////////////////////////////////////////////////////// | 
| 116 | 121 | 
| 117 static GM* MyFactory(void*) { return new OffsetImageFilterGM; } | 122 static GM* MyFactory(void*) { return new OffsetImageFilterGM; } | 
| 118 static GMRegistry reg(MyFactory); | 123 static GMRegistry reg(MyFactory); | 
| 119 | 124 | 
| 120 } | 125 } | 
| OLD | NEW | 
|---|