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

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

Issue 131163007: release the scanline textures in GrRectBlurEffect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use autounref, and clean up more tidy after CreateScanlineTextures in the event that creating the v… Created 6 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 | « no previous file | 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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 typedef GrGLRectBlurEffect GLEffect; 520 typedef GrGLRectBlurEffect GLEffect;
521 521
522 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; 522 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
523 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; 523 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
524 524
525 /** 525 /**
526 * Create a simple filter effect with custom bicubic coefficients. 526 * Create a simple filter effect with custom bicubic coefficients.
527 */ 527 */
528 static GrEffectRef* Create(GrContext *context, const SkRect& rect, 528 static GrEffectRef* Create(GrContext *context, const SkRect& rect,
529 float sigma) { 529 float sigma) {
530 GrTexture *horizontalScanline, *verticalScanline; 530 GrTexture *horizontalScanline = NULL, *verticalScanline = NULL;
531 bool createdScanlines = CreateScanlineTextures(context, sigma, 531 bool createdScanlines = CreateScanlineTextures(context, sigma,
532 SkScalarCeilToInt(rect.wi dth()), 532 SkScalarCeilToInt(rect.wi dth()),
533 SkScalarCeilToInt(rect.he ight()), 533 SkScalarCeilToInt(rect.he ight()),
534 &horizontalScanline, &ver ticalScanline); 534 &horizontalScanline, &ver ticalScanline);
robertphillips 2014/01/31 13:33:10 Won't this potentially cause a problem if the hori
humper 2014/01/31 13:51:17 yeah, I'll land a better fix for this once this pa
535 if (!createdScanlines) { 535 SkAutoTUnref<GrTexture> hunref(horizontalScanline), vunref(verticalScan line);
536 if (!createdScanlines) {
536 return NULL; 537 return NULL;
537 } 538 }
538 AutoEffectUnref effect(SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, 539 AutoEffectUnref effect(SkNEW_ARGS(GrRectBlurEffect, (rect, sigma,
539 horizontalScanline, verticalScanline))); 540 horizontalScanline, verticalScanline)));
540 return CreateEffectRef(effect); 541 return CreateEffectRef(effect);
541 } 542 }
542 543
543 unsigned int getWidth() const { return fWidth; } 544 unsigned int getWidth() const { return fWidth; }
544 unsigned int getHeight() const { return fHeight; } 545 unsigned int getHeight() const { return fHeight; }
545 float getSigma() const { return fSigma; } 546 float getSigma() const { return fSigma; }
546 const GrCoordTransform& getTransform() const { return fTransform; } 547 const GrCoordTransform& getTransform() const { return fTransform; }
547 548
548 private: 549 private:
549 GrRectBlurEffect(const SkRect& rect, float sigma, 550 GrRectBlurEffect(const SkRect& rect, float sigma,
550 GrTexture *horizontal_scanline, GrTexture *vertical_scanlin e); 551 GrTexture *horizontal_scanline, GrTexture *vertical_scanlin e);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 ada.reset(profile); 680 ada.reset(profile);
680 } 681 }
681 682
682 SkAutoTMalloc<uint8_t> verticalPixels(height); 683 SkAutoTMalloc<uint8_t> verticalPixels(height);
683 SkBlurMask::ComputeBlurredScanline(verticalPixels, profile, height, sigm a); 684 SkBlurMask::ComputeBlurredScanline(verticalPixels, profile, height, sigm a);
684 685
685 *verticalScanline = context->createTexture(&params, texDesc, verticalCac heID, 686 *verticalScanline = context->createTexture(&params, texDesc, verticalCac heID,
686 verticalPixels, 0); 687 verticalPixels, 0);
687 688
688 if (NULL == *verticalScanline) { 689 if (NULL == *verticalScanline) {
690 (*horizontalScanline)->unref();
689 return false; 691 return false;
690 } 692 }
691 693
692 } 694 }
693 return true; 695 return true;
694 } 696 }
695 697
696 GrRectBlurEffect::GrRectBlurEffect(const SkRect& rect, float sigma, 698 GrRectBlurEffect::GrRectBlurEffect(const SkRect& rect, float sigma,
697 GrTexture *horizontal_scanline, GrTexture *ve rtical_scanline) 699 GrTexture *horizontal_scanline, GrTexture *ve rtical_scanline)
698 : INHERITED(), 700 : INHERITED(),
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 } else { 897 } else {
896 str->append("None"); 898 str->append("None");
897 } 899 }
898 str->append("))"); 900 str->append("))");
899 } 901 }
900 #endif 902 #endif
901 903
902 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 904 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
903 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 905 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
904 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 906 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698