OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkMaskFilter.h" | 10 #include "SkMaskFilter.h" |
11 #include "SkBlitter.h" | 11 #include "SkBlitter.h" |
12 #include "SkBounder.h" | 12 #include "SkBounder.h" |
13 #include "SkDraw.h" | 13 #include "SkDraw.h" |
14 #include "SkRasterClip.h" | 14 #include "SkRasterClip.h" |
| 15 #include "SkRRect.h" |
15 #include "SkTypes.h" | 16 #include "SkTypes.h" |
16 | 17 |
17 #if SK_SUPPORT_GPU | 18 #if SK_SUPPORT_GPU |
18 #include "GrTexture.h" | 19 #include "GrTexture.h" |
19 #include "SkGr.h" | 20 #include "SkGr.h" |
20 #include "SkGrPixelRef.h" | 21 #include "SkGrPixelRef.h" |
21 #endif | 22 #endif |
22 | 23 |
23 SK_DEFINE_INST_COUNT(SkMaskFilter) | 24 SK_DEFINE_INST_COUNT(SkMaskFilter) |
24 | 25 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 198 } |
198 } | 199 } |
199 | 200 |
200 static int countNestedRects(const SkPath& path, SkRect rects[2]) { | 201 static int countNestedRects(const SkPath& path, SkRect rects[2]) { |
201 if (path.isNestedRects(rects)) { | 202 if (path.isNestedRects(rects)) { |
202 return 2; | 203 return 2; |
203 } | 204 } |
204 return path.isRect(&rects[0]); | 205 return path.isRect(&rects[0]); |
205 } | 206 } |
206 | 207 |
| 208 bool SkMaskFilter::filterRRect(const SkRRect& devRRect, const SkMatrix& matrix, |
| 209 const SkRasterClip& clip, SkBounder* bounder, |
| 210 SkBlitter* blitter, SkPaint::Style style) const { |
| 211 // Attempt to speed up drawing by creating a nine patch. If a nine patch |
| 212 // cannot be used, return false to allow our caller to recover and perform |
| 213 // the drawing another way. |
| 214 NinePatch patch; |
| 215 patch.fMask.fImage = NULL; |
| 216 if (kTrue_FilterReturn != this->filterRRectToNine(devRRect, matrix, |
| 217 clip.getBounds(), |
| 218 &patch)) { |
| 219 SkASSERT(NULL == patch.fMask.fImage); |
| 220 return false; |
| 221 } |
| 222 draw_nine(patch.fMask, patch.fOuterRect, patch.fCenter, true, clip, |
| 223 bounder, blitter); |
| 224 SkMask::FreeImage(patch.fMask.fImage); |
| 225 return true; |
| 226 } |
| 227 |
207 bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix, | 228 bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix, |
208 const SkRasterClip& clip, SkBounder* bounder, | 229 const SkRasterClip& clip, SkBounder* bounder, |
209 SkBlitter* blitter, SkPaint::Style style) const { | 230 SkBlitter* blitter, SkPaint::Style style) const { |
210 SkRect rects[2]; | 231 SkRect rects[2]; |
211 int rectCount = 0; | 232 int rectCount = 0; |
212 if (SkPaint::kFill_Style == style) { | 233 if (SkPaint::kFill_Style == style) { |
213 rectCount = countNestedRects(devPath, rects); | 234 rectCount = countNestedRects(devPath, rects); |
214 } | 235 } |
215 if (rectCount > 0) { | 236 if (rectCount > 0) { |
216 NinePatch patch; | 237 NinePatch patch; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 do { | 281 do { |
261 blitter->blitMask(dstM, cr); | 282 blitter->blitMask(dstM, cr); |
262 clipper.next(); | 283 clipper.next(); |
263 } while (!clipper.done()); | 284 } while (!clipper.done()); |
264 } | 285 } |
265 | 286 |
266 return true; | 287 return true; |
267 } | 288 } |
268 | 289 |
269 SkMaskFilter::FilterReturn | 290 SkMaskFilter::FilterReturn |
| 291 SkMaskFilter::filterRRectToNine(const SkRRect&, const SkMatrix&, |
| 292 const SkIRect& clipBounds, NinePatch*) const { |
| 293 return kUnimplemented_FilterReturn; |
| 294 } |
| 295 |
| 296 SkMaskFilter::FilterReturn |
270 SkMaskFilter::filterRectsToNine(const SkRect[], int count, const SkMatrix&, | 297 SkMaskFilter::filterRectsToNine(const SkRect[], int count, const SkMatrix&, |
271 const SkIRect& clipBounds, NinePatch*) const { | 298 const SkIRect& clipBounds, NinePatch*) const { |
272 return kUnimplemented_FilterReturn; | 299 return kUnimplemented_FilterReturn; |
273 } | 300 } |
274 | 301 |
275 #if SK_SUPPORT_GPU | 302 #if SK_SUPPORT_GPU |
276 bool SkMaskFilter::asNewEffect(GrEffectRef** effect, GrTexture*) const { | 303 bool SkMaskFilter::asNewEffect(GrEffectRef** effect, GrTexture*) const { |
277 return false; | 304 return false; |
278 } | 305 } |
279 | 306 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 srcM.fRowBytes = 0; | 374 srcM.fRowBytes = 0; |
348 srcM.fFormat = SkMask::kA8_Format; | 375 srcM.fFormat = SkMask::kA8_Format; |
349 | 376 |
350 SkIPoint margin; // ignored | 377 SkIPoint margin; // ignored |
351 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) { | 378 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) { |
352 dst->set(dstM.fBounds); | 379 dst->set(dstM.fBounds); |
353 } else { | 380 } else { |
354 dst->set(srcM.fBounds); | 381 dst->set(srcM.fBounds); |
355 } | 382 } |
356 } | 383 } |
OLD | NEW |