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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 346 |
347 // TODO: take clipBounds into account to limit our coordinates up front | 347 // TODO: take clipBounds into account to limit our coordinates up front |
348 // for now, just skip too-large src rects (to take the old code path). | 348 // for now, just skip too-large src rects (to take the old code path). |
349 if (rect_exceeds(rrect.rect(), SkIntToScalar(32767))) { | 349 if (rect_exceeds(rrect.rect(), SkIntToScalar(32767))) { |
350 return kUnimplemented_FilterReturn; | 350 return kUnimplemented_FilterReturn; |
351 } | 351 } |
352 | 352 |
353 SkIPoint margin; | 353 SkIPoint margin; |
354 SkMask srcM, dstM; | 354 SkMask srcM, dstM; |
355 srcM.fBounds = rrect.rect().roundOut(); | 355 srcM.fBounds = rrect.rect().roundOut(); |
356 srcM.fImage = nullptr; | |
357 srcM.fFormat = SkMask::kA8_Format; | 356 srcM.fFormat = SkMask::kA8_Format; |
358 srcM.fRowBytes = 0; | 357 srcM.fRowBytes = 0; |
359 | 358 |
360 bool filterResult = false; | 359 bool filterResult = false; |
361 if (c_analyticBlurRRect) { | 360 if (c_analyticBlurRRect) { |
362 // special case for fast round rect blur | 361 // special case for fast round rect blur |
363 // don't actually do the blur the first time, just compute the correct s
ize | 362 // don't actually do the blur the first time, just compute the correct s
ize |
364 filterResult = this->filterRRectMask(&dstM, rrect, matrix, &margin, | 363 filterResult = this->filterRRectMask(&dstM, rrect, matrix, &margin, |
365 SkMask::kJustComputeBounds_CreateMod
e); | 364 SkMask::kJustComputeBounds_CreateMod
e); |
366 } | 365 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 465 |
467 // TODO: take clipBounds into account to limit our coordinates up front | 466 // TODO: take clipBounds into account to limit our coordinates up front |
468 // for now, just skip too-large src rects (to take the old code path). | 467 // for now, just skip too-large src rects (to take the old code path). |
469 if (rect_exceeds(rects[0], SkIntToScalar(32767))) { | 468 if (rect_exceeds(rects[0], SkIntToScalar(32767))) { |
470 return kUnimplemented_FilterReturn; | 469 return kUnimplemented_FilterReturn; |
471 } | 470 } |
472 | 471 |
473 SkIPoint margin; | 472 SkIPoint margin; |
474 SkMask srcM, dstM; | 473 SkMask srcM, dstM; |
475 srcM.fBounds = rects[0].roundOut(); | 474 srcM.fBounds = rects[0].roundOut(); |
476 srcM.fImage = nullptr; | |
477 srcM.fFormat = SkMask::kA8_Format; | 475 srcM.fFormat = SkMask::kA8_Format; |
478 srcM.fRowBytes = 0; | 476 srcM.fRowBytes = 0; |
479 | 477 |
480 bool filterResult = false; | 478 bool filterResult = false; |
481 if (count == 1 && c_analyticBlurNinepatch) { | 479 if (count == 1 && c_analyticBlurNinepatch) { |
482 // special case for fast rect blur | 480 // special case for fast rect blur |
483 // don't actually do the blur the first time, just compute the correct s
ize | 481 // don't actually do the blur the first time, just compute the correct s
ize |
484 filterResult = this->filterRectMask(&dstM, rects[0], matrix, &margin, | 482 filterResult = this->filterRectMask(&dstM, rects[0], matrix, &margin, |
485 SkMask::kJustComputeBounds_CreateMod
e); | 483 SkMask::kJustComputeBounds_CreateMod
e); |
486 } else { | 484 } else { |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 SkRRect smallRRect; | 980 SkRRect smallRRect; |
983 smallRRect.setRectXY(smallRect, SkIntToScalar(cornerRadius), SkIntToScal
ar(cornerRadius)); | 981 smallRRect.setRectXY(smallRect, SkIntToScalar(cornerRadius), SkIntToScal
ar(cornerRadius)); |
984 | 982 |
985 SkPath path; | 983 SkPath path; |
986 path.addRRect(smallRRect); | 984 path.addRRect(smallRRect); |
987 | 985 |
988 SkDraw::DrawToMask(path, &mask.fBounds, nullptr, nullptr, &mask, | 986 SkDraw::DrawToMask(path, &mask.fBounds, nullptr, nullptr, &mask, |
989 SkMask::kJustRenderImage_CreateMode, SkPaint::kFill_S
tyle); | 987 SkMask::kJustRenderImage_CreateMode, SkPaint::kFill_S
tyle); |
990 | 988 |
991 SkMask blurredMask; | 989 SkMask blurredMask; |
992 SkBlurMask::BoxBlur(&blurredMask, mask, sigma, kNormal_SkBlurStyle, kHig
h_SkBlurQuality, | 990 if (!SkBlurMask::BoxBlur(&blurredMask, mask, sigma, kNormal_SkBlurStyle, |
993 nullptr, true); | 991 kHigh_SkBlurQuality, nullptr, true)) { |
| 992 return nullptr; |
| 993 } |
994 | 994 |
995 unsigned int texSide = smallRectSide + 2*blurRadius; | 995 unsigned int texSide = smallRectSide + 2*blurRadius; |
996 GrSurfaceDesc texDesc; | 996 GrSurfaceDesc texDesc; |
997 texDesc.fWidth = texSide; | 997 texDesc.fWidth = texSide; |
998 texDesc.fHeight = texSide; | 998 texDesc.fHeight = texSide; |
999 texDesc.fConfig = kAlpha_8_GrPixelConfig; | 999 texDesc.fConfig = kAlpha_8_GrPixelConfig; |
1000 | 1000 |
1001 blurNinePatchTexture.reset( | 1001 blurNinePatchTexture.reset( |
1002 texProvider->createTexture(texDesc, true, blurredMask.fImage, 0)); | 1002 texProvider->createTexture(texDesc, true, blurredMask.fImage, 0)); |
1003 SkMask::FreeImage(blurredMask.fImage); | 1003 SkMask::FreeImage(blurredMask.fImage); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 } else { | 1307 } else { |
1308 str->append("None"); | 1308 str->append("None"); |
1309 } | 1309 } |
1310 str->append("))"); | 1310 str->append("))"); |
1311 } | 1311 } |
1312 #endif | 1312 #endif |
1313 | 1313 |
1314 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1314 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
1315 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1315 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
1316 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1316 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |