Chromium Code Reviews| 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 { | |
|
robertphillips
2013/10/31 00:24:58
Could you expand on what makes this case sneaky?
scroggo
2013/11/01 21:45:46
Done.
| |
| 211 // Only handle the sneaky case: | |
| 212 NinePatch patch; | |
| 213 patch.fMask.fImage = NULL; | |
| 214 if (kTrue_FilterReturn != this->filterRRectToNine(devRRect, matrix, | |
| 215 clip.getBounds(), | |
| 216 &patch)) { | |
| 217 return false; | |
| 218 } | |
| 219 draw_nine(patch.fMask, patch.fOuterRect, patch.fCenter, true, clip, | |
| 220 bounder, blitter); | |
| 221 SkMask::FreeImage(patch.fMask.fImage); | |
| 222 return true; | |
| 223 } | |
| 224 | |
| 207 bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix, | 225 bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix, |
| 208 const SkRasterClip& clip, SkBounder* bounder, | 226 const SkRasterClip& clip, SkBounder* bounder, |
| 209 SkBlitter* blitter, SkPaint::Style style) const { | 227 SkBlitter* blitter, SkPaint::Style style) const { |
| 210 SkRect rects[2]; | 228 SkRect rects[2]; |
| 211 int rectCount = 0; | 229 int rectCount = 0; |
| 212 if (SkPaint::kFill_Style == style) { | 230 if (SkPaint::kFill_Style == style) { |
| 213 rectCount = countNestedRects(devPath, rects); | 231 rectCount = countNestedRects(devPath, rects); |
| 214 } | 232 } |
| 215 if (rectCount > 0) { | 233 if (rectCount > 0) { |
| 216 NinePatch patch; | 234 NinePatch patch; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 do { | 278 do { |
| 261 blitter->blitMask(dstM, cr); | 279 blitter->blitMask(dstM, cr); |
| 262 clipper.next(); | 280 clipper.next(); |
| 263 } while (!clipper.done()); | 281 } while (!clipper.done()); |
| 264 } | 282 } |
| 265 | 283 |
| 266 return true; | 284 return true; |
| 267 } | 285 } |
| 268 | 286 |
| 269 SkMaskFilter::FilterReturn | 287 SkMaskFilter::FilterReturn |
| 288 SkMaskFilter::filterRRectToNine(const SkRRect&, const SkMatrix&, | |
| 289 const SkIRect& clipBounds, NinePatch*) const { | |
| 290 return kUnimplemented_FilterReturn; | |
| 291 } | |
| 292 | |
| 293 SkMaskFilter::FilterReturn | |
| 270 SkMaskFilter::filterRectsToNine(const SkRect[], int count, const SkMatrix&, | 294 SkMaskFilter::filterRectsToNine(const SkRect[], int count, const SkMatrix&, |
| 271 const SkIRect& clipBounds, NinePatch*) const { | 295 const SkIRect& clipBounds, NinePatch*) const { |
| 272 return kUnimplemented_FilterReturn; | 296 return kUnimplemented_FilterReturn; |
| 273 } | 297 } |
| 274 | 298 |
| 275 #if SK_SUPPORT_GPU | 299 #if SK_SUPPORT_GPU |
| 276 bool SkMaskFilter::asNewEffect(GrEffectRef** effect, GrTexture*) const { | 300 bool SkMaskFilter::asNewEffect(GrEffectRef** effect, GrTexture*) const { |
| 277 return false; | 301 return false; |
| 278 } | 302 } |
| 279 | 303 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 srcM.fRowBytes = 0; | 371 srcM.fRowBytes = 0; |
| 348 srcM.fFormat = SkMask::kA8_Format; | 372 srcM.fFormat = SkMask::kA8_Format; |
| 349 | 373 |
| 350 SkIPoint margin; // ignored | 374 SkIPoint margin; // ignored |
| 351 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) { | 375 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) { |
| 352 dst->set(dstM.fBounds); | 376 dst->set(dstM.fBounds); |
| 353 } else { | 377 } else { |
| 354 dst->set(srcM.fBounds); | 378 dst->set(srcM.fBounds); |
| 355 } | 379 } |
| 356 } | 380 } |
| OLD | NEW |