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

Side by Side Diff: src/gpu/effects/GrCustomXfermodePriv.h

Issue 852203003: Add Xfer Processor for GrCustomXfermodes (Closed) Base URL: https://skia.googlesource.com/skia.git@xferMover
Patch Set: Fix build Created 5 years, 11 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 | « src/gpu/effects/GrCustomXfermode.cpp ('k') | no next file » | 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 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrCustomXfermodePriv_DEFINED 8 #ifndef GrCustomXfermodePriv_DEFINED
9 #define GrCustomXfermodePriv_DEFINED 9 #define GrCustomXfermodePriv_DEFINED
10 10
11 #include "GrCoordTransform.h" 11 #include "GrCoordTransform.h"
12 #include "GrFragmentProcessor.h" 12 #include "GrFragmentProcessor.h"
13 #include "GrTextureAccess.h" 13 #include "GrTextureAccess.h"
14 #include "GrXferProcessor.h"
14 #include "SkXfermode.h" 15 #include "SkXfermode.h"
15 16
16 class GrGLCaps; 17 class GrGLCaps;
17 class GrGLFragmentProcessor; 18 class GrGLFragmentProcessor;
18 class GrInvariantOutput; 19 class GrInvariantOutput;
19 class GrProcessorKeyBuilder; 20 class GrProcessorKeyBuilder;
20 class GrTexture; 21 class GrTexture;
21 22
22 /////////////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////////////
23 // Fragment Processor 24 // Fragment Processor
(...skipping 19 matching lines...) Expand all
43 44
44 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 45 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
45 46
46 SkXfermode::Mode fMode; 47 SkXfermode::Mode fMode;
47 GrCoordTransform fBackgroundTransform; 48 GrCoordTransform fBackgroundTransform;
48 GrTextureAccess fBackgroundAccess; 49 GrTextureAccess fBackgroundAccess;
49 50
50 typedef GrFragmentProcessor INHERITED; 51 typedef GrFragmentProcessor INHERITED;
51 }; 52 };
52 53
54 ///////////////////////////////////////////////////////////////////////////////
55 // Xfer Processor
56 ///////////////////////////////////////////////////////////////////////////////
57
58 class GrCustomXP : public GrXferProcessor {
59 public:
60 static GrXferProcessor* Create(SkXfermode::Mode mode) {
61 if (!GrCustomXfermode::IsSupportedMode(mode)) {
62 return NULL;
63 } else {
64 return SkNEW_ARGS(GrCustomXP, (mode));
65 }
66 }
67
68 ~GrCustomXP() SK_OVERRIDE {};
69
70 const char* name() const SK_OVERRIDE { return "Custom Xfermode"; }
71
72 void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const SK_OVERRIDE;
73
74 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE;
75
76 bool hasSecondaryOutput() const SK_OVERRIDE { return false; }
77
78 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI,
79 const GrProcOptInfo& coveragePOI,
80 bool doesStencilWrite,
81 GrColor* overrideColor,
82 const GrDrawTargetCaps& caps) SK_ OVERRIDE;
83
84 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE {
85 blendInfo->fSrcBlend = kOne_GrBlendCoeff;
86 blendInfo->fDstBlend = kZero_GrBlendCoeff;
87 blendInfo->fBlendConstant = 0;
88 }
89
90 SkXfermode::Mode mode() const { return fMode; }
91
92 private:
93 GrCustomXP(SkXfermode::Mode mode);
94
95 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE;
96
97 SkXfermode::Mode fMode;
98
99 typedef GrXferProcessor INHERITED;
100 };
101
102 ///////////////////////////////////////////////////////////////////////////////
103
104 class GrCustomXPFactory : public GrXPFactory {
105 public:
106 GrCustomXPFactory(SkXfermode::Mode mode);
107
108 GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI,
109 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE {
110 return GrCustomXP::Create(fMode);
111 }
112
113 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const SK_OVERRIDE {
114 return true;
115 }
116
117 bool canApplyCoverage(const GrProcOptInfo& colorPOI,
118 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE {
119 return true;
120 }
121
122 bool canTweakAlphaForCoverage() const SK_OVERRIDE {
123 return false;
124 }
125
126 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI,
127 GrXPFactory::InvariantOutput*) const SK_OVERRIDE;
128
129 bool willReadDst(const GrProcOptInfo& colorPOI,
130 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE {
131 return true;
132 }
133
134 private:
135 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE {
136 const GrCustomXPFactory& xpf = xpfBase.cast<GrCustomXPFactory>();
137 return fMode == xpf.fMode;
138 }
139
140 GR_DECLARE_XP_FACTORY_TEST;
141
142 SkXfermode::Mode fMode;
143
144 typedef GrXPFactory INHERITED;
145 };
53 #endif 146 #endif
54 147
OLDNEW
« no previous file with comments | « src/gpu/effects/GrCustomXfermode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698