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 "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 // Draw only the center of the small bitmap | 85 // Draw only the center of the small bitmap |
86 void drawCase1(SkCanvas* canvas, int transX, int transY, | 86 void drawCase1(SkCanvas* canvas, int transX, int transY, |
87 SkCanvas::DrawBitmapRectFlags flags, bool filter) { | 87 SkCanvas::DrawBitmapRectFlags flags, bool filter) { |
88 SkRect src = SkRect::MakeXYWH(1, 1, | 88 SkRect src = SkRect::MakeXYWH(1, 1, |
89 kSmallTextureSize-2, | 89 kSmallTextureSize-2, |
90 kSmallTextureSize-2); | 90 kSmallTextureSize-2); |
91 SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToSc
alar(kBlockSize)); | 91 SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToSc
alar(kBlockSize)); |
92 | 92 |
93 SkPaint paint; | 93 SkPaint paint; |
94 paint.setFilterBitmap(filter); | 94 paint.setFilterLevel(filter ? SkPaint::kLow_FilterLevel : SkPaint::kNone
_FilterLevel); |
95 | 95 |
96 canvas->save(); | 96 canvas->save(); |
97 canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY)); | 97 canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY)); |
98 canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint, flags); | 98 canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint, flags); |
99 canvas->restore(); | 99 canvas->restore(); |
100 } | 100 } |
101 | 101 |
102 // Draw almost all of the large bitmap | 102 // Draw almost all of the large bitmap |
103 void drawCase2(SkCanvas* canvas, int transX, int transY, | 103 void drawCase2(SkCanvas* canvas, int transX, int transY, |
104 SkCanvas::DrawBitmapRectFlags flags, bool filter) { | 104 SkCanvas::DrawBitmapRectFlags flags, bool filter) { |
105 SkRect src = SkRect::MakeXYWH(1, 1, | 105 SkRect src = SkRect::MakeXYWH(1, 1, |
106 SkIntToScalar(fBitmapBig.width()-2), | 106 SkIntToScalar(fBitmapBig.width()-2), |
107 SkIntToScalar(fBitmapBig.height()-2)); | 107 SkIntToScalar(fBitmapBig.height()-2)); |
108 SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToSc
alar(kBlockSize)); | 108 SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToSc
alar(kBlockSize)); |
109 | 109 |
110 SkPaint paint; | 110 SkPaint paint; |
111 paint.setFilterBitmap(filter); | 111 paint.setFilterLevel(filter ? SkPaint::kLow_FilterLevel : SkPaint::kNone
_FilterLevel); |
112 | 112 |
113 canvas->save(); | 113 canvas->save(); |
114 canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY)); | 114 canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY)); |
115 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint, flags); | 115 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint, flags); |
116 canvas->restore(); | 116 canvas->restore(); |
117 } | 117 } |
118 | 118 |
119 // Draw ~1/4 of the large bitmap | 119 // Draw ~1/4 of the large bitmap |
120 void drawCase3(SkCanvas* canvas, int transX, int transY, | 120 void drawCase3(SkCanvas* canvas, int transX, int transY, |
121 SkCanvas::DrawBitmapRectFlags flags, bool filter) { | 121 SkCanvas::DrawBitmapRectFlags flags, bool filter) { |
122 SkRect src = SkRect::MakeXYWH(1, 1, | 122 SkRect src = SkRect::MakeXYWH(1, 1, |
123 SkIntToScalar(fBitmapBig.width()/2-1), | 123 SkIntToScalar(fBitmapBig.width()/2-1), |
124 SkIntToScalar(fBitmapBig.height()/2-1)); | 124 SkIntToScalar(fBitmapBig.height()/2-1)); |
125 SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToSc
alar(kBlockSize)); | 125 SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToSc
alar(kBlockSize)); |
126 | 126 |
127 SkPaint paint; | 127 SkPaint paint; |
128 paint.setFilterBitmap(filter); | 128 paint.setFilterLevel(filter ? SkPaint::kLow_FilterLevel : SkPaint::kNone
_FilterLevel); |
129 | 129 |
130 canvas->save(); | 130 canvas->save(); |
131 canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY)); | 131 canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY)); |
132 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint, flags); | 132 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint, flags); |
133 canvas->restore(); | 133 canvas->restore(); |
134 } | 134 } |
135 | 135 |
136 // Draw the center of the small bitmap with a mask filter | 136 // Draw the center of the small bitmap with a mask filter |
137 void drawCase4(SkCanvas* canvas, int transX, int transY, | 137 void drawCase4(SkCanvas* canvas, int transX, int transY, |
138 SkCanvas::DrawBitmapRectFlags flags, bool filter) { | 138 SkCanvas::DrawBitmapRectFlags flags, bool filter) { |
139 SkRect src = SkRect::MakeXYWH(1, 1, | 139 SkRect src = SkRect::MakeXYWH(1, 1, |
140 kSmallTextureSize-2, | 140 kSmallTextureSize-2, |
141 kSmallTextureSize-2); | 141 kSmallTextureSize-2); |
142 SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToSc
alar(kBlockSize)); | 142 SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToSc
alar(kBlockSize)); |
143 | 143 |
144 SkPaint paint; | 144 SkPaint paint; |
145 paint.setFilterBitmap(filter); | 145 paint.setFilterLevel(filter ? SkPaint::kLow_FilterLevel : SkPaint::kNone
_FilterLevel); |
146 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_Bl
urStyle, | 146 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_Bl
urStyle, |
147 SkBlurMask::ConvertRadiusToSigma(SkIntT
oScalar(3))); | 147 SkBlurMask::ConvertRadiusToSigma(SkIntT
oScalar(3))); |
148 paint.setMaskFilter(mf)->unref(); | 148 paint.setMaskFilter(mf)->unref(); |
149 | 149 |
150 canvas->save(); | 150 canvas->save(); |
151 canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY)); | 151 canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY)); |
152 canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint, flags); | 152 canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint, flags); |
153 canvas->restore(); | 153 canvas->restore(); |
154 } | 154 } |
155 | 155 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 static const int kSmallTextureSize = 4; | 218 static const int kSmallTextureSize = 4; |
219 static const int kMaxTextureSize = 32; | 219 static const int kMaxTextureSize = 32; |
220 | 220 |
221 SkBitmap fBitmapSmall; | 221 SkBitmap fBitmapSmall; |
222 SkBitmap fBitmapBig; | 222 SkBitmap fBitmapBig; |
223 | 223 |
224 typedef GM INHERITED; | 224 typedef GM INHERITED; |
225 }; | 225 }; |
226 | 226 |
227 DEF_GM( return new BleedGM(); ) | 227 DEF_GM( return new BleedGM(); ) |
OLD | NEW |