| 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 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
| 10 #include "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 const SkScalar bottomUnstretched = SkTMax(LL.fY, LR.fY) + SkIntToScalar(2 *
margin.fY); | 314 const SkScalar bottomUnstretched = SkTMax(LL.fY, LR.fY) + SkIntToScalar(2 *
margin.fY); |
| 315 | 315 |
| 316 const SkScalar totalSmallHeight = topUnstretched + bottomUnstretched + stret
chSize; | 316 const SkScalar totalSmallHeight = topUnstretched + bottomUnstretched + stret
chSize; |
| 317 if (totalSmallHeight >= rrect.rect().height()) { | 317 if (totalSmallHeight >= rrect.rect().height()) { |
| 318 // There is no valid piece to stretch. | 318 // There is no valid piece to stretch. |
| 319 return kUnimplemented_FilterReturn; | 319 return kUnimplemented_FilterReturn; |
| 320 } | 320 } |
| 321 | 321 |
| 322 SkRect smallR = SkRect::MakeWH(totalSmallWidth, totalSmallHeight); | 322 SkRect smallR = SkRect::MakeWH(totalSmallWidth, totalSmallHeight); |
| 323 | 323 |
| 324 if (smallR.width() * smallR.height() > clipBounds.width() * clipBounds.heigh
t()) { |
| 325 // This path creates the nine-patch and then draws it. The fallback |
| 326 // path draws the clipped path, blurs it then blits it. If we are |
| 327 // going to touch more pixels using this path we should probably just |
| 328 // fall back. |
| 329 return kUnimplemented_FilterReturn; |
| 330 } |
| 331 |
| 324 SkRRect smallRR; | 332 SkRRect smallRR; |
| 325 SkVector radii[4]; | 333 SkVector radii[4]; |
| 326 radii[SkRRect::kUpperLeft_Corner] = UL; | 334 radii[SkRRect::kUpperLeft_Corner] = UL; |
| 327 radii[SkRRect::kUpperRight_Corner] = UR; | 335 radii[SkRRect::kUpperRight_Corner] = UR; |
| 328 radii[SkRRect::kLowerRight_Corner] = LR; | 336 radii[SkRRect::kLowerRight_Corner] = LR; |
| 329 radii[SkRRect::kLowerLeft_Corner] = LL; | 337 radii[SkRRect::kLowerLeft_Corner] = LL; |
| 330 smallRR.setRectRadii(smallR, radii); | 338 smallRR.setRectRadii(smallR, radii); |
| 331 | 339 |
| 332 if (!draw_rrect_into_mask(smallRR, &srcM)) { | 340 if (!draw_rrect_into_mask(smallRR, &srcM)) { |
| 333 return kFalse_FilterReturn; | 341 return kFalse_FilterReturn; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 smallR[0].set(rects[0].left(), rects[0].top(), rects[0].right() - dx, rects[
0].bottom() - dy); | 452 smallR[0].set(rects[0].left(), rects[0].top(), rects[0].right() - dx, rects[
0].bottom() - dy); |
| 445 if (smallR[0].width() < 2 || smallR[0].height() < 2) { | 453 if (smallR[0].width() < 2 || smallR[0].height() < 2) { |
| 446 return kUnimplemented_FilterReturn; | 454 return kUnimplemented_FilterReturn; |
| 447 } | 455 } |
| 448 if (2 == count) { | 456 if (2 == count) { |
| 449 smallR[1].set(rects[1].left(), rects[1].top(), | 457 smallR[1].set(rects[1].left(), rects[1].top(), |
| 450 rects[1].right() - dx, rects[1].bottom() - dy); | 458 rects[1].right() - dx, rects[1].bottom() - dy); |
| 451 SkASSERT(!smallR[1].isEmpty()); | 459 SkASSERT(!smallR[1].isEmpty()); |
| 452 } | 460 } |
| 453 | 461 |
| 462 #if 0 |
| 463 // Both filterRectsToNine and filterRRectToNine share this problem |
| 464 // (potentially trying to allocate too large a nine-patch mask). |
| 465 // Chromium is currently seeing the filterRRectToNine crash but we have |
| 466 // not yet seen the filterRectsToNine corrolate. Presumably we will have |
| 467 // to enable this code some day but more testing is required (For example, |
| 468 // since the analytic case is faster then the normal blur should we |
| 469 // actually have a constant multiplier in the following inequality). |
| 470 if (smallR[0].width() * smallR[0].height() > |
| 471 clipBounds.width() * clipBounds.height()) { |
| 472 // This path creates the nine-patch and then draws it. The fallback |
| 473 // path draws the clipped path, blurs it then blits it. If we are |
| 474 // going to touch more pixels using this path we should probably just |
| 475 // fall back. |
| 476 return kUnimplemented_FilterReturn; |
| 477 } |
| 478 #endif |
| 479 |
| 454 if (count > 1 || !c_analyticBlurNinepatch) { | 480 if (count > 1 || !c_analyticBlurNinepatch) { |
| 455 if (!draw_rects_into_mask(smallR, count, &srcM)) { | 481 if (!draw_rects_into_mask(smallR, count, &srcM)) { |
| 456 return kFalse_FilterReturn; | 482 return kFalse_FilterReturn; |
| 457 } | 483 } |
| 458 | 484 |
| 459 SkAutoMaskFreeImage amf(srcM.fImage); | 485 SkAutoMaskFreeImage amf(srcM.fImage); |
| 460 | 486 |
| 461 if (!this->filterMask(&patch->fMask, srcM, matrix, &margin)) { | 487 if (!this->filterMask(&patch->fMask, srcM, matrix, &margin)) { |
| 462 return kFalse_FilterReturn; | 488 return kFalse_FilterReturn; |
| 463 } | 489 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } else { | 641 } else { |
| 616 str->append("None"); | 642 str->append("None"); |
| 617 } | 643 } |
| 618 str->append("))"); | 644 str->append("))"); |
| 619 } | 645 } |
| 620 #endif | 646 #endif |
| 621 | 647 |
| 622 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 648 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
| 623 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 649 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
| 624 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 650 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |