Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/effects/SkBlurMaskFilter.cpp

Issue 868233005: Revert of Move npot resizing out of GrContext and simplify GrContext texture functions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/gpu/GrTypes.h ('k') | src/effects/SkColorCubeFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
751 bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma, 751 bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma,
752 GrTexture **blurProfileTexture) { 752 GrTexture **blurProfileTexture) {
753 GrTextureParams params;
753 GrSurfaceDesc texDesc; 754 GrSurfaceDesc texDesc;
754 755
755 unsigned int profileSize = SkScalarCeilToInt(6*sigma); 756 unsigned int profileSize = SkScalarCeilToInt(6*sigma);
756 757
757 texDesc.fWidth = profileSize; 758 texDesc.fWidth = profileSize;
758 texDesc.fHeight = 1; 759 texDesc.fHeight = 1;
759 texDesc.fConfig = kAlpha_8_GrPixelConfig; 760 texDesc.fConfig = kAlpha_8_GrPixelConfig;
760 761
761 static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain(); 762 static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
762 GrContentKey key; 763 GrContentKey key;
763 GrContentKey::Builder builder(&key, kDomain, 1); 764 GrContentKey::Builder builder(&key, kDomain, 1);
764 builder[0] = profileSize; 765 builder[0] = profileSize;
765 builder.finish(); 766 builder.finish();
766 767
767 uint8_t *profile = NULL; 768 uint8_t *profile = NULL;
768 SkAutoTDeleteArray<uint8_t> ada(NULL); 769 SkAutoTDeleteArray<uint8_t> ada(NULL);
769 770
770 *blurProfileTexture = context->findAndRefCachedTexture(key); 771 *blurProfileTexture = context->findAndRefTexture(texDesc, key, &params);
771 772
772 if (NULL == *blurProfileTexture) { 773 if (NULL == *blurProfileTexture) {
773 774
774 SkBlurMask::ComputeBlurProfile(sigma, &profile); 775 SkBlurMask::ComputeBlurProfile(sigma, &profile);
775 ada.reset(profile); 776 ada.reset(profile);
776 777
777 *blurProfileTexture = context->createTexture(texDesc, profile, 0); 778 *blurProfileTexture = context->createTexture(&params, texDesc, key, prof ile, 0);
778 779
779 if (NULL == *blurProfileTexture) { 780 if (NULL == *blurProfileTexture) {
780 return false; 781 return false;
781 } 782 }
782 SkAssertResult(context->addResourceToCache(key, *blurProfileTexture));
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 return NULL; 918 return NULL;
919 } 919 }
920 920
921 static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain(); 921 static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
922 GrContentKey key; 922 GrContentKey key;
923 GrContentKey::Builder builder(&key, kDomain, 2); 923 GrContentKey::Builder builder(&key, kDomain, 2);
924 builder[0] = blurRadius; 924 builder[0] = blurRadius;
925 builder[1] = cornerRadius; 925 builder[1] = cornerRadius;
926 builder.finish(); 926 builder.finish();
927 927
928 GrTexture *blurNinePatchTexture = context->findAndRefCachedTexture(key); 928 GrTextureParams params;
929 params.setFilterMode(GrTextureParams::kBilerp_FilterMode);
930
931 unsigned int smallRectSide = 2*(blurRadius + cornerRadius) + 1;
932 unsigned int texSide = smallRectSide + 2*blurRadius;
933 GrSurfaceDesc texDesc;
934 texDesc.fWidth = texSide;
935 texDesc.fHeight = texSide;
936 texDesc.fConfig = kAlpha_8_GrPixelConfig;
937
938 GrTexture *blurNinePatchTexture = context->findAndRefTexture(texDesc, key, & params);
929 939
930 if (NULL == blurNinePatchTexture) { 940 if (NULL == blurNinePatchTexture) {
931 SkMask mask; 941 SkMask mask;
932 942
933 unsigned int smallRectSide = 2*(blurRadius + cornerRadius) + 1;
934
935 mask.fBounds = SkIRect::MakeWH(smallRectSide, smallRectSide); 943 mask.fBounds = SkIRect::MakeWH(smallRectSide, smallRectSide);
936 mask.fFormat = SkMask::kA8_Format; 944 mask.fFormat = SkMask::kA8_Format;
937 mask.fRowBytes = mask.fBounds.width(); 945 mask.fRowBytes = mask.fBounds.width();
938 mask.fImage = SkMask::AllocImage(mask.computeTotalImageSize()); 946 mask.fImage = SkMask::AllocImage(mask.computeTotalImageSize());
939 SkAutoMaskFreeImage amfi(mask.fImage); 947 SkAutoMaskFreeImage amfi(mask.fImage);
940 948
941 memset(mask.fImage, 0, mask.computeTotalImageSize()); 949 memset(mask.fImage, 0, mask.computeTotalImageSize());
942 950
943 SkRect smallRect; 951 SkRect smallRect;
944 smallRect.setWH(SkIntToScalar(smallRectSide), SkIntToScalar(smallRectSid e)); 952 smallRect.setWH(SkIntToScalar(smallRectSide), SkIntToScalar(smallRectSid e));
945 953
946 SkRRect smallRRect; 954 SkRRect smallRRect;
947 smallRRect.setRectXY(smallRect, SkIntToScalar(cornerRadius), SkIntToScal ar(cornerRadius)); 955 smallRRect.setRectXY(smallRect, SkIntToScalar(cornerRadius), SkIntToScal ar(cornerRadius));
948 956
949 SkPath path; 957 SkPath path;
950 path.addRRect( smallRRect ); 958 path.addRRect( smallRRect );
951 959
952 SkDraw::DrawToMask(path, &mask.fBounds, NULL, NULL, &mask, 960 SkDraw::DrawToMask(path, &mask.fBounds, NULL, NULL, &mask, SkMask::kJust RenderImage_CreateMode, SkPaint::kFill_Style);
953 SkMask::kJustRenderImage_CreateMode, SkPaint::kFill_S tyle);
954 961
955 SkMask blurred_mask; 962 SkMask blurred_mask;
956 SkBlurMask::BoxBlur(&blurred_mask, mask, sigma, kNormal_SkBlurStyle, kHi gh_SkBlurQuality, 963 SkBlurMask::BoxBlur(&blurred_mask, mask, sigma, kNormal_SkBlurStyle, kHi gh_SkBlurQuality, NULL, true );
957 NULL, true );
958 964
959 unsigned int texSide = smallRectSide + 2*blurRadius; 965 blurNinePatchTexture = context->createTexture(&params, texDesc, key, blu rred_mask.fImage, 0);
960 GrSurfaceDesc texDesc;
961 texDesc.fWidth = texSide;
962 texDesc.fHeight = texSide;
963 texDesc.fConfig = kAlpha_8_GrPixelConfig;
964
965 blurNinePatchTexture = context->createTexture(texDesc, blurred_mask.fIma ge, 0);
966 SkAssertResult(context->addResourceToCache(key, blurNinePatchTexture));
967
968 SkMask::FreeImage(blurred_mask.fImage); 966 SkMask::FreeImage(blurred_mask.fImage);
969 } 967 }
970 968
971 SkAutoTUnref<GrTexture> blurunref(blurNinePatchTexture); 969 SkAutoTUnref<GrTexture> blurunref(blurNinePatchTexture);
972 if (NULL == blurNinePatchTexture) { 970 if (NULL == blurNinePatchTexture) {
973 return NULL; 971 return NULL;
974 } 972 }
975 973
976 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture)); 974 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture));
977 } 975 }
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 } else { 1265 } else {
1268 str->append("None"); 1266 str->append("None");
1269 } 1267 }
1270 str->append("))"); 1268 str->append("))");
1271 } 1269 }
1272 #endif 1270 #endif
1273 1271
1274 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1272 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1275 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1273 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1276 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1274 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « include/gpu/GrTypes.h ('k') | src/effects/SkColorCubeFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698