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

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

Issue 751283002: Add XferProcessor factory in GrPaint and GrDrawState. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: capitalization Created 6 years 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
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 GrFragmentProcessor; 16 class GrFragmentProcessor;
17 class GrTexture; 17 class GrTexture;
18 class GrXPFactory;
18 class SkString; 19 class SkString;
19 20
20 /** \class SkXfermode 21 /** \class SkXfermode
21 * 22 *
22 * SkXfermode is the base class for objects that are called to implement custom 23 * SkXfermode is the base class for objects that are called to implement custom
23 * "transfer-modes" in the drawing pipeline. The static function Create(Modes) 24 * "transfer-modes" in the drawing pipeline. The static function Create(Modes)
24 * can be called to return an instance of any of the predefined subclasses as 25 * can be called to return an instance of any of the predefined subclasses as
25 * specified in the Modes enum. When an SkXfermode is assigned to an SkPaint, 26 * specified in the Modes enum. When an SkXfermode is assigned to an SkPaint,
26 * then objects drawn with that paint have the xfermode applied. 27 * then objects drawn with that paint have the xfermode applied.
27 * 28 *
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 192
192 /** A subclass may implement this factory function to work with the GPU back end. It is legal 193 /** A subclass may implement this factory function to work with the GPU back end. It is legal
193 to call this with all params NULL to simply test the return value. If ef fect is non-NULL 194 to call this with all params NULL to simply test the return value. If ef fect is non-NULL
194 then the xfermode may optionally allocate an effect to return and the ca ller as *effect. 195 then the xfermode may optionally allocate an effect to return and the ca ller as *effect.
195 The caller will install it and own a ref to it. Since the xfermode may o r may not assign 196 The caller will install it and own a ref to it. Since the xfermode may o r may not assign
196 *effect, the caller should set *effect to NULL beforehand. background sp ecifies the 197 *effect, the caller should set *effect to NULL beforehand. background sp ecifies the
197 texture to use as the background for compositing, and should be accessed in the effect's 198 texture to use as the background for compositing, and should be accessed in the effect's
198 fragment shader. If NULL, the effect should request access to destinatio n color 199 fragment shader. If NULL, the effect should request access to destinatio n color
199 (setWillReadDstColor()), and use that in the fragment shader (builder->d stColor()). 200 (setWillReadDstColor()), and use that in the fragment shader (builder->d stColor()).
200 */ 201 */
202 // TODO: Once all custom xp's have been created the background parameter wil l be required here.
203 // We will always use the XPProcessor if there is not background texture and the fragment if
bsalomon 2014/12/01 19:24:39 XPFactory?
egdaniel 2014/12/02 15:07:09 Done.
204 // there is one.
201 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* backgroun d = NULL) const; 205 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* backgroun d = NULL) const;
202 206
203 /** Returns true if the xfermode can be expressed as coeffs (src, dst), or a s an effect 207 /** A subclass may implement this factory function to work with the GPU back end. It is legal
204 (effect). This helper calls the asCoeff() and asFragmentProcessor() virt uals. If the 208 to call this with xpf NULL to simply test the return value. If factory i s non-NULL
bsalomon 2014/12/01 19:24:39 My mistake before, I think it should be "If xpf is
egdaniel 2014/12/02 15:07:09 Done.
205 xfermode is NULL, it is treated as kSrcOver_Mode. It is legal to call th is with all params 209 then the xfermode may optionally allocate a factory to return and the ca ller as *xpf.
206 NULL to simply test the return value. effect, src, and dst must all be NULL or all 210 The caller will install it and own a ref to it. Since the xfermode may o r may not assign
207 non-NULL. 211 *xpf, the caller should set *xpf to NULL beforehand. XP's cannot use a b ackground texture
212 since they have no coord transforms.
208 */ 213 */
209 static bool asFragmentProcessorOrCoeff(SkXfermode*, GrFragmentProcessor**, C oeff* src, 214 virtual bool asXPFactory(GrXPFactory** xpf) const;
210 Coeff* dst, GrTexture* background = N ULL); 215
216 /** Returns true if the xfermode can be expressed as an xfer processor facto ry (xpFactory),
217 or a fragment processor. This helper calls the asCoeff(), asXPFactory(),
218 and asFragmentProcessor() virtuals. If the xfermode is NULL, it is treat ed as kSrcOver_Mode.
219 It is legal to call this with all params NULL to simply test the return value.
220 fp, xpf, src, and dst must all be NULL or all non-NULL.
221 */
222 static bool AsFragmentProcessorOrXPFactory(SkXfermode*, GrFragmentProcessor* *,
bsalomon 2014/12/01 19:24:39 Can't wait for this to die. AFAIK there is only on
egdaniel 2014/12/02 15:07:09 Done.
223 GrXPFactory**, Coeff* src, Coeff* dst,
224 GrTexture* background = NULL);
211 225
212 SK_TO_STRING_PUREVIRT() 226 SK_TO_STRING_PUREVIRT()
213 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 227 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
214 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) 228 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode)
215 229
216 protected: 230 protected:
217 SkXfermode() {} 231 SkXfermode() {}
218 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING 232 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
219 explicit SkXfermode(SkReadBuffer& rb) : SkFlattenable(rb) {} 233 explicit SkXfermode(SkReadBuffer& rb) : SkFlattenable(rb) {}
220 #endif 234 #endif
(...skipping 10 matching lines...) Expand all
231 245
232 private: 246 private:
233 enum { 247 enum {
234 kModeCount = kLastMode + 1 248 kModeCount = kLastMode + 1
235 }; 249 };
236 250
237 typedef SkFlattenable INHERITED; 251 typedef SkFlattenable INHERITED;
238 }; 252 };
239 253
240 #endif 254 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698