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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "SkBitmapSource.h" | 9 #include "SkBitmapSource.h" |
10 #include "SkColorFilterImageFilter.h" | 10 #include "SkColorFilterImageFilter.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0, | 92 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0, |
93 0, SK_Scalar1, 0, 0, 0, | 93 0, SK_Scalar1, 0, 0, 0, |
94 0, 0, SK_Scalar1, 0, 0, | 94 0, 0, SK_Scalar1, 0, 0, |
95 0, 0, 0, SK_Scalar1, 0 }; | 95 0, 0, 0, SK_Scalar1, 0 }; |
96 | 96 |
97 SkRect srcRect = SkRect::MakeWH(SkIntToScalar(fBitmap.width()), | 97 SkRect srcRect = SkRect::MakeWH(SkIntToScalar(fBitmap.width()), |
98 SkIntToScalar(fBitmap.height())); | 98 SkIntToScalar(fBitmap.height())); |
99 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(fBitmap.width() * 2), | 99 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(fBitmap.width() * 2), |
100 SkIntToScalar(fBitmap.height() * 2)); | 100 SkIntToScalar(fBitmap.height() * 2)); |
101 SkAutoTUnref<SkImageFilter> tile(SkTileImageFilter::Create(srcRect, dstR
ect, NULL)); | 101 SkAutoTUnref<SkImageFilter> tile(SkTileImageFilter::Create(srcRect, dstR
ect, nullptr)); |
102 SkAutoTUnref<SkColorFilter> cf(SkColorMatrixFilter::Create(matrix)); | 102 SkAutoTUnref<SkColorFilter> cf(SkColorMatrixFilter::Create(matrix)); |
103 | 103 |
104 SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf, ti
le.get())); | 104 SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf, ti
le.get())); |
105 SkPaint paint; | 105 SkPaint paint; |
106 paint.setImageFilter(cfif); | 106 paint.setImageFilter(cfif); |
107 canvas->save(); | 107 canvas->save(); |
108 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); | 108 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |
109 canvas->clipRect(dstRect); | 109 canvas->clipRect(dstRect); |
110 canvas->saveLayer(&dstRect, &paint); | 110 canvas->saveLayer(&dstRect, &paint); |
111 canvas->drawBitmap(fBitmap, 0, 0); | 111 canvas->drawBitmap(fBitmap, 0, 0); |
112 canvas->restore(); | 112 canvas->restore(); |
113 canvas->restore(); | 113 canvas->restore(); |
114 } | 114 } |
115 private: | 115 private: |
116 SkBitmap fBitmap; | 116 SkBitmap fBitmap; |
117 SkBitmap fCheckerboard; | 117 SkBitmap fCheckerboard; |
118 | 118 |
119 typedef GM INHERITED; | 119 typedef GM INHERITED; |
120 }; | 120 }; |
121 | 121 |
122 ////////////////////////////////////////////////////////////////////////////// | 122 ////////////////////////////////////////////////////////////////////////////// |
123 | 123 |
124 DEF_GM(return new TileImageFilterGM;) | 124 DEF_GM(return new TileImageFilterGM;) |
125 } | 125 } |
OLD | NEW |