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

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

Issue 13097006: Add interface to SkXfermode to return a GrEffect and blend coeffs. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Add SkGpuDevice.cpp Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/core/SkXfermode.cpp » ('j') | src/core/SkXfermode.cpp » ('J')
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
11 #define SkXfermode_DEFINED 11 #define SkXfermode_DEFINED
12 12
13 #include "SkFlattenable.h" 13 #include "SkFlattenable.h"
14 #include "SkColor.h" 14 #include "SkColor.h"
15 15
16 class GrContext;
17 class GrEffectRef;
16 class SkString; 18 class SkString;
17 19
18 /** \class SkXfermode 20 /** \class SkXfermode
19 21
20 SkXfermode is the base class for objects that are called to implement custom 22 SkXfermode is the base class for objects that are called to implement custom
21 "transfer-modes" in the drawing pipeline. The static function Create(Modes) 23 "transfer-modes" in the drawing pipeline. The static function Create(Modes)
22 can be called to return an instance of any of the predefined subclasses as 24 can be called to return an instance of any of the predefined subclasses as
23 specified in the Modes enum. When an SkXfermode is assigned to an SkPaint, 25 specified in the Modes enum. When an SkXfermode is assigned to an SkPaint,
24 then objects drawn with that paint have the xfermode applied. 26 then objects drawn with that paint have the xfermode applied.
25 */ 27 */
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 clear zero zero 69 clear zero zero
68 src one zero 70 src one zero
69 dst zero one 71 dst zero one
70 srcover one isa 72 srcover one isa
71 dstover ida one 73 dstover ida one
72 */ 74 */
73 virtual bool asCoeff(Coeff* src, Coeff* dst) const; 75 virtual bool asCoeff(Coeff* src, Coeff* dst) const;
74 76
75 /** 77 /**
76 * The same as calling xfermode->asCoeff(..), except that this also checks 78 * The same as calling xfermode->asCoeff(..), except that this also checks
77 * if the xfermode is NULL, and if so, treats its as kSrcOver_Mode. 79 * if the xfermode is NULL, and if so, treats it as kSrcOver_Mode.
78 */ 80 */
79 static bool AsCoeff(const SkXfermode*, Coeff* src, Coeff* dst); 81 static bool AsCoeff(const SkXfermode*, Coeff* src, Coeff* dst);
80 82
81 /** List of predefined xfermodes. 83 /** List of predefined xfermodes.
82 The algebra for the modes uses the following symbols: 84 The algebra for the modes uses the following symbols:
83 Sa, Sc - source alpha and color 85 Sa, Sc - source alpha and color
84 Da, Dc - destination alpha and color (before compositing) 86 Da, Dc - destination alpha and color (before compositing)
85 [a, c] - Resulting (alpha, color) values 87 [a, c] - Resulting (alpha, color) values
86 For these equations, the colors are in premultiplied state. 88 For these equations, the colors are in premultiplied state.
87 If no xfermode is specified, kSrcOver is assumed. 89 If no xfermode is specified, kSrcOver is assumed.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 131
130 /** 132 /**
131 * If the xfermode is one of the modes in the Mode enum, then asMode() 133 * If the xfermode is one of the modes in the Mode enum, then asMode()
132 * returns true and sets (if not null) mode accordingly. Otherwise it 134 * returns true and sets (if not null) mode accordingly. Otherwise it
133 * returns false and ignores the mode parameter. 135 * returns false and ignores the mode parameter.
134 */ 136 */
135 virtual bool asMode(Mode* mode) const; 137 virtual bool asMode(Mode* mode) const;
136 138
137 /** 139 /**
138 * The same as calling xfermode->asMode(mode), except that this also checks 140 * The same as calling xfermode->asMode(mode), except that this also checks
139 * if the xfermode is NULL, and if so, treats its as kSrcOver_Mode. 141 * if the xfermode is NULL, and if so, treats it as kSrcOver_Mode.
140 */ 142 */
141 static bool AsMode(const SkXfermode*, Mode* mode); 143 static bool AsMode(const SkXfermode*, Mode* mode);
142 144
143 /** 145 /**
144 * Returns true if the xfermode claims to be the specified Mode. This works 146 * Returns true if the xfermode claims to be the specified Mode. This works
145 * correctly even if the xfermode is NULL (which equates to kSrcOver.) Thus 147 * correctly even if the xfermode is NULL (which equates to kSrcOver.) Thus
146 * you can say this without checking for a null... 148 * you can say this without checking for a null...
147 * 149 *
148 * If (SkXfermode::IsMode(paint.getXfermode(), 150 * If (SkXfermode::IsMode(paint.getXfermode(),
149 * SkXfermode::kDstOver_Mode)) { 151 * SkXfermode::kDstOver_Mode)) {
(...skipping 24 matching lines...) Expand all
174 * not representable as a pair of Coeffs, return false and ignore the 176 * not representable as a pair of Coeffs, return false and ignore the
175 * src and dst parameters. 177 * src and dst parameters.
176 */ 178 */
177 static bool ModeAsCoeff(Mode mode, Coeff* src, Coeff* dst); 179 static bool ModeAsCoeff(Mode mode, Coeff* src, Coeff* dst);
178 180
179 // DEPRECATED: call AsMode(...) 181 // DEPRECATED: call AsMode(...)
180 static bool IsMode(const SkXfermode* xfer, Mode* mode) { 182 static bool IsMode(const SkXfermode* xfer, Mode* mode) {
181 return AsMode(xfer, mode); 183 return AsMode(xfer, mode);
182 } 184 }
183 185
186 /** A subclass may implement this factory function to work with the GPU back end. It is legal
robertphillips 2013/03/27 18:12:09 will -> with
bsalomon 2013/03/27 18:39:42 Done.
187 to call this will all but the context param NULL to simply test the retu rn value. effect,
188 src, and dst must all be NULL or all non-NULL. If effect is non-NULL bef ore this function
189 is called then the xfermode may optionally allocate an effect to return and the caller will
190 install it and own a ref to it. If the function returns true then the sr c and dst coeffs
191 will be applied to the draw.
192 */
193 virtual bool asNewEffect(GrContext*, GrEffectRef** effect, Coeff* src, Coeff * dst) const;
194
195 /**
196 * The same as calling xfermode->asNewEffect(...), except that this also ch ecks if the xfermode
197 * is NULL, and if so, treats it as kSrcOver_Mode.
198 */
199 static bool AsNewEffect(SkXfermode*, GrContext*, GrEffectRef** effect, Coeff * src, Coeff* dst);
200
184 SkDEVCODE(virtual void toString(SkString* str) const = 0;) 201 SkDEVCODE(virtual void toString(SkString* str) const = 0;)
185 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 202 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
186 protected: 203 protected:
187 SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {} 204 SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {}
188 205
189 /** The default implementation of xfer32/xfer16/xferA8 in turn call this 206 /** The default implementation of xfer32/xfer16/xferA8 in turn call this
190 method, 1 color at a time (upscaled to a SkPMColor). The default 207 method, 1 color at a time (upscaled to a SkPMColor). The default
191 implmentation of this method just returns dst. If performance is 208 implmentation of this method just returns dst. If performance is
192 important, your subclass should override xfer32/xfer16/xferA8 directly. 209 important, your subclass should override xfer32/xfer16/xferA8 directly.
193 210
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 fProc = proc; 253 fProc = proc;
237 } 254 }
238 255
239 private: 256 private:
240 SkXfermodeProc fProc; 257 SkXfermodeProc fProc;
241 258
242 typedef SkXfermode INHERITED; 259 typedef SkXfermode INHERITED;
243 }; 260 };
244 261
245 #endif 262 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkXfermode.cpp » ('j') | src/core/SkXfermode.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698