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

Side by Side Diff: include/core/SkColorFilter.h

Issue 1827433002: Reland of [2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | « gyp/skia_for_android_framework_defines.gypi ('k') | include/core/SkPaint.h » ('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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkColorFilter_DEFINED 8 #ifndef SkColorFilter_DEFINED
9 #define SkColorFilter_DEFINED 9 #define SkColorFilter_DEFINED
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 */ 79 */
80 virtual uint32_t getFlags() const { return 0; } 80 virtual uint32_t getFlags() const { return 0; }
81 81
82 /** 82 /**
83 * If this subclass can optimally createa composition with the inner filter , return it as 83 * If this subclass can optimally createa composition with the inner filter , return it as
84 * a new filter (which the caller must unref() when it is done). If no such optimization 84 * a new filter (which the caller must unref() when it is done). If no such optimization
85 * is known, return NULL. 85 * is known, return NULL.
86 * 86 *
87 * e.g. result(color) == this_filter(inner(color)) 87 * e.g. result(color) == this_filter(inner(color))
88 */ 88 */
89 virtual SkColorFilter* newComposed(const SkColorFilter* /*inner*/) const { r eturn NULL; } 89 virtual sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter>) const { retu rn nullptr; }
90 90
91 /** 91 /**
92 * Apply this colorfilter to the specified SkColor. This routine handles 92 * Apply this colorfilter to the specified SkColor. This routine handles
93 * converting to SkPMColor, calling the filter, and then converting back 93 * converting to SkPMColor, calling the filter, and then converting back
94 * to SkColor. This method is not virtual, but will call filterSpan() 94 * to SkColor. This method is not virtual, but will call filterSpan()
95 * which is virtual. 95 * which is virtual.
96 */ 96 */
97 SkColor filterColor(SkColor) const; 97 SkColor filterColor(SkColor) const;
98 98
99 /** 99 /**
100 * Filters a single color. 100 * Filters a single color.
101 */ 101 */
102 SkColor4f filterColor4f(const SkColor4f&) const; 102 SkColor4f filterColor4f(const SkColor4f&) const;
103 103
104 /** Create a colorfilter that uses the specified color and mode. 104 /** Create a colorfilter that uses the specified color and mode.
105 If the Mode is DST, this function will return NULL (since that 105 If the Mode is DST, this function will return NULL (since that
106 mode will have no effect on the result). 106 mode will have no effect on the result).
107 @param c The source color used with the specified mode 107 @param c The source color used with the specified mode
108 @param mode The xfermode mode that is applied to each color in 108 @param mode The xfermode mode that is applied to each color in
109 the colorfilter's filterSpan[16,32] methods 109 the colorfilter's filterSpan[16,32] methods
110 @return colorfilter object that applies the src color and mode, 110 @return colorfilter object that applies the src color and mode,
111 or NULL if the mode will have no effect. 111 or NULL if the mode will have no effect.
112 */ 112 */
113 static SkColorFilter* CreateModeFilter(SkColor c, SkXfermode::Mode mode); 113 static sk_sp<SkColorFilter> MakeModeFilter(SkColor c, SkXfermode::Mode mode) ;
114 114
115 /** Construct a colorfilter whose effect is to first apply the inner filter and then apply 115 /** Construct a colorfilter whose effect is to first apply the inner filter and then apply
116 * the outer filter to the result of the inner's. 116 * the outer filter to the result of the inner's.
117 * The reference counts for outer and inner are incremented. 117 * The reference counts for outer and inner are incremented.
118 * 118 *
119 * Due to internal limits, it is possible that this will return NULL, so th e caller must 119 * Due to internal limits, it is possible that this will return NULL, so th e caller must
120 * always check. 120 * always check.
121 */ 121 */
122 static SkColorFilter* CreateComposeFilter(SkColorFilter* outer, SkColorFilte r* inner); 122 static sk_sp<SkColorFilter> MakeComposeFilter(sk_sp<SkColorFilter> outer,
123 sk_sp<SkColorFilter> inner);
123 124
124 /** Construct a color filter that transforms a color by a 4x5 matrix. The ma trix is in row- 125 /** Construct a color filter that transforms a color by a 4x5 matrix. The ma trix is in row-
125 * major order and the translation column is specified in unnormalized, 0.. .255, space. 126 * major order and the translation column is specified in unnormalized, 0.. .255, space.
126 */ 127 */
127 static SkColorFilter* CreateMatrixFilterRowMajor255(const SkScalar array[20] ); 128 static sk_sp<SkColorFilter> MakeMatrixFilterRowMajor255(const SkScalar array [20]);
129
130 #ifdef SK_SUPPORT_LEGACY_COLORFILTER_PTR
131 static SkColorFilter* CreateModeFilter(SkColor c, SkXfermode::Mode mode) {
132 return MakeModeFilter(c, mode).release();
133 }
134 static SkColorFilter* CreateComposeFilter(SkColorFilter* outer, SkColorFilte r* inner) {
135 return MakeComposeFilter(sk_ref_sp(outer), sk_ref_sp(inner)).release();
136 }
137 static SkColorFilter* CreateMatrixFilterRowMajor255(const SkScalar array[20] ) {
138 return MakeMatrixFilterRowMajor255(array).release();
139 }
140 virtual SkColorFilter* newComposed(const SkColorFilter* inner) const {
141 return this->makeComposed(sk_ref_sp(const_cast<SkColorFilter*>(inner))). release();
142 }
143 #endif
128 144
129 /** 145 /**
130 * A subclass may implement this factory function to work with the GPU back end. It returns 146 * A subclass may implement this factory function to work with the GPU back end. It returns
131 * a GrFragmentProcessor that implemets the color filter in GPU shader code . 147 * a GrFragmentProcessor that implemets the color filter in GPU shader code .
132 * 148 *
133 * The fragment processor receives a premultiplied input color and produces a premultiplied 149 * The fragment processor receives a premultiplied input color and produces a premultiplied
134 * output color. 150 * output color.
135 * 151 *
136 * A null return indicates that the color filter isn't implemented for the GPU backend. 152 * A null return indicates that the color filter isn't implemented for the GPU backend.
137 */ 153 */
(...skipping 21 matching lines...) Expand all
159 * 175 *
160 * e.g. compose(filter, compose(compose(filter, filter), filter)) --> 4 176 * e.g. compose(filter, compose(compose(filter, filter), filter)) --> 4
161 */ 177 */
162 virtual int privateComposedFilterCount() const { return 1; } 178 virtual int privateComposedFilterCount() const { return 1; }
163 friend class SkComposeColorFilter; 179 friend class SkComposeColorFilter;
164 180
165 typedef SkFlattenable INHERITED; 181 typedef SkFlattenable INHERITED;
166 }; 182 };
167 183
168 #endif 184 #endif
OLDNEW
« no previous file with comments | « gyp/skia_for_android_framework_defines.gypi ('k') | include/core/SkPaint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698