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

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

Issue 1674673002: Alter SkXfermode's asFragmentProcessor & asXPFactory contracts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix unit test bug Created 4 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 | « include/client/android/SkPixelXorXfermode.h ('k') | include/effects/SkXfermodeImageFilter.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 /* 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 9
10 #ifndef SkXfermode_DEFINED 10 #ifndef SkXfermode_DEFINED
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 * that will be given to the xfer mode. 186 * that will be given to the xfer mode.
187 */ 187 */
188 virtual bool isOpaque(SrcColorOpacity opacityType) const; 188 virtual bool isOpaque(SrcColorOpacity opacityType) const;
189 189
190 /** 190 /**
191 * The same as calling xfermode->isOpaque(...), except that this also check s if 191 * The same as calling xfermode->isOpaque(...), except that this also check s if
192 * the xfermode is NULL, and if so, treats it as kSrcOver_Mode. 192 * the xfermode is NULL, and if so, treats it as kSrcOver_Mode.
193 */ 193 */
194 static bool IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType); 194 static bool IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType);
195 195
196 /** Used to do in-shader blending between two colors computed in the shader via a 196 #if SK_SUPPORT_GPU
197 GrFragmentProcessor. The input to the returned FP is the src color. The dst color is 197 /** Used by the SkXfermodeImageFilter to blend two colors via a GrFragmentPr ocessor.
198 provided by the dst param which becomes a child FP of the returned FP. I f the params are 198 The input to the returned FP is the src color. The dst color is
199 null then this is just a query of whether the SkXfermode could support t his functionality. 199 provided by the dst param which becomes a child FP of the returned FP.
200 It is legal for the function to succeed but return a null output. This i ndicates that 200 It is legal for the function to return a null output. This indicates tha t
201 the output of the blend is simply the src color. 201 the output of the blend is simply the src color.
202 */ 202 */
203 virtual bool asFragmentProcessor(const GrFragmentProcessor** output, 203 virtual const GrFragmentProcessor* getFragmentProcessorForImageFilter(
204 const GrFragmentProcessor* dst) const; 204 const GrFragmentProc essor* dst) const;
205 205
206 /** A subclass may implement this factory function to work with the GPU back end. It is legal 206 /** A subclass must implement this factory function to work with the GPU bac kend.
207 to call this with xpf NULL to simply test the return value. If xpf is non- NULL then the 207 The xfermode will return a factory for which the caller will get a ref. It is up
208 xfermode may optionally allocate a factory to return to the caller as *xpf . The caller 208 to the caller to install it. XferProcessors cannot use a background text ure.
209 will install it and own a ref to it. Since the xfermode may or may not ass ign *xpf, the
210 caller should set *xpf to NULL beforehand. XferProcessors cannot use a bac kground texture.
211 */ 209 */
212 virtual bool asXPFactory(GrXPFactory** xpf) const; 210 virtual GrXPFactory* asXPFactory() const;
213 211 #endif
214 /** Returns true if the xfermode can be expressed as an xfer processor facto ry (xpFactory).
215 This helper calls the asXPFactory() virtual. If the xfermode is NULL, it i s treated as
216 kSrcOver_Mode. It is legal to call this with xpf param NULL to simply test the return value.
217 */
218 static inline bool AsXPFactory(SkXfermode* xfermode, GrXPFactory** xpf) {
219 if (nullptr == xfermode) {
220 if (xpf) {
221 *xpf = nullptr;
222 }
223 return true;
224 }
225 return xfermode->asXPFactory(xpf);
226 }
227 212
228 SK_TO_STRING_PUREVIRT() 213 SK_TO_STRING_PUREVIRT()
229 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 214 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
230 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) 215 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode)
231 216
232 enum PM4fFlags { 217 enum PM4fFlags {
233 kSrcIsOpaque_PM4fFlag = 1 << 0, 218 kSrcIsOpaque_PM4fFlag = 1 << 0,
234 kDstIsSRGB_PM4fFlag = 1 << 1, 219 kDstIsSRGB_PM4fFlag = 1 << 1,
235 }; 220 };
236 struct PM4fState { 221 struct PM4fState {
(...skipping 23 matching lines...) Expand all
260 245
261 private: 246 private:
262 enum { 247 enum {
263 kModeCount = kLastMode + 1 248 kModeCount = kLastMode + 1
264 }; 249 };
265 250
266 typedef SkFlattenable INHERITED; 251 typedef SkFlattenable INHERITED;
267 }; 252 };
268 253
269 #endif 254 #endif
OLDNEW
« no previous file with comments | « include/client/android/SkPixelXorXfermode.h ('k') | include/effects/SkXfermodeImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698