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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
740 } | 740 } |
741 | 741 |
742 void GrGLRectBlurEffect::setData(const GrGLProgramDataManager& pdman, | 742 void GrGLRectBlurEffect::setData(const GrGLProgramDataManager& pdman, |
743 const GrProcessor& proc) { | 743 const GrProcessor& proc) { |
744 const GrRectBlurEffect& rbe = proc.cast<GrRectBlurEffect>(); | 744 const GrRectBlurEffect& rbe = proc.cast<GrRectBlurEffect>(); |
745 SkRect rect = rbe.getRect(); | 745 SkRect rect = rbe.getRect(); |
746 | 746 |
747 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot tom); | 747 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot tom); |
748 pdman.set1f(fProfileSizeUniform, SkScalarCeilToScalar(6*rbe.getSigma())); | 748 pdman.set1f(fProfileSizeUniform, SkScalarCeilToScalar(6*rbe.getSigma())); |
749 } | 749 } |
750 | 750 |
robertphillips
2015/04/30 20:43:44
Just pass in textureProvider ?
bsalomon
2015/04/30 20:58:39
Done.
| |
751 bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma, | 751 bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma, |
752 GrTexture **blurProfileTexture) { | 752 GrTexture **blurProfileTexture) { |
753 GrSurfaceDesc texDesc; | 753 GrSurfaceDesc texDesc; |
754 | 754 |
755 unsigned int profileSize = SkScalarCeilToInt(6*sigma); | 755 unsigned int profileSize = SkScalarCeilToInt(6*sigma); |
756 | 756 |
757 texDesc.fWidth = profileSize; | 757 texDesc.fWidth = profileSize; |
758 texDesc.fHeight = 1; | 758 texDesc.fHeight = 1; |
759 texDesc.fConfig = kAlpha_8_GrPixelConfig; | 759 texDesc.fConfig = kAlpha_8_GrPixelConfig; |
760 | 760 |
761 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); | 761 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
762 GrUniqueKey key; | 762 GrUniqueKey key; |
763 GrUniqueKey::Builder builder(&key, kDomain, 1); | 763 GrUniqueKey::Builder builder(&key, kDomain, 1); |
764 builder[0] = profileSize; | 764 builder[0] = profileSize; |
765 builder.finish(); | 765 builder.finish(); |
766 | 766 |
767 uint8_t *profile = NULL; | 767 uint8_t *profile = NULL; |
768 SkAutoTDeleteArray<uint8_t> ada(NULL); | 768 SkAutoTDeleteArray<uint8_t> ada(NULL); |
769 | 769 |
770 *blurProfileTexture = context->findAndRefCachedTexture(key); | 770 *blurProfileTexture = context->textureProvider()->findAndRefTextureByUniqueK ey(key); |
771 | 771 |
772 if (NULL == *blurProfileTexture) { | 772 if (NULL == *blurProfileTexture) { |
773 | 773 |
774 SkBlurMask::ComputeBlurProfile(sigma, &profile); | 774 SkBlurMask::ComputeBlurProfile(sigma, &profile); |
775 ada.reset(profile); | 775 ada.reset(profile); |
776 | 776 |
777 *blurProfileTexture = context->createTexture(texDesc, true, profile, 0); | 777 *blurProfileTexture = context->textureProvider()->createTexture(texDesc, true, profile, 0); |
778 | 778 |
779 if (NULL == *blurProfileTexture) { | 779 if (NULL == *blurProfileTexture) { |
780 return false; | 780 return false; |
781 } | 781 } |
782 context->addResourceToCache(key, *blurProfileTexture); | 782 context->textureProvider()->assignUniqueKeyToTexture(key, *blurProfileTe xture); |
783 } | 783 } |
784 | 784 |
785 return true; | 785 return true; |
786 } | 786 } |
787 | 787 |
788 GrRectBlurEffect::GrRectBlurEffect(const SkRect& rect, float sigma, | 788 GrRectBlurEffect::GrRectBlurEffect(const SkRect& rect, float sigma, |
789 GrTexture *blur_profile) | 789 GrTexture *blur_profile) |
790 : fRect(rect), | 790 : fRect(rect), |
791 fSigma(sigma), | 791 fSigma(sigma), |
792 fBlurProfileAccess(blur_profile) { | 792 fBlurProfileAccess(blur_profile) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
920 return NULL; | 920 return NULL; |
921 } | 921 } |
922 | 922 |
923 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); | 923 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
924 GrUniqueKey key; | 924 GrUniqueKey key; |
925 GrUniqueKey::Builder builder(&key, kDomain, 2); | 925 GrUniqueKey::Builder builder(&key, kDomain, 2); |
926 builder[0] = blurRadius; | 926 builder[0] = blurRadius; |
927 builder[1] = cornerRadius; | 927 builder[1] = cornerRadius; |
928 builder.finish(); | 928 builder.finish(); |
929 | 929 |
930 SkAutoTUnref<GrTexture> blurNinePatchTexture(context->findAndRefCachedTextur e(key)); | 930 SkAutoTUnref<GrTexture> blurNinePatchTexture( |
931 context->textureProvider()->findAndRefTextureByUniqueKey(key)); | |
931 | 932 |
932 if (!blurNinePatchTexture) { | 933 if (!blurNinePatchTexture) { |
933 SkMask mask; | 934 SkMask mask; |
934 | 935 |
935 unsigned int smallRectSide = 2*(blurRadius + cornerRadius) + 1; | 936 unsigned int smallRectSide = 2*(blurRadius + cornerRadius) + 1; |
936 | 937 |
937 mask.fBounds = SkIRect::MakeWH(smallRectSide, smallRectSide); | 938 mask.fBounds = SkIRect::MakeWH(smallRectSide, smallRectSide); |
938 mask.fFormat = SkMask::kA8_Format; | 939 mask.fFormat = SkMask::kA8_Format; |
939 mask.fRowBytes = mask.fBounds.width(); | 940 mask.fRowBytes = mask.fBounds.width(); |
940 mask.fImage = SkMask::AllocImage(mask.computeTotalImageSize()); | 941 mask.fImage = SkMask::AllocImage(mask.computeTotalImageSize()); |
(...skipping 16 matching lines...) Expand all Loading... | |
957 SkMask blurredMask; | 958 SkMask blurredMask; |
958 SkBlurMask::BoxBlur(&blurredMask, mask, sigma, kNormal_SkBlurStyle, kHig h_SkBlurQuality, | 959 SkBlurMask::BoxBlur(&blurredMask, mask, sigma, kNormal_SkBlurStyle, kHig h_SkBlurQuality, |
959 NULL, true ); | 960 NULL, true ); |
960 | 961 |
961 unsigned int texSide = smallRectSide + 2*blurRadius; | 962 unsigned int texSide = smallRectSide + 2*blurRadius; |
962 GrSurfaceDesc texDesc; | 963 GrSurfaceDesc texDesc; |
963 texDesc.fWidth = texSide; | 964 texDesc.fWidth = texSide; |
964 texDesc.fHeight = texSide; | 965 texDesc.fHeight = texSide; |
965 texDesc.fConfig = kAlpha_8_GrPixelConfig; | 966 texDesc.fConfig = kAlpha_8_GrPixelConfig; |
966 | 967 |
967 blurNinePatchTexture.reset(context->createTexture(texDesc, true, blurred Mask.fImage, 0)); | 968 blurNinePatchTexture.reset( |
969 context->textureProvider()->createTexture(texDesc, true, blurredMask .fImage, 0)); | |
968 SkMask::FreeImage(blurredMask.fImage); | 970 SkMask::FreeImage(blurredMask.fImage); |
969 if (!blurNinePatchTexture) { | 971 if (!blurNinePatchTexture) { |
970 return NULL; | 972 return NULL; |
971 } | 973 } |
972 context->addResourceToCache(key, blurNinePatchTexture); | 974 context->textureProvider()->assignUniqueKeyToTexture(key, blurNinePatchT exture); |
973 } | 975 } |
974 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture)); | 976 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture)); |
975 } | 977 } |
976 | 978 |
977 void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { | 979 void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { |
978 inout->mulByUnknownSingleComponent(); | 980 inout->mulByUnknownSingleComponent(); |
979 } | 981 } |
980 | 982 |
981 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur e *ninePatchTexture) | 983 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur e *ninePatchTexture) |
982 : fRRect(rrect), | 984 : fRRect(rrect), |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1265 } else { | 1267 } else { |
1266 str->append("None"); | 1268 str->append("None"); |
1267 } | 1269 } |
1268 str->append("))"); | 1270 str->append("))"); |
1269 } | 1271 } |
1270 #endif | 1272 #endif |
1271 | 1273 |
1272 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1274 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
1273 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1275 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
1274 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1276 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |