OLD | NEW |
---|---|
(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 GrXferProcessor is used to combine the output of the color and coverage sta ges into one or two | |
bsalomon
2014/12/01 19:24:39
I think this comment will be confusing to someone
egdaniel
2014/12/02 15:07:09
Done.
| |
20 * output colors (two if dual source is enabled). All blending is handled intern ally inside the xfer | |
21 * processor and thus the client code can be oblivious to how the blending works . A GrXP is never | |
22 * created directly by a client. Instead, a GrXPFactory class is used. At the ti me of snapping the | |
23 * draw state and creating optimizations, the XPFactory will create an XP. This XP also serves as a | |
24 * feedback loop into the OptDrawState, informing the OptDrawState what addition al optimizations to | |
25 * perform based on blending. The XP does not have local coords and will never r ead the fragment | |
26 * position. However, it can possibly read the destination color when doing blen ding. The final draw | |
27 * state will always have one and only one GrXferProcessor. | |
28 */ | |
29 class GrXferProcessor : public GrFragmentProcessor { | |
30 private: | |
31 virtual bool onIsEqual(const GrFragmentProcessor&) const = 0; | |
bsalomon
2014/12/01 19:24:40
pure virtual override?
egdaniel
2014/12/02 15:07:09
because we all love code that does nothing of cour
| |
32 | |
33 typedef GrFragmentProcessor INHERITED; | |
34 }; | |
35 | |
36 class GrXPFactory : public GrProgramElement { | |
37 public: | |
38 virtual const GrXferProcessor* createXferProcessor() const = 0; | |
39 | |
40 virtual bool supportsRGBCoverage(const GrDrawState&) const { return false; } | |
bsalomon
2014/12/01 19:24:40
comment about what this means?
Also, GrDrawState
egdaniel
2014/12/02 15:07:09
Done.
| |
41 | |
42 private: | |
43 typedef GrProgramElement INHERITED; | |
44 }; | |
45 | |
46 /////////////////////////////////////////////////////////////////////////////// | |
47 | |
48 /** | |
49 * This creates a factory outside of the effect memory pool. The factory's destr uctor will be called | |
50 * at global destruction time. NAME will be the name of the created GrXPFactory. | |
51 */ | |
52 #define GR_CREATE_STATIC_XP_FACTORY(NAME, XPF_CLASS, ARGS) \ | |
53 static SkAlignedSStorage<sizeof(XPF_CLASS)> g_##NAME##_Storage; \ | |
54 static GrXPFactory* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), XPF_CLAS S, ARGS); \ | |
55 static SkAutoTDestroy<GrXPFactory> NAME##_ad(NAME); | |
56 | |
57 #endif | |
58 | |
OLD | NEW |