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

Unified Diff: src/effects/SkBlurMaskFilter.cpp

Issue 882223003: Move npot resizing out of GrContext and simplify GrContext texture functions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/GrTypes.h ('k') | src/effects/SkColorCubeFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkBlurMaskFilter.cpp
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 3487ae40b49af51ebc8ccf3d01dcbea2e839b92b..d284717f936a34bc92514949f58c302cdc38cf59 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -750,7 +750,6 @@ void GrGLRectBlurEffect::setData(const GrGLProgramDataManager& pdman,
bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma,
GrTexture **blurProfileTexture) {
- GrTextureParams params;
GrSurfaceDesc texDesc;
unsigned int profileSize = SkScalarCeilToInt(6*sigma);
@@ -768,18 +767,19 @@ bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma,
uint8_t *profile = NULL;
SkAutoTDeleteArray<uint8_t> ada(NULL);
- *blurProfileTexture = context->findAndRefTexture(texDesc, key, &params);
+ *blurProfileTexture = context->findAndRefCachedTexture(key);
if (NULL == *blurProfileTexture) {
SkBlurMask::ComputeBlurProfile(sigma, &profile);
ada.reset(profile);
- *blurProfileTexture = context->createTexture(&params, texDesc, key, profile, 0);
+ *blurProfileTexture = context->createTexture(texDesc, profile, 0);
if (NULL == *blurProfileTexture) {
return false;
}
+ SkAssertResult(context->addResourceToCache(key, *blurProfileTexture));
}
return true;
@@ -925,21 +925,13 @@ GrFragmentProcessor* GrRRectBlurEffect::Create(GrContext* context, float sigma,
builder[1] = cornerRadius;
builder.finish();
- GrTextureParams params;
- params.setFilterMode(GrTextureParams::kBilerp_FilterMode);
-
- unsigned int smallRectSide = 2*(blurRadius + cornerRadius) + 1;
- unsigned int texSide = smallRectSide + 2*blurRadius;
- GrSurfaceDesc texDesc;
- texDesc.fWidth = texSide;
- texDesc.fHeight = texSide;
- texDesc.fConfig = kAlpha_8_GrPixelConfig;
-
- GrTexture *blurNinePatchTexture = context->findAndRefTexture(texDesc, key, &params);
+ GrTexture *blurNinePatchTexture = context->findAndRefCachedTexture(key);
if (NULL == blurNinePatchTexture) {
SkMask mask;
+ unsigned int smallRectSide = 2*(blurRadius + cornerRadius) + 1;
+
mask.fBounds = SkIRect::MakeWH(smallRectSide, smallRectSide);
mask.fFormat = SkMask::kA8_Format;
mask.fRowBytes = mask.fBounds.width();
@@ -957,12 +949,22 @@ GrFragmentProcessor* GrRRectBlurEffect::Create(GrContext* context, float sigma,
SkPath path;
path.addRRect( smallRRect );
- SkDraw::DrawToMask(path, &mask.fBounds, NULL, NULL, &mask, SkMask::kJustRenderImage_CreateMode, SkPaint::kFill_Style);
+ SkDraw::DrawToMask(path, &mask.fBounds, NULL, NULL, &mask,
+ SkMask::kJustRenderImage_CreateMode, SkPaint::kFill_Style);
SkMask blurred_mask;
- SkBlurMask::BoxBlur(&blurred_mask, mask, sigma, kNormal_SkBlurStyle, kHigh_SkBlurQuality, NULL, true );
+ SkBlurMask::BoxBlur(&blurred_mask, mask, sigma, kNormal_SkBlurStyle, kHigh_SkBlurQuality,
+ NULL, true );
+
+ unsigned int texSide = smallRectSide + 2*blurRadius;
+ GrSurfaceDesc texDesc;
+ texDesc.fWidth = texSide;
+ texDesc.fHeight = texSide;
+ texDesc.fConfig = kAlpha_8_GrPixelConfig;
+
+ blurNinePatchTexture = context->createTexture(texDesc, blurred_mask.fImage, 0);
+ SkAssertResult(context->addResourceToCache(key, blurNinePatchTexture));
- blurNinePatchTexture = context->createTexture(&params, texDesc, key, blurred_mask.fImage, 0);
SkMask::FreeImage(blurred_mask.fImage);
}
« 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