| 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 "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 468 |
| 469 /////////////////////////////////////////////////////////////////////////////// | 469 /////////////////////////////////////////////////////////////////////////////// |
| 470 | 470 |
| 471 // we use a local function to wrap the class static method to work around | 471 // we use a local function to wrap the class static method to work around |
| 472 // a bug in gcc98 | 472 // a bug in gcc98 |
| 473 void SkMask_FreeImage(uint8_t* image); | 473 void SkMask_FreeImage(uint8_t* image); |
| 474 void SkMask_FreeImage(uint8_t* image) { | 474 void SkMask_FreeImage(uint8_t* image) { |
| 475 SkMask::FreeImage(image); | 475 SkMask::FreeImage(image); |
| 476 } | 476 } |
| 477 | 477 |
| 478 bool SkBlurMask::Blur(SkMask* dst, const SkMask& src, | |
| 479 SkScalar radius, Style style, Quality quality, | |
| 480 SkIPoint* margin) { | |
| 481 return SkBlurMask::BoxBlur(dst, src, | |
| 482 SkBlurMask::ConvertRadiusToSigma(radius), | |
| 483 style, quality, margin); | |
| 484 } | |
| 485 | |
| 486 bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, | 478 bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, |
| 487 SkScalar sigma, Style style, Quality quality, | 479 SkScalar sigma, Style style, Quality quality, |
| 488 SkIPoint* margin) { | 480 SkIPoint* margin) { |
| 489 | 481 |
| 490 if (src.fFormat != SkMask::kA8_Format) { | 482 if (src.fFormat != SkMask::kA8_Format) { |
| 491 return false; | 483 return false; |
| 492 } | 484 } |
| 493 | 485 |
| 494 // Force high quality off for small radii (performance) | 486 // Force high quality off for small radii (performance) |
| 495 if (sigma <= SkIntToScalar(2)) { | 487 if (sigma <= SkIntToScalar(2)) { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 if (profile_size <= sw) { | 726 if (profile_size <= sw) { |
| 735 pixels[x] = ProfileLookup(profile, x, width, w); | 727 pixels[x] = ProfileLookup(profile, x, width, w); |
| 736 } else { | 728 } else { |
| 737 float span = float(sw)/(2*sigma); | 729 float span = float(sw)/(2*sigma); |
| 738 float giX = 1.5f - (x+.5f)/(2*sigma); | 730 float giX = 1.5f - (x+.5f)/(2*sigma); |
| 739 pixels[x] = (uint8_t) (255 * (gaussianIntegral(giX) - gaussianIntegra
l(giX + span))); | 731 pixels[x] = (uint8_t) (255 * (gaussianIntegral(giX) - gaussianIntegra
l(giX + span))); |
| 740 } | 732 } |
| 741 } | 733 } |
| 742 } | 734 } |
| 743 | 735 |
| 744 bool SkBlurMask::BlurRect(SkMask *dst, const SkRect &src, | |
| 745 SkScalar radius, Style style, | |
| 746 SkIPoint *margin, SkMask::CreateMode createMode) { | |
| 747 return SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(radius), | |
| 748 dst, src, | |
| 749 style, margin, createMode); | |
| 750 } | |
| 751 | |
| 752 bool SkBlurMask::BlurRect(SkScalar sigma, SkMask *dst, | 736 bool SkBlurMask::BlurRect(SkScalar sigma, SkMask *dst, |
| 753 const SkRect &src, Style style, | 737 const SkRect &src, Style style, |
| 754 SkIPoint *margin, SkMask::CreateMode createMode) { | 738 SkIPoint *margin, SkMask::CreateMode createMode) { |
| 755 int profile_size = SkScalarCeilToInt(6*sigma); | 739 int profile_size = SkScalarCeilToInt(6*sigma); |
| 756 | 740 |
| 757 int pad = profile_size/2; | 741 int pad = profile_size/2; |
| 758 if (margin) { | 742 if (margin) { |
| 759 margin->set( pad, pad ); | 743 margin->set( pad, pad ); |
| 760 } | 744 } |
| 761 | 745 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 uint8_t *dst_scanline = dp + y*dstWidth + pad; | 827 uint8_t *dst_scanline = dp + y*dstWidth + pad; |
| 844 memset(dst_scanline, 0xff, sw); | 828 memset(dst_scanline, 0xff, sw); |
| 845 } | 829 } |
| 846 } | 830 } |
| 847 // normal and solid styles are the same for analytic rect blurs, so don't | 831 // normal and solid styles are the same for analytic rect blurs, so don't |
| 848 // need to handle solid specially. | 832 // need to handle solid specially. |
| 849 | 833 |
| 850 return true; | 834 return true; |
| 851 } | 835 } |
| 852 | 836 |
| 853 bool SkBlurMask::BlurGroundTruth(SkMask* dst, const SkMask& src, SkScalar radius
, | 837 bool SkBlurMask::BlurRRect(SkScalar sigma, SkMask *dst, |
| 854 Style style, SkIPoint* margin) { | 838 const SkRRect &src, Style style, |
| 855 return BlurGroundTruth(ConvertRadiusToSigma(radius), dst, src, style, margin
); | 839 SkIPoint *margin, SkMask::CreateMode createMode) { |
| 840 // Temporary for now -- always fail, should cause caller to fall back |
| 841 // to old path. Plumbing just to land API and parallelize effort. |
| 842 |
| 843 return false; |
| 856 } | 844 } |
| 845 |
| 857 // The "simple" blur is a direct implementation of separable convolution with a
discrete | 846 // The "simple" blur is a direct implementation of separable convolution with a
discrete |
| 858 // gaussian kernel. It's "ground truth" in a sense; too slow to be used, but ve
ry | 847 // gaussian kernel. It's "ground truth" in a sense; too slow to be used, but ve
ry |
| 859 // useful for correctness comparisons. | 848 // useful for correctness comparisons. |
| 860 | 849 |
| 861 bool SkBlurMask::BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src, | 850 bool SkBlurMask::BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src, |
| 862 Style style, SkIPoint* margin) { | 851 Style style, SkIPoint* margin) { |
| 863 | 852 |
| 864 if (src.fFormat != SkMask::kA8_Format) { | 853 if (src.fFormat != SkMask::kA8_Format) { |
| 865 return false; | 854 return false; |
| 866 } | 855 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 (void)autoCall.detach(); | 983 (void)autoCall.detach(); |
| 995 } | 984 } |
| 996 | 985 |
| 997 if (style == kInner_Style) { | 986 if (style == kInner_Style) { |
| 998 dst->fBounds = src.fBounds; // restore trimmed bounds | 987 dst->fBounds = src.fBounds; // restore trimmed bounds |
| 999 dst->fRowBytes = src.fRowBytes; | 988 dst->fRowBytes = src.fRowBytes; |
| 1000 } | 989 } |
| 1001 | 990 |
| 1002 return true; | 991 return true; |
| 1003 } | 992 } |
| OLD | NEW |