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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma, | 749 bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma, |
750 GrTexture **blurProfileTexture)
{ | 750 GrTexture **blurProfileTexture)
{ |
751 GrSurfaceDesc texDesc; | 751 GrSurfaceDesc texDesc; |
752 | 752 |
753 unsigned int profileSize = SkScalarCeilToInt(6*sigma); | 753 unsigned int profileSize = SkScalarCeilToInt(6*sigma); |
754 | 754 |
755 texDesc.fWidth = profileSize; | 755 texDesc.fWidth = profileSize; |
756 texDesc.fHeight = 1; | 756 texDesc.fHeight = 1; |
757 texDesc.fConfig = kAlpha_8_GrPixelConfig; | 757 texDesc.fConfig = kAlpha_8_GrPixelConfig; |
758 | 758 |
759 static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain(); | 759 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
760 GrContentKey key; | 760 GrUniqueKey key; |
761 GrContentKey::Builder builder(&key, kDomain, 1); | 761 GrUniqueKey::Builder builder(&key, kDomain, 1); |
762 builder[0] = profileSize; | 762 builder[0] = profileSize; |
763 builder.finish(); | 763 builder.finish(); |
764 | 764 |
765 uint8_t *profile = NULL; | 765 uint8_t *profile = NULL; |
766 SkAutoTDeleteArray<uint8_t> ada(NULL); | 766 SkAutoTDeleteArray<uint8_t> ada(NULL); |
767 | 767 |
768 *blurProfileTexture = context->findAndRefCachedTexture(key); | 768 *blurProfileTexture = context->findAndRefCachedTexture(key); |
769 | 769 |
770 if (NULL == *blurProfileTexture) { | 770 if (NULL == *blurProfileTexture) { |
771 | 771 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 // sufficiently small relative to both the size of the corner radius and the | 910 // sufficiently small relative to both the size of the corner radius and the |
911 // width (and height) of the rrect. | 911 // width (and height) of the rrect. |
912 | 912 |
913 unsigned int blurRadius = 3*SkScalarCeilToInt(sigma-1/6.0f); | 913 unsigned int blurRadius = 3*SkScalarCeilToInt(sigma-1/6.0f); |
914 unsigned int cornerRadius = SkScalarCeilToInt(rrect.getSimpleRadii().x()); | 914 unsigned int cornerRadius = SkScalarCeilToInt(rrect.getSimpleRadii().x()); |
915 if (cornerRadius + blurRadius > rrect.width()/2 || | 915 if (cornerRadius + blurRadius > rrect.width()/2 || |
916 cornerRadius + blurRadius > rrect.height()/2) { | 916 cornerRadius + blurRadius > rrect.height()/2) { |
917 return NULL; | 917 return NULL; |
918 } | 918 } |
919 | 919 |
920 static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain(); | 920 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
921 GrContentKey key; | 921 GrUniqueKey key; |
922 GrContentKey::Builder builder(&key, kDomain, 2); | 922 GrUniqueKey::Builder builder(&key, kDomain, 2); |
923 builder[0] = blurRadius; | 923 builder[0] = blurRadius; |
924 builder[1] = cornerRadius; | 924 builder[1] = cornerRadius; |
925 builder.finish(); | 925 builder.finish(); |
926 | 926 |
927 GrTexture *blurNinePatchTexture = context->findAndRefCachedTexture(key); | 927 GrTexture *blurNinePatchTexture = context->findAndRefCachedTexture(key); |
928 | 928 |
929 if (NULL == blurNinePatchTexture) { | 929 if (NULL == blurNinePatchTexture) { |
930 SkMask mask; | 930 SkMask mask; |
931 | 931 |
932 unsigned int smallRectSide = 2*(blurRadius + cornerRadius) + 1; | 932 unsigned int smallRectSide = 2*(blurRadius + cornerRadius) + 1; |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 } else { | 1266 } else { |
1267 str->append("None"); | 1267 str->append("None"); |
1268 } | 1268 } |
1269 str->append("))"); | 1269 str->append("))"); |
1270 } | 1270 } |
1271 #endif | 1271 #endif |
1272 | 1272 |
1273 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1273 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
1274 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1274 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
1275 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1275 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |