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 #include <list> | |
|
Stephen White
2014/06/09 18:03:58
I'm not sure what the Skia project's official stan
| |
| 10 | |
| 9 #include "SkBlurMaskFilter.h" | 11 #include "SkBlurMaskFilter.h" |
| 10 #include "SkBlurMask.h" | 12 #include "SkBlurMask.h" |
| 11 #include "SkGpuBlurUtils.h" | 13 #include "SkGpuBlurUtils.h" |
| 12 #include "SkReadBuffer.h" | 14 #include "SkReadBuffer.h" |
| 13 #include "SkWriteBuffer.h" | 15 #include "SkWriteBuffer.h" |
| 14 #include "SkMaskFilter.h" | 16 #include "SkMaskFilter.h" |
| 15 #include "SkRRect.h" | 17 #include "SkRRect.h" |
| 16 #include "SkRTConf.h" | 18 #include "SkRTConf.h" |
| 19 #include "SkScaledImageCache.h" | |
| 17 #include "SkStringUtils.h" | 20 #include "SkStringUtils.h" |
| 18 #include "SkStrokeRec.h" | 21 #include "SkStrokeRec.h" |
| 19 | 22 |
| 20 #if SK_SUPPORT_GPU | 23 #if SK_SUPPORT_GPU |
| 21 #include "GrContext.h" | 24 #include "GrContext.h" |
| 22 #include "GrTexture.h" | 25 #include "GrTexture.h" |
| 23 #include "GrEffect.h" | 26 #include "GrEffect.h" |
| 24 #include "gl/GrGLEffect.h" | 27 #include "gl/GrGLEffect.h" |
| 25 #include "effects/GrSimpleTextureEffect.h" | 28 #include "effects/GrSimpleTextureEffect.h" |
| 26 #include "GrTBackendEffectFactory.h" | 29 #include "GrTBackendEffectFactory.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 virtual bool filterMaskGPU(GrTexture* src, | 61 virtual bool filterMaskGPU(GrTexture* src, |
| 59 const SkMatrix& ctm, | 62 const SkMatrix& ctm, |
| 60 const SkRect& maskRect, | 63 const SkRect& maskRect, |
| 61 GrTexture** result, | 64 GrTexture** result, |
| 62 bool canOverwriteSrc) const SK_OVERRIDE; | 65 bool canOverwriteSrc) const SK_OVERRIDE; |
| 63 #endif | 66 #endif |
| 64 | 67 |
| 65 virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE; | 68 virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE; |
| 66 virtual bool asABlur(BlurRec*) const SK_OVERRIDE; | 69 virtual bool asABlur(BlurRec*) const SK_OVERRIDE; |
| 67 | 70 |
| 71 class BlurMaskRecord { | |
| 72 public: | |
| 73 BlurMaskRecord(): fSigma(0), | |
| 74 fRectCount(0), | |
| 75 fRects(NULL), | |
| 76 fMask(NULL) {} | |
| 77 | |
| 78 BlurMaskRecord(SkScalar sigma, unsigned rectCount, SkRect** rects, SkDis cardableMemoryMask* mask) | |
| 79 : fSigma(sigma), | |
| 80 fRectCount(rectCount), | |
| 81 fRects(rects), | |
| 82 fMask(mask) {} | |
| 83 | |
| 84 ~BlurMaskRecord() { | |
| 85 if (fMask) { | |
| 86 delete fMask; | |
| 87 } | |
| 88 if (fRects) { | |
| 89 for(unsigned i = 0; i < fRectCount; i++) { | |
| 90 if (fRects[i]) | |
| 91 delete fRects[i]; | |
| 92 } | |
| 93 delete []fRects; | |
| 94 } | |
| 95 } | |
| 96 | |
| 97 SkScalar fSigma; | |
| 98 unsigned fRectCount; | |
| 99 SkRect** fRects; | |
| 100 SkDiscardableMemoryMask* fMask; | |
| 101 }; | |
| 102 | |
| 103 static bool getBlurMaskRecord(SkScalar sigma, | |
| 104 unsigned rectCount, | |
| 105 const SkRect rects[], | |
| 106 SkDiscardableMemoryMask** mask); | |
| 107 static bool addBlurMaskRecord(BlurMaskRecord* blurMaskRecord); | |
| 108 static void clearBlurMaskRecordList(); | |
| 109 | |
| 68 SK_TO_STRING_OVERRIDE() | 110 SK_TO_STRING_OVERRIDE() |
| 69 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl) | 111 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl) |
| 70 | 112 |
| 71 protected: | 113 protected: |
| 72 virtual FilterReturn filterRectsToNine(const SkRect[], int count, const SkMa trix&, | 114 virtual FilterReturn filterRectsToNine(const SkRect[], int count, const SkMa trix&, |
| 73 const SkIRect& clipBounds, | 115 const SkIRect& clipBounds, |
| 74 NinePatch*) const SK_OVERRIDE; | 116 NinePatch*) const SK_OVERRIDE; |
| 75 | 117 |
| 76 virtual FilterReturn filterRRectToNine(const SkRRect&, const SkMatrix&, | 118 virtual FilterReturn filterRRectToNine(const SkRRect&, const SkMatrix&, |
| 77 const SkIRect& clipBounds, | 119 const SkIRect& clipBounds, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 100 SkBlurMaskFilterImpl(SkReadBuffer&); | 142 SkBlurMaskFilterImpl(SkReadBuffer&); |
| 101 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 143 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 102 | 144 |
| 103 SkScalar computeXformedSigma(const SkMatrix& ctm) const { | 145 SkScalar computeXformedSigma(const SkMatrix& ctm) const { |
| 104 bool ignoreTransform = SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTr ansform_BlurFlag); | 146 bool ignoreTransform = SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTr ansform_BlurFlag); |
| 105 | 147 |
| 106 SkScalar xformedSigma = ignoreTransform ? fSigma : ctm.mapRadius(fSigma) ; | 148 SkScalar xformedSigma = ignoreTransform ? fSigma : ctm.mapRadius(fSigma) ; |
| 107 return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA); | 149 return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA); |
| 108 } | 150 } |
| 109 | 151 |
| 152 typedef std::list<BlurMaskRecord*> BlurMaskRecordList; | |
| 153 static BlurMaskRecordList fCachedBlurMaskRecordList; | |
| 154 | |
| 110 typedef SkMaskFilter INHERITED; | 155 typedef SkMaskFilter INHERITED; |
| 111 }; | 156 }; |
| 112 | 157 |
| 113 const SkScalar SkBlurMaskFilterImpl::kMAX_BLUR_SIGMA = SkIntToScalar(128); | 158 const SkScalar SkBlurMaskFilterImpl::kMAX_BLUR_SIGMA = SkIntToScalar(128); |
| 114 | 159 |
| 160 SkBlurMaskFilterImpl::BlurMaskRecordList SkBlurMaskFilterImpl::fCachedBlurMaskRe cordList; | |
| 161 SK_DECLARE_STATIC_MUTEX(gMutex); | |
| 162 | |
| 163 bool SkBlurMaskFilterImpl::getBlurMaskRecord(SkScalar sigma, | |
| 164 unsigned rectCount, | |
| 165 const SkRect rects[], | |
| 166 SkDiscardableMemoryMask** mask) { | |
| 167 SkAutoMutexAcquire am(gMutex); | |
| 168 if (!fCachedBlurMaskRecordList.empty()) { | |
| 169 for (BlurMaskRecordList::reverse_iterator it = fCachedBlurMaskRecordList .rbegin(); | |
| 170 it != fCachedBlurMaskRecordList.rend(); ++it) { | |
| 171 BlurMaskRecord* cachedBlurMaskRecord = *it; | |
| 172 if (cachedBlurMaskRecord->fSigma == sigma | |
| 173 && cachedBlurMaskRecord->fRectCount == rectCount) { | |
| 174 bool found = true; | |
| 175 SkRect* tempRects[2] = {NULL, NULL}; | |
| 176 for (unsigned i = 0; i < rectCount; i++) { | |
| 177 tempRects[i] = *(cachedBlurMaskRecord->fRects + i); | |
| 178 if (tempRects[i]->width() != rects[i].width() || | |
| 179 tempRects[i]->height() != rects[i].height()) { | |
| 180 found = false; | |
|
Stephen White
2014/06/09 18:03:58
Perhaps this inner loop could be in its own functi
| |
| 181 break; | |
| 182 } | |
| 183 } | |
| 184 if (found && rectCount == 2) { | |
| 185 if ((tempRects[0]->x() - rects[0].x()) != (tempRects[1]->x() - rects[1].x()) || | |
| 186 (tempRects[0]->y() - rects[0].y()) != (tempRects[1]->y() - rects[1].y())) | |
| 187 found = false; | |
|
Stephen White
2014/06/09 18:03:58
Same here.
| |
| 188 } | |
| 189 if (found) { | |
| 190 SkBitmap bitmap; | |
| 191 void* scaledCacheId = SkScaledImageCache::FindAndLock(cached BlurMaskRecord->fMask->fPixelGenerationID, | |
| 192 cachedBlurMaskRecord->fMask ->fMask.fBounds.width(), | |
| 193 cachedBlurMaskRecord->fMask ->fMask.fBounds.height(), | |
| 194 &bitmap); | |
| 195 if (scaledCacheId) { | |
| 196 SkAutoLockPixels autoLockPixels(bitmap); | |
| 197 if (bitmap.getPixels()) { | |
| 198 cachedBlurMaskRecord->fMask->fCacheId = scaledCacheI d; | |
| 199 *mask = cachedBlurMaskRecord->fMask; | |
| 200 return true; | |
| 201 } | |
| 202 } | |
| 203 fCachedBlurMaskRecordList.erase(--it.base()); | |
| 204 return false; | |
| 205 } | |
| 206 } | |
| 207 } | |
| 208 } | |
| 209 return false; | |
| 210 } | |
| 211 | |
| 212 bool SkBlurMaskFilterImpl::addBlurMaskRecord(BlurMaskRecord* blurMaskRecord) { | |
| 213 SkAutoMutexAcquire am(gMutex); | |
| 214 fCachedBlurMaskRecordList.push_back(blurMaskRecord); | |
| 215 return true; | |
| 216 } | |
| 217 | |
| 218 void SkBlurMaskFilterImpl::clearBlurMaskRecordList() { | |
| 219 SkAutoMutexAcquire am(gMutex); | |
| 220 while (!fCachedBlurMaskRecordList.empty()) { | |
| 221 BlurMaskRecord* cachedBlurMaskRecord = fCachedBlurMaskRecordList.front() ; | |
| 222 fCachedBlurMaskRecordList.pop_front(); | |
| 223 if (cachedBlurMaskRecord) { | |
| 224 delete cachedBlurMaskRecord; | |
| 225 cachedBlurMaskRecord = NULL; | |
| 226 } | |
| 227 } | |
| 228 } | |
| 229 | |
| 115 SkMaskFilter* SkBlurMaskFilter::Create(SkBlurStyle style, SkScalar sigma, uint32 _t flags) { | 230 SkMaskFilter* SkBlurMaskFilter::Create(SkBlurStyle style, SkScalar sigma, uint32 _t flags) { |
| 116 if (!SkScalarIsFinite(sigma) || sigma <= 0) { | 231 if (!SkScalarIsFinite(sigma) || sigma <= 0) { |
| 117 return NULL; | 232 return NULL; |
| 118 } | 233 } |
| 119 if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) { | 234 if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) { |
| 120 return NULL; | 235 return NULL; |
| 121 } | 236 } |
| 122 if (flags > SkBlurMaskFilter::kAll_BlurFlag) { | 237 if (flags > SkBlurMaskFilter::kAll_BlurFlag) { |
| 123 return NULL; | 238 return NULL; |
| 124 } | 239 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 SkRect smallR = SkRect::MakeWH(totalSmallWidth, totalSmallHeight); | 473 SkRect smallR = SkRect::MakeWH(totalSmallWidth, totalSmallHeight); |
| 359 | 474 |
| 360 SkRRect smallRR; | 475 SkRRect smallRR; |
| 361 SkVector radii[4]; | 476 SkVector radii[4]; |
| 362 radii[SkRRect::kUpperLeft_Corner] = UL; | 477 radii[SkRRect::kUpperLeft_Corner] = UL; |
| 363 radii[SkRRect::kUpperRight_Corner] = UR; | 478 radii[SkRRect::kUpperRight_Corner] = UR; |
| 364 radii[SkRRect::kLowerRight_Corner] = LR; | 479 radii[SkRRect::kLowerRight_Corner] = LR; |
| 365 radii[SkRRect::kLowerLeft_Corner] = LL; | 480 radii[SkRRect::kLowerLeft_Corner] = LL; |
| 366 smallRR.setRectRadii(smallR, radii); | 481 smallRR.setRectRadii(smallR, radii); |
| 367 | 482 |
| 483 SkScalar sigma = this->computeXformedSigma(matrix); | |
| 484 SkDiscardableMemoryMask* cachedBlurMask = NULL; | |
| 485 SkRect rects[1]; | |
| 486 rects[0] = rrect.rect(); | |
| 487 if (getBlurMaskRecord(sigma, 1, rects, &cachedBlurMask)) { | |
| 488 patch->fDiscardableMemoryMask = *cachedBlurMask; | |
| 489 patch->fOuterRect = dstM.fBounds; | |
| 490 patch->fCenter.fX = SkScalarCeilToInt(leftUnstretched) + 1; | |
| 491 patch->fCenter.fY = SkScalarCeilToInt(topUnstretched) + 1; | |
| 492 return kTrue_FilterReturn; | |
| 493 } | |
| 494 | |
| 495 SkBlurMask::addDiscardableMemoryMaskToMap(&(patch->fDiscardableMemoryMask.fM ask), | |
| 496 &(patch->fDiscardableMemoryMask)); | |
| 368 bool analyticBlurWorked = false; | 497 bool analyticBlurWorked = false; |
| 369 if (c_analyticBlurRRect) { | 498 if (c_analyticBlurRRect) { |
| 370 analyticBlurWorked = | 499 analyticBlurWorked = |
| 371 this->filterRRectMask(&patch->fMask, smallRR, matrix, &margin, | 500 this->filterRRectMask(&(patch->fDiscardableMemoryMask.fMask), smallR R, matrix, &margin, |
| 372 SkMask::kComputeBoundsAndRenderImage_CreateMod e); | 501 SkMask::kComputeBoundsAndRenderImage_CreateMod e); |
| 373 } | 502 } |
| 374 | 503 |
| 375 if (!analyticBlurWorked) { | 504 if (!analyticBlurWorked) { |
| 376 if (!draw_rrect_into_mask(smallRR, &srcM)) { | 505 if (!draw_rrect_into_mask(smallRR, &srcM)) { |
| 377 return kFalse_FilterReturn; | 506 return kFalse_FilterReturn; |
| 378 } | 507 } |
| 379 | 508 |
| 380 SkAutoMaskFreeImage amf(srcM.fImage); | 509 SkAutoMaskFreeImage amf(srcM.fImage); |
| 381 | 510 |
| 382 if (!this->filterMask(&patch->fMask, srcM, matrix, &margin)) { | 511 if (!this->filterMask(&(patch->fDiscardableMemoryMask.fMask), srcM, matr ix, &margin)) { |
| 383 return kFalse_FilterReturn; | 512 return kFalse_FilterReturn; |
| 384 } | 513 } |
| 385 } | 514 } |
| 386 | 515 |
| 387 patch->fMask.fBounds.offsetTo(0, 0); | 516 SkBlurMask::removeDiscardableMemoryMaskFromMap(&(patch->fDiscardableMemoryMa sk.fMask)); |
| 517 patch->fDiscardableMemoryMask.fMask.fBounds.offsetTo(0, 0); | |
| 388 patch->fOuterRect = dstM.fBounds; | 518 patch->fOuterRect = dstM.fBounds; |
| 389 patch->fCenter.fX = SkScalarCeilToInt(leftUnstretched) + 1; | 519 patch->fCenter.fX = SkScalarCeilToInt(leftUnstretched) + 1; |
| 390 patch->fCenter.fY = SkScalarCeilToInt(topUnstretched) + 1; | 520 patch->fCenter.fY = SkScalarCeilToInt(topUnstretched) + 1; |
| 521 if (!cachedBlurMask) { | |
| 522 SkDiscardableMemoryMask* tempMask = new SkDiscardableMemoryMask; | |
| 523 *tempMask = patch->fDiscardableMemoryMask; | |
| 524 SkRect** tempRects = new SkRect* [1]; | |
| 525 tempRects[0] = new SkRect; | |
| 526 *(tempRects[0]) = rrect.rect(); | |
| 527 BlurMaskRecord * blurMaskRecord = new BlurMaskRecord(sigma, 1, tempRects , tempMask); | |
| 528 if (blurMaskRecord) | |
| 529 addBlurMaskRecord(blurMaskRecord); | |
| 530 } | |
| 531 | |
| 391 return kTrue_FilterReturn; | 532 return kTrue_FilterReturn; |
| 392 } | 533 } |
| 393 | 534 |
| 394 SK_CONF_DECLARE( bool, c_analyticBlurNinepatch, "mask.filter.analyticNinePatch", true, "Use the faster analytic blur approach for ninepatch rects" ); | 535 SK_CONF_DECLARE( bool, c_analyticBlurNinepatch, "mask.filter.analyticNinePatch", true, "Use the faster analytic blur approach for ninepatch rects" ); |
| 395 | 536 |
| 396 SkMaskFilter::FilterReturn | 537 SkMaskFilter::FilterReturn |
| 397 SkBlurMaskFilterImpl::filterRectsToNine(const SkRect rects[], int count, | 538 SkBlurMaskFilterImpl::filterRectsToNine(const SkRect rects[], int count, |
| 398 const SkMatrix& matrix, | 539 const SkMatrix& matrix, |
| 399 const SkIRect& clipBounds, | 540 const SkIRect& clipBounds, |
| 400 NinePatch* patch) const { | 541 NinePatch* patch) const { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 if (1 == count) { | 601 if (1 == count) { |
| 461 innerIR = srcM.fBounds; | 602 innerIR = srcM.fBounds; |
| 462 center.set(smallW, smallH); | 603 center.set(smallW, smallH); |
| 463 } else { | 604 } else { |
| 464 SkASSERT(2 == count); | 605 SkASSERT(2 == count); |
| 465 rects[1].roundIn(&innerIR); | 606 rects[1].roundIn(&innerIR); |
| 466 center.set(smallW + (innerIR.left() - srcM.fBounds.left()), | 607 center.set(smallW + (innerIR.left() - srcM.fBounds.left()), |
| 467 smallH + (innerIR.top() - srcM.fBounds.top())); | 608 smallH + (innerIR.top() - srcM.fBounds.top())); |
| 468 } | 609 } |
| 469 | 610 |
| 611 SkScalar sigma = this->computeXformedSigma(matrix); | |
| 612 SkDiscardableMemoryMask* cachedBlurMask = NULL; | |
| 613 if (getBlurMaskRecord(sigma, count, rects, &cachedBlurMask)) { | |
| 614 patch->fDiscardableMemoryMask = *cachedBlurMask; | |
| 615 patch->fOuterRect = dstM.fBounds; | |
| 616 patch->fCenter = center; | |
| 617 return kTrue_FilterReturn; | |
| 618 } | |
| 619 | |
| 470 // +1 so we get a clean, stretchable, center row/col | 620 // +1 so we get a clean, stretchable, center row/col |
| 471 smallW += 1; | 621 smallW += 1; |
| 472 smallH += 1; | 622 smallH += 1; |
| 473 | 623 |
| 474 // we want the inset amounts to be integral, so we don't change any | 624 // we want the inset amounts to be integral, so we don't change any |
| 475 // fractional phase on the fRight or fBottom of our smallR. | 625 // fractional phase on the fRight or fBottom of our smallR. |
| 476 const SkScalar dx = SkIntToScalar(innerIR.width() - smallW); | 626 const SkScalar dx = SkIntToScalar(innerIR.width() - smallW); |
| 477 const SkScalar dy = SkIntToScalar(innerIR.height() - smallH); | 627 const SkScalar dy = SkIntToScalar(innerIR.height() - smallH); |
| 478 if (dx < 0 || dy < 0) { | 628 if (dx < 0 || dy < 0) { |
| 479 // we're too small, relative to our blur, to break into nine-patch, | 629 // we're too small, relative to our blur, to break into nine-patch, |
| 480 // so we ask to have our normal filterMask() be called. | 630 // so we ask to have our normal filterMask() be called. |
| 481 return kUnimplemented_FilterReturn; | 631 return kUnimplemented_FilterReturn; |
| 482 } | 632 } |
| 483 | 633 |
| 484 smallR[0].set(rects[0].left(), rects[0].top(), rects[0].right() - dx, rects[ 0].bottom() - dy); | 634 smallR[0].set(rects[0].left(), rects[0].top(), rects[0].right() - dx, rects[ 0].bottom() - dy); |
| 485 if (smallR[0].width() < 2 || smallR[0].height() < 2) { | 635 if (smallR[0].width() < 2 || smallR[0].height() < 2) { |
| 486 return kUnimplemented_FilterReturn; | 636 return kUnimplemented_FilterReturn; |
| 487 } | 637 } |
| 488 if (2 == count) { | 638 if (2 == count) { |
| 489 smallR[1].set(rects[1].left(), rects[1].top(), | 639 smallR[1].set(rects[1].left(), rects[1].top(), |
| 490 rects[1].right() - dx, rects[1].bottom() - dy); | 640 rects[1].right() - dx, rects[1].bottom() - dy); |
| 491 SkASSERT(!smallR[1].isEmpty()); | 641 SkASSERT(!smallR[1].isEmpty()); |
| 492 } | 642 } |
| 493 | 643 |
| 644 SkBlurMask::addDiscardableMemoryMaskToMap(&(patch->fDiscardableMemoryMask.fM ask), | |
| 645 &(patch->fDiscardableMemoryMask)); | |
| 494 if (count > 1 || !c_analyticBlurNinepatch) { | 646 if (count > 1 || !c_analyticBlurNinepatch) { |
| 495 if (!draw_rects_into_mask(smallR, count, &srcM)) { | 647 if (!draw_rects_into_mask(smallR, count, &srcM)) { |
| 496 return kFalse_FilterReturn; | 648 return kFalse_FilterReturn; |
| 497 } | 649 } |
| 498 | |
| 499 SkAutoMaskFreeImage amf(srcM.fImage); | 650 SkAutoMaskFreeImage amf(srcM.fImage); |
| 500 | 651 |
| 501 if (!this->filterMask(&patch->fMask, srcM, matrix, &margin)) { | 652 if (!this->filterMask(&patch->fDiscardableMemoryMask.fMask, srcM, matrix , &margin)) { |
| 502 return kFalse_FilterReturn; | 653 return kFalse_FilterReturn; |
| 503 } | 654 } |
| 504 } else { | 655 } else { |
| 505 if (!this->filterRectMask(&patch->fMask, smallR[0], matrix, &margin, | 656 if (!this->filterRectMask(&patch->fDiscardableMemoryMask.fMask, smallR[0 ], matrix, &margin, |
| 506 SkMask::kComputeBoundsAndRenderImage_CreateMod e)) { | 657 SkMask::kComputeBoundsAndRenderImage_CreateMod e)) { |
| 507 return kFalse_FilterReturn; | 658 return kFalse_FilterReturn; |
| 508 } | 659 } |
| 509 } | 660 } |
| 510 patch->fMask.fBounds.offsetTo(0, 0); | 661 patch->fDiscardableMemoryMask.fMask.fBounds.offsetTo(0, 0); |
| 511 patch->fOuterRect = dstM.fBounds; | 662 patch->fOuterRect = dstM.fBounds; |
| 512 patch->fCenter = center; | 663 patch->fCenter = center; |
| 664 SkBlurMask::removeDiscardableMemoryMaskFromMap(&(patch->fDiscardableMemoryMa sk.fMask)); | |
| 665 if (!cachedBlurMask) { | |
| 666 SkDiscardableMemoryMask* tempMask = new SkDiscardableMemoryMask; | |
| 667 *tempMask = patch->fDiscardableMemoryMask; | |
| 668 SkRect** tempRects = new SkRect* [count]; | |
| 669 for (int i = 0; i < count; i++) { | |
| 670 tempRects[i] = new SkRect; | |
| 671 *(tempRects[i]) = rects[i]; | |
| 672 } | |
| 673 BlurMaskRecord * blurMaskRecord = new BlurMaskRecord(sigma, count, tempR ects, tempMask); | |
| 674 if (blurMaskRecord) | |
| 675 addBlurMaskRecord(blurMaskRecord); | |
| 676 } | |
| 677 | |
| 513 return kTrue_FilterReturn; | 678 return kTrue_FilterReturn; |
| 514 } | 679 } |
| 515 | 680 |
| 516 void SkBlurMaskFilterImpl::computeFastBounds(const SkRect& src, | 681 void SkBlurMaskFilterImpl::computeFastBounds(const SkRect& src, |
| 517 SkRect* dst) const { | 682 SkRect* dst) const { |
| 518 SkScalar pad = 3.0f * fSigma; | 683 SkScalar pad = 3.0f * fSigma; |
| 519 | 684 |
| 520 dst->set(src.fLeft - pad, src.fTop - pad, | 685 dst->set(src.fLeft - pad, src.fTop - pad, |
| 521 src.fRight + pad, src.fBottom + pad); | 686 src.fRight + pad, src.fBottom + pad); |
| 522 } | 687 } |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1209 } else { | 1374 } else { |
| 1210 str->append("None"); | 1375 str->append("None"); |
| 1211 } | 1376 } |
| 1212 str->append("))"); | 1377 str->append("))"); |
| 1213 } | 1378 } |
| 1214 #endif | 1379 #endif |
| 1215 | 1380 |
| 1216 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1381 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
| 1217 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1382 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
| 1218 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1383 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |