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

Side by Side Diff: include/gpu/GrXferProcessor.h

Issue 751283002: Add XferProcessor factory in GrPaint and GrDrawState. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update gyp 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
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrXferProcessor_DEFINED
9 #define GrXferProcessor_DEFINED
10
11 #include "GrColor.h"
12 #include "GrFragmentProcessor.h"
13 #include "GrTypes.h"
14 #include "SkXfermode.h"
15
16 class GrDrawState;
17
18 /**
19 * A GrGeomteryProcessor is used to perform computation in the vertex shader and
20 * add support for custom vertex attributes. A GrGemeotryProcessor is typically
21 * tied to the code that does a specific type of high-level primitive rendering
22 * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw is
23 * specified using GrDrawState. There can only be one geometry processor active for
24 * a draw. The custom vertex attributes required by the geometry processor must be
25 * added to the vertex attribute array specified on the GrDrawState.
26 * GrGeometryProcessor subclasses should be immutable after construction.
27 */
joshualitt 2014/11/26 20:10:34 Comment refers to GP
egdaniel 2014/12/01 18:18:24 Done.
28 class GrXferProcessor : public GrFragmentProcessor {
29 public:
30 /** Returns true if this and other prceossor conservatively draw identically . It can only return
31 true when the two prceossor are of the same subclass (i.e. they return t he same object from
bsalomon 2014/11/26 21:02:44 Does this comment apply? Will these have a backend
egdaniel 2014/12/01 18:18:24 In this current version the XP is derived from a f
32 from getFactory()).
33
34 A return value of true from isEqual() should not be used to test whether the prceossor would
35 generate the same shader code. To test for identical code generation use the prceossor' keys
36 computed by the GrBackendProcessorFactory. */
37 bool isEqual(const GrXferProcessor& that) const {
bsalomon 2014/11/26 21:02:45 non-virtual override?
egdaniel 2014/12/01 18:18:24 Code deleted since coeff's have been moved off bas
38 /*
bsalomon 2014/11/26 21:02:45 ?
egdaniel 2014/12/01 18:18:24 Done.
39 if (fSrcBlend != that.fSrcBlend || fDstBlend != that.fDstBlend) {
40 return false;
41 }
42 */
joshualitt 2014/11/26 20:10:34 Is this code supposed to be commented out?
egdaniel 2014/12/01 18:18:24 nope
43 return this->onIsEqual(that);
44 }
45
46 protected:
47 GrXferProcessor() : fSrcBlend(kOne_GrBlendCoeff), fDstBlend(kZero_GrBlendCoe ff) {}
48
49 GrXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend)
50 : fSrcBlend(srcBlend), fDstBlend(dstBlend) {}
51
52 private:
53 virtual bool onIsEqual(const GrFragmentProcessor&) const = 0;
54
55 GrBlendCoeff fSrcBlend;
56 GrBlendCoeff fDstBlend;
57
58 typedef GrFragmentProcessor INHERITED;
59 };
60
61 class GrXPFactory : public GrProgramElement {
62 public:
63 virtual const GrXferProcessor* createXferProcessor() const = 0;
bsalomon 2014/11/26 21:02:44 no inputs?
egdaniel 2014/12/01 18:18:24 In this cl it has none, but in the next DrawState
64
65 virtual bool supportsLCDText(const GrDrawState&) const { return false; }
bsalomon 2014/11/26 21:02:44 Can we call it LCDCoverage or RGBCoverage rather t
egdaniel 2014/12/01 18:18:24 Done.
66
joshualitt 2014/11/26 20:10:34 Is there a way to name this more generally? ie, w
67 virtual bool canApplyCoverage(const GrDrawState&) const { return false; }
bsalomon 2014/11/26 21:02:44 This and the above need some clear documentation a
egdaniel 2014/12/01 18:18:24 Removed for now since it is unused in this CL. Wil
68
69 protected:
70 GrXPFactory()
71 : INHERITED(), fSrc(kOne_GrBlendCoeff), fDst(kZero_GrBlendCoeff) {}
72
73 GrXPFactory(GrBlendCoeff src, GrBlendCoeff dst)
74 : fSrc(src), fDst(dst) {}
75
76 GrBlendCoeff fSrc;
77 GrBlendCoeff fDst;
78
79 private:
80 typedef GrProgramElement INHERITED;
81 };
82
83 ///////////////////////////////////////////////////////////////////////////////
84
85 /**
86 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called
87 * at global destruction time. NAME will be the name of the created GrProcessor.
88 */
89 #define GR_CREATE_STATIC_XP_FACTORY(NAME, XPF_CLASS, ARGS) \
bsalomon 2014/11/26 21:02:44 You must be coming from a really old revision. The
egdaniel 2014/12/01 18:18:24 This isn't a GrProcessor subclass, it is for GrXPF
bsalomon 2014/12/01 19:24:39 Acknowledged.
90 static SkAlignedSStorage<sizeof(XPF_CLASS)> g_##NAME##_Storage; \
91 static GrXPFactory* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), XPF_CLAS S, ARGS); \
92 static SkAutoTDestroy<GrXPFactory> NAME##_ad(NAME);
93
94 #endif
95
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698