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

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

Issue 997923002: fix for valgrind preAbandonGpuContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix for valgrind leak Created 5 years, 9 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/GrCoordTransform.h ('k') | no next file » | 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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 GrTexture *blurNinePatchTexture = context->findAndRefCachedTexture(key); 930 SkAutoTUnref<GrTexture> blurNinePatchTexture(context->findAndRefCachedTextur e(key));
931 931
932 if (NULL == blurNinePatchTexture) { 932 if (!blurNinePatchTexture) {
933 SkMask mask; 933 SkMask mask;
934 934
935 unsigned int smallRectSide = 2*(blurRadius + cornerRadius) + 1; 935 unsigned int smallRectSide = 2*(blurRadius + cornerRadius) + 1;
936 936
937 mask.fBounds = SkIRect::MakeWH(smallRectSide, smallRectSide); 937 mask.fBounds = SkIRect::MakeWH(smallRectSide, smallRectSide);
938 mask.fFormat = SkMask::kA8_Format; 938 mask.fFormat = SkMask::kA8_Format;
939 mask.fRowBytes = mask.fBounds.width(); 939 mask.fRowBytes = mask.fBounds.width();
940 mask.fImage = SkMask::AllocImage(mask.computeTotalImageSize()); 940 mask.fImage = SkMask::AllocImage(mask.computeTotalImageSize());
941 SkAutoMaskFreeImage amfi(mask.fImage); 941 SkAutoMaskFreeImage amfi(mask.fImage);
942 942
943 memset(mask.fImage, 0, mask.computeTotalImageSize()); 943 memset(mask.fImage, 0, mask.computeTotalImageSize());
944 944
945 SkRect smallRect; 945 SkRect smallRect;
946 smallRect.setWH(SkIntToScalar(smallRectSide), SkIntToScalar(smallRectSid e)); 946 smallRect.setWH(SkIntToScalar(smallRectSide), SkIntToScalar(smallRectSid e));
947 947
948 SkRRect smallRRect; 948 SkRRect smallRRect;
949 smallRRect.setRectXY(smallRect, SkIntToScalar(cornerRadius), SkIntToScal ar(cornerRadius)); 949 smallRRect.setRectXY(smallRect, SkIntToScalar(cornerRadius), SkIntToScal ar(cornerRadius));
950 950
951 SkPath path; 951 SkPath path;
952 path.addRRect( smallRRect ); 952 path.addRRect( smallRRect );
953 953
954 SkDraw::DrawToMask(path, &mask.fBounds, NULL, NULL, &mask, 954 SkDraw::DrawToMask(path, &mask.fBounds, NULL, NULL, &mask,
955 SkMask::kJustRenderImage_CreateMode, SkPaint::kFill_S tyle); 955 SkMask::kJustRenderImage_CreateMode, SkPaint::kFill_S tyle);
956 956
957 SkMask blurred_mask; 957 SkMask blurredMask;
958 SkBlurMask::BoxBlur(&blurred_mask, mask, sigma, kNormal_SkBlurStyle, kHi gh_SkBlurQuality, 958 SkBlurMask::BoxBlur(&blurredMask, mask, sigma, kNormal_SkBlurStyle, kHig h_SkBlurQuality,
959 NULL, true ); 959 NULL, true );
960 960
961 unsigned int texSide = smallRectSide + 2*blurRadius; 961 unsigned int texSide = smallRectSide + 2*blurRadius;
962 GrSurfaceDesc texDesc; 962 GrSurfaceDesc texDesc;
963 texDesc.fWidth = texSide; 963 texDesc.fWidth = texSide;
964 texDesc.fHeight = texSide; 964 texDesc.fHeight = texSide;
965 texDesc.fConfig = kAlpha_8_GrPixelConfig; 965 texDesc.fConfig = kAlpha_8_GrPixelConfig;
966 966
967 blurNinePatchTexture = context->createTexture(texDesc, true, blurred_mas k.fImage, 0); 967 blurNinePatchTexture.reset(context->createTexture(texDesc, true, blurred Mask.fImage, 0));
968 SkMask::FreeImage(blurredMask.fImage);
968 if (!blurNinePatchTexture) { 969 if (!blurNinePatchTexture) {
969 return NULL; 970 return NULL;
970 } 971 }
971 context->addResourceToCache(key, blurNinePatchTexture); 972 context->addResourceToCache(key, blurNinePatchTexture);
972
973 SkMask::FreeImage(blurred_mask.fImage);
974 } 973 }
975
976 SkAutoTUnref<GrTexture> blurunref(blurNinePatchTexture);
977 if (NULL == blurNinePatchTexture) {
978 return NULL;
979 }
980
981 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture)); 974 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture));
982 } 975 }
983 976
984 void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 977 void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
985 inout->mulByUnknownSingleComponent(); 978 inout->mulByUnknownSingleComponent();
986 } 979 }
987 980
988 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur e *ninePatchTexture) 981 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur e *ninePatchTexture)
989 : fRRect(rrect), 982 : fRRect(rrect),
990 fSigma(sigma), 983 fSigma(sigma),
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 } else { 1265 } else {
1273 str->append("None"); 1266 str->append("None");
1274 } 1267 }
1275 str->append("))"); 1268 str->append("))");
1276 } 1269 }
1277 #endif 1270 #endif
1278 1271
1279 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1272 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1280 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1273 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1281 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1274 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « include/gpu/GrCoordTransform.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698