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

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

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web 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 | « src/effects/SkArithmeticMode_gpu.cpp ('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 20 matching lines...) Expand all
31 31
32 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { 32 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) {
33 return SkBlurMask::ConvertRadiusToSigma(radius); 33 return SkBlurMask::ConvertRadiusToSigma(radius);
34 } 34 }
35 35
36 class SkBlurMaskFilterImpl : public SkMaskFilter { 36 class SkBlurMaskFilterImpl : public SkMaskFilter {
37 public: 37 public:
38 SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle, uint32_t flags); 38 SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle, uint32_t flags);
39 39
40 // overrides from SkMaskFilter 40 // overrides from SkMaskFilter
41 SkMask::Format getFormat() const SK_OVERRIDE; 41 SkMask::Format getFormat() const override;
42 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, 42 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
43 SkIPoint* margin) const SK_OVERRIDE; 43 SkIPoint* margin) const override;
44 44
45 #if SK_SUPPORT_GPU 45 #if SK_SUPPORT_GPU
46 virtual bool canFilterMaskGPU(const SkRect& devBounds, 46 virtual bool canFilterMaskGPU(const SkRect& devBounds,
47 const SkIRect& clipBounds, 47 const SkIRect& clipBounds,
48 const SkMatrix& ctm, 48 const SkMatrix& ctm,
49 SkRect* maskRect) const SK_OVERRIDE; 49 SkRect* maskRect) const override;
50 virtual bool directFilterMaskGPU(GrContext* context, 50 virtual bool directFilterMaskGPU(GrContext* context,
51 GrRenderTarget* rt, 51 GrRenderTarget* rt,
52 GrPaint* grp, 52 GrPaint* grp,
53 const GrClip&, 53 const GrClip&,
54 const SkMatrix& viewMatrix, 54 const SkMatrix& viewMatrix,
55 const SkStrokeRec& strokeRec, 55 const SkStrokeRec& strokeRec,
56 const SkPath& path) const SK_OVERRIDE; 56 const SkPath& path) const override;
57 virtual bool directFilterRRectMaskGPU(GrContext* context, 57 virtual bool directFilterRRectMaskGPU(GrContext* context,
58 GrRenderTarget* rt, 58 GrRenderTarget* rt,
59 GrPaint* grp, 59 GrPaint* grp,
60 const GrClip&, 60 const GrClip&,
61 const SkMatrix& viewMatrix, 61 const SkMatrix& viewMatrix,
62 const SkStrokeRec& strokeRec, 62 const SkStrokeRec& strokeRec,
63 const SkRRect& rrect) const SK_OVERRID E; 63 const SkRRect& rrect) const override;
64 64
65 virtual bool filterMaskGPU(GrTexture* src, 65 virtual bool filterMaskGPU(GrTexture* src,
66 const SkMatrix& ctm, 66 const SkMatrix& ctm,
67 const SkRect& maskRect, 67 const SkRect& maskRect,
68 GrTexture** result, 68 GrTexture** result,
69 bool canOverwriteSrc) const SK_OVERRIDE; 69 bool canOverwriteSrc) const override;
70 #endif 70 #endif
71 71
72 void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE; 72 void computeFastBounds(const SkRect&, SkRect*) const override;
73 bool asABlur(BlurRec*) const SK_OVERRIDE; 73 bool asABlur(BlurRec*) const override;
74 74
75 SK_TO_STRING_OVERRIDE() 75 SK_TO_STRING_OVERRIDE()
76 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl) 76 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl)
77 77
78 protected: 78 protected:
79 virtual FilterReturn filterRectsToNine(const SkRect[], int count, const SkMa trix&, 79 virtual FilterReturn filterRectsToNine(const SkRect[], int count, const SkMa trix&,
80 const SkIRect& clipBounds, 80 const SkIRect& clipBounds,
81 NinePatch*) const SK_OVERRIDE; 81 NinePatch*) const override;
82 82
83 virtual FilterReturn filterRRectToNine(const SkRRect&, const SkMatrix&, 83 virtual FilterReturn filterRRectToNine(const SkRRect&, const SkMatrix&,
84 const SkIRect& clipBounds, 84 const SkIRect& clipBounds,
85 NinePatch*) const SK_OVERRIDE; 85 NinePatch*) const override;
86 86
87 bool filterRectMask(SkMask* dstM, const SkRect& r, const SkMatrix& matrix, 87 bool filterRectMask(SkMask* dstM, const SkRect& r, const SkMatrix& matrix,
88 SkIPoint* margin, SkMask::CreateMode createMode) const; 88 SkIPoint* margin, SkMask::CreateMode createMode) const;
89 bool filterRRectMask(SkMask* dstM, const SkRRect& r, const SkMatrix& matrix, 89 bool filterRRectMask(SkMask* dstM, const SkRRect& r, const SkMatrix& matrix,
90 SkIPoint* margin, SkMask::CreateMode createMode) const; 90 SkIPoint* margin, SkMask::CreateMode createMode) const;
91 91
92 private: 92 private:
93 // To avoid unseemly allocation requests (esp. for finite platforms like 93 // To avoid unseemly allocation requests (esp. for finite platforms like
94 // handset) we limit the radius so something manageable. (as opposed to 94 // handset) we limit the radius so something manageable. (as opposed to
95 // a request like 10,000) 95 // a request like 10,000)
96 static const SkScalar kMAX_BLUR_SIGMA; 96 static const SkScalar kMAX_BLUR_SIGMA;
97 97
98 SkScalar fSigma; 98 SkScalar fSigma;
99 SkBlurStyle fBlurStyle; 99 SkBlurStyle fBlurStyle;
100 uint32_t fBlurFlags; 100 uint32_t fBlurFlags;
101 101
102 SkBlurQuality getQuality() const { 102 SkBlurQuality getQuality() const {
103 return (fBlurFlags & SkBlurMaskFilter::kHighQuality_BlurFlag) ? 103 return (fBlurFlags & SkBlurMaskFilter::kHighQuality_BlurFlag) ?
104 kHigh_SkBlurQuality : kLow_SkBlurQuality; 104 kHigh_SkBlurQuality : kLow_SkBlurQuality;
105 } 105 }
106 106
107 SkBlurMaskFilterImpl(SkReadBuffer&); 107 SkBlurMaskFilterImpl(SkReadBuffer&);
108 void flatten(SkWriteBuffer&) const SK_OVERRIDE; 108 void flatten(SkWriteBuffer&) const override;
109 109
110 SkScalar computeXformedSigma(const SkMatrix& ctm) const { 110 SkScalar computeXformedSigma(const SkMatrix& ctm) const {
111 bool ignoreTransform = SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTr ansform_BlurFlag); 111 bool ignoreTransform = SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTr ansform_BlurFlag);
112 112
113 SkScalar xformedSigma = ignoreTransform ? fSigma : ctm.mapRadius(fSigma) ; 113 SkScalar xformedSigma = ignoreTransform ? fSigma : ctm.mapRadius(fSigma) ;
114 return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA); 114 return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA);
115 } 115 }
116 116
117 friend class SkBlurMaskFilter; 117 friend class SkBlurMaskFilter;
118 118
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 } 600 }
601 601
602 #if SK_SUPPORT_GPU 602 #if SK_SUPPORT_GPU
603 603
604 class GrGLRectBlurEffect; 604 class GrGLRectBlurEffect;
605 605
606 class GrRectBlurEffect : public GrFragmentProcessor { 606 class GrRectBlurEffect : public GrFragmentProcessor {
607 public: 607 public:
608 virtual ~GrRectBlurEffect(); 608 virtual ~GrRectBlurEffect();
609 609
610 const char* name() const SK_OVERRIDE { return "RectBlur"; } 610 const char* name() const override { return "RectBlur"; }
611 611
612 virtual void getGLProcessorKey(const GrGLCaps& caps, 612 virtual void getGLProcessorKey(const GrGLCaps& caps,
613 GrProcessorKeyBuilder* b) const SK_OVERRIDE; 613 GrProcessorKeyBuilder* b) const override;
614 614
615 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; 615 GrGLFragmentProcessor* createGLInstance() const override;
616 616
617 /** 617 /**
618 * Create a simple filter effect with custom bicubic coefficients. 618 * Create a simple filter effect with custom bicubic coefficients.
619 */ 619 */
620 static GrFragmentProcessor* Create(GrContext *context, const SkRect& rect, f loat sigma) { 620 static GrFragmentProcessor* Create(GrContext *context, const SkRect& rect, f loat sigma) {
621 GrTexture *blurProfileTexture = NULL; 621 GrTexture *blurProfileTexture = NULL;
622 int doubleProfileSize = SkScalarCeilToInt(12*sigma); 622 int doubleProfileSize = SkScalarCeilToInt(12*sigma);
623 623
624 if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.heigh t()) { 624 if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.heigh t()) {
625 // if the blur sigma is too large so the gaussian overlaps the whole 625 // if the blur sigma is too large so the gaussian overlaps the whole
626 // rect in either direction, fall back to CPU path for now. 626 // rect in either direction, fall back to CPU path for now.
627 627
628 return NULL; 628 return NULL;
629 } 629 }
630 630
631 bool createdBlurProfileTexture = CreateBlurProfileTexture(context, sigma , &blurProfileTexture); 631 bool createdBlurProfileTexture = CreateBlurProfileTexture(context, sigma , &blurProfileTexture);
632 SkAutoTUnref<GrTexture> hunref(blurProfileTexture); 632 SkAutoTUnref<GrTexture> hunref(blurProfileTexture);
633 if (!createdBlurProfileTexture) { 633 if (!createdBlurProfileTexture) {
634 return NULL; 634 return NULL;
635 } 635 }
636 return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture)); 636 return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture));
637 } 637 }
638 638
639 const SkRect& getRect() const { return fRect; } 639 const SkRect& getRect() const { return fRect; }
640 float getSigma() const { return fSigma; } 640 float getSigma() const { return fSigma; }
641 641
642 private: 642 private:
643 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile); 643 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile);
644 bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; 644 bool onIsEqual(const GrFragmentProcessor&) const override;
645 645
646 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; 646 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
647 647
648 static bool CreateBlurProfileTexture(GrContext *context, float sigma, 648 static bool CreateBlurProfileTexture(GrContext *context, float sigma,
649 GrTexture **blurProfileTexture); 649 GrTexture **blurProfileTexture);
650 650
651 SkRect fRect; 651 SkRect fRect;
652 float fSigma; 652 float fSigma;
653 GrTextureAccess fBlurProfileAccess; 653 GrTextureAccess fBlurProfileAccess;
654 654
655 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 655 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
656 656
657 typedef GrFragmentProcessor INHERITED; 657 typedef GrFragmentProcessor INHERITED;
658 }; 658 };
659 659
660 class GrGLRectBlurEffect : public GrGLFragmentProcessor { 660 class GrGLRectBlurEffect : public GrGLFragmentProcessor {
661 public: 661 public:
662 GrGLRectBlurEffect(const GrProcessor&) {} 662 GrGLRectBlurEffect(const GrProcessor&) {}
663 virtual void emitCode(GrGLFPBuilder*, 663 virtual void emitCode(GrGLFPBuilder*,
664 const GrFragmentProcessor&, 664 const GrFragmentProcessor&,
665 const char* outputColor, 665 const char* outputColor,
666 const char* inputColor, 666 const char* inputColor,
667 const TransformedCoordsArray&, 667 const TransformedCoordsArray&,
668 const TextureSamplerArray&) SK_OVERRIDE; 668 const TextureSamplerArray&) override;
669 669
670 void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; 670 void setData(const GrGLProgramDataManager&, const GrProcessor&) override;
671 671
672 private: 672 private:
673 typedef GrGLProgramDataManager::UniformHandle UniformHandle; 673 typedef GrGLProgramDataManager::UniformHandle UniformHandle;
674 674
675 UniformHandle fProxyRectUniform; 675 UniformHandle fProxyRectUniform;
676 UniformHandle fProfileSizeUniform; 676 UniformHandle fProfileSizeUniform;
677 677
678 typedef GrGLFragmentProcessor INHERITED; 678 typedef GrGLFragmentProcessor INHERITED;
679 }; 679 };
680 680
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, i nverse); 869 context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, i nverse);
870 return true; 870 return true;
871 } 871 }
872 872
873 class GrRRectBlurEffect : public GrFragmentProcessor { 873 class GrRRectBlurEffect : public GrFragmentProcessor {
874 public: 874 public:
875 875
876 static GrFragmentProcessor* Create(GrContext* context, float sigma, const Sk RRect&); 876 static GrFragmentProcessor* Create(GrContext* context, float sigma, const Sk RRect&);
877 877
878 virtual ~GrRRectBlurEffect() {}; 878 virtual ~GrRRectBlurEffect() {};
879 const char* name() const SK_OVERRIDE { return "GrRRectBlur"; } 879 const char* name() const override { return "GrRRectBlur"; }
880 880
881 const SkRRect& getRRect() const { return fRRect; } 881 const SkRRect& getRRect() const { return fRRect; }
882 float getSigma() const { return fSigma; } 882 float getSigma() const { return fSigma; }
883 883
884 virtual void getGLProcessorKey(const GrGLCaps& caps, 884 virtual void getGLProcessorKey(const GrGLCaps& caps,
885 GrProcessorKeyBuilder* b) const SK_OVERRIDE; 885 GrProcessorKeyBuilder* b) const override;
886 886
887 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; 887 GrGLFragmentProcessor* createGLInstance() const override;
888 888
889 private: 889 private:
890 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture); 890 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture);
891 891
892 bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE; 892 bool onIsEqual(const GrFragmentProcessor& other) const override;
893 893
894 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; 894 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
895 895
896 SkRRect fRRect; 896 SkRRect fRRect;
897 float fSigma; 897 float fSigma;
898 GrTextureAccess fNinePatchAccess; 898 GrTextureAccess fNinePatchAccess;
899 899
900 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 900 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
901 901
902 typedef GrFragmentProcessor INHERITED; 902 typedef GrFragmentProcessor INHERITED;
903 }; 903 };
904 904
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 1013
1014 class GrGLRRectBlurEffect : public GrGLFragmentProcessor { 1014 class GrGLRRectBlurEffect : public GrGLFragmentProcessor {
1015 public: 1015 public:
1016 GrGLRRectBlurEffect(const GrProcessor&) {} 1016 GrGLRRectBlurEffect(const GrProcessor&) {}
1017 1017
1018 virtual void emitCode(GrGLFPBuilder*, 1018 virtual void emitCode(GrGLFPBuilder*,
1019 const GrFragmentProcessor&, 1019 const GrFragmentProcessor&,
1020 const char* outputColor, 1020 const char* outputColor,
1021 const char* inputColor, 1021 const char* inputColor,
1022 const TransformedCoordsArray&, 1022 const TransformedCoordsArray&,
1023 const TextureSamplerArray&) SK_OVERRIDE; 1023 const TextureSamplerArray&) override;
1024 1024
1025 void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; 1025 void setData(const GrGLProgramDataManager&, const GrProcessor&) override;
1026 1026
1027 private: 1027 private:
1028 GrGLProgramDataManager::UniformHandle fProxyRectUniform; 1028 GrGLProgramDataManager::UniformHandle fProxyRectUniform;
1029 GrGLProgramDataManager::UniformHandle fCornerRadiusUniform; 1029 GrGLProgramDataManager::UniformHandle fCornerRadiusUniform;
1030 GrGLProgramDataManager::UniformHandle fBlurRadiusUniform; 1030 GrGLProgramDataManager::UniformHandle fBlurRadiusUniform;
1031 typedef GrGLFragmentProcessor INHERITED; 1031 typedef GrGLFragmentProcessor INHERITED;
1032 }; 1032 };
1033 1033
1034 void GrGLRRectBlurEffect::emitCode(GrGLFPBuilder* builder, 1034 void GrGLRRectBlurEffect::emitCode(GrGLFPBuilder* builder,
1035 const GrFragmentProcessor&, 1035 const GrFragmentProcessor&,
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 } else { 1265 } else {
1266 str->append("None"); 1266 str->append("None");
1267 } 1267 }
1268 str->append("))"); 1268 str->append("))");
1269 } 1269 }
1270 #endif 1270 #endif
1271 1271
1272 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1272 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1273 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1273 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1274 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1274 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode_gpu.cpp ('k') | src/effects/SkColorCubeFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698