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

Side by Side Diff: src/effects/SkArithmeticMode_gpu.h

Issue 885923002: Move DstCopy on gpu into the GrXferProcessor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Some clean up Created 5 years, 10 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
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 SkArithmeticMode_gpu_DEFINED 8 #ifndef SkArithmeticMode_gpu_DEFINED
9 #define SkArithmeticMode_gpu_DEFINED 9 #define SkArithmeticMode_gpu_DEFINED
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 12
13 #if SK_SUPPORT_GPU 13 #if SK_SUPPORT_GPU
14 14
15 #include "GrCoordTransform.h" 15 #include "GrCoordTransform.h"
16 #include "GrDrawTargetCaps.h"
16 #include "GrFragmentProcessor.h" 17 #include "GrFragmentProcessor.h"
17 #include "GrTextureAccess.h" 18 #include "GrTextureAccess.h"
18 #include "GrTypes.h" 19 #include "GrTypes.h"
19 #include "GrXferProcessor.h" 20 #include "GrXferProcessor.h"
20 21
21 class GrInvariantOutput; 22 class GrInvariantOutput;
22 class GrProcOptInfo; 23 class GrProcOptInfo;
23 class GrTexture; 24 class GrTexture;
24 25
25 /////////////////////////////////////////////////////////////////////////////// 26 ///////////////////////////////////////////////////////////////////////////////
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 66 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
66 typedef GrFragmentProcessor INHERITED; 67 typedef GrFragmentProcessor INHERITED;
67 }; 68 };
68 69
69 /////////////////////////////////////////////////////////////////////////////// 70 ///////////////////////////////////////////////////////////////////////////////
70 // Xfer Processor 71 // Xfer Processor
71 /////////////////////////////////////////////////////////////////////////////// 72 ///////////////////////////////////////////////////////////////////////////////
72 73
73 class GrArithmeticXP : public GrXferProcessor { 74 class GrArithmeticXP : public GrXferProcessor {
74 public: 75 public:
75 static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool enforcePMColor) { 76 static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool enforcePMColor,
76 return SkNEW_ARGS(GrArithmeticXP, (k1, k2, k3, k4, enforcePMColor)); 77 const GrDeviceCoordTexture* dstCopy,
78 int32_t dstReadKey) {
79 return SkNEW_ARGS(GrArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstCo py, dstReadKey));
77 } 80 }
78 81
79 ~GrArithmeticXP() SK_OVERRIDE {}; 82 ~GrArithmeticXP() SK_OVERRIDE {};
80 83
81 const char* name() const SK_OVERRIDE { return "Arithmetic"; } 84 const char* name() const SK_OVERRIDE { return "Arithmetic"; }
82 85
83 void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const SK_OVERRIDE;
84
85 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; 86 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE;
86 87
87 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } 88 bool hasSecondaryOutput() const SK_OVERRIDE { return false; }
88 89
89 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, 90 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI,
90 const GrProcOptInfo& coveragePOI, 91 const GrProcOptInfo& coveragePOI,
91 bool doesStencilWrite, 92 bool doesStencilWrite,
92 GrColor* overrideColor, 93 GrColor* overrideColor,
93 const GrDrawTargetCaps& caps) SK_ OVERRIDE; 94 const GrDrawTargetCaps& caps) SK_ OVERRIDE;
94 95
95 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE { 96 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE {
96 blendInfo->fSrcBlend = kOne_GrBlendCoeff; 97 blendInfo->fSrcBlend = kOne_GrBlendCoeff;
97 blendInfo->fDstBlend = kZero_GrBlendCoeff; 98 blendInfo->fDstBlend = kZero_GrBlendCoeff;
98 blendInfo->fBlendConstant = 0; 99 blendInfo->fBlendConstant = 0;
99 } 100 }
100 101
101 float k1() const { return fK1; } 102 float k1() const { return fK1; }
102 float k2() const { return fK2; } 103 float k2() const { return fK2; }
103 float k3() const { return fK3; } 104 float k3() const { return fK3; }
104 float k4() const { return fK4; } 105 float k4() const { return fK4; }
105 bool enforcePMColor() const { return fEnforcePMColor; } 106 bool enforcePMColor() const { return fEnforcePMColor; }
106 107
107 private: 108 private:
108 GrArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor); 109 GrArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor,
110 const GrDeviceCoordTexture* dstCopy, int32_t dstReadKey);
111
112 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con st SK_OVERRIDE;
109 113
110 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { 114 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE {
111 const GrArithmeticXP& xp = xpBase.cast<GrArithmeticXP>(); 115 const GrArithmeticXP& xp = xpBase.cast<GrArithmeticXP>();
112 if (fK1 != xp.fK1 || 116 if (fK1 != xp.fK1 ||
113 fK2 != xp.fK2 || 117 fK2 != xp.fK2 ||
114 fK3 != xp.fK3 || 118 fK3 != xp.fK3 ||
115 fK4 != xp.fK4 || 119 fK4 != xp.fK4 ||
116 fEnforcePMColor != xp.fEnforcePMColor) { 120 fEnforcePMColor != xp.fEnforcePMColor) {
117 return false; 121 return false;
118 } 122 }
119 return true; 123 return true;
120 } 124 }
121 125
122 float fK1, fK2, fK3, fK4; 126 float fK1, fK2, fK3, fK4;
123 bool fEnforcePMColor; 127 bool fEnforcePMColor;
124 128
125 typedef GrXferProcessor INHERITED; 129 typedef GrXferProcessor INHERITED;
126 }; 130 };
127 131
128 /////////////////////////////////////////////////////////////////////////////// 132 ///////////////////////////////////////////////////////////////////////////////
129 133
130 class GrArithmeticXPFactory : public GrXPFactory { 134 class GrArithmeticXPFactory : public GrXPFactory {
131 public: 135 public:
132 static GrXPFactory* Create(float k1, float k2, float k3, float k4, bool enfo rcePMColor) { 136 static GrXPFactory* Create(float k1, float k2, float k3, float k4, bool enfo rcePMColor) {
133 return SkNEW_ARGS(GrArithmeticXPFactory, (k1, k2, k3, k4, enforcePMColor )); 137 return SkNEW_ARGS(GrArithmeticXPFactory, (k1, k2, k3, k4, enforcePMColor ));
134 } 138 }
135 139
136 GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI,
137 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE {
138 return GrArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor);
139 }
140
141 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const SK_OVERRIDE { 140 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const SK_OVERRIDE {
142 return true; 141 return true;
143 } 142 }
144 143
145 bool canApplyCoverage(const GrProcOptInfo& colorPOI, 144 bool canApplyCoverage(const GrProcOptInfo& colorPOI,
146 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { 145 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE {
147 return true; 146 return true;
148 } 147 }
149 148
150 bool canTweakAlphaForCoverage() const SK_OVERRIDE { 149 bool canTweakAlphaForCoverage() const SK_OVERRIDE {
151 return false; 150 return false;
152 } 151 }
153 152
154 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI, 153 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI,
155 GrXPFactory::InvariantOutput*) const SK_OVERRIDE; 154 GrXPFactory::InvariantOutput*) const SK_OVERRIDE;
156 155
157 bool willReadDst() const SK_OVERRIDE { return true; }
158
159 private: 156 private:
160 GrArithmeticXPFactory(float k1, float k2, float k3, float k4, bool enforcePM Color); 157 GrArithmeticXPFactory(float k1, float k2, float k3, float k4, bool enforcePM Color);
161 158
159 GrXferProcessor* onCreateXferProcessor(const GrProcOptInfo& colorPOI,
160 const GrProcOptInfo& coveragePOI,
161 const GrDeviceCoordTexture* dstCopy,
162 int32_t dstReadKey) const SK_OVERRIDE {
163 return GrArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor, dstCo py, dstReadKey);
164 }
165
166 bool willReadDst() const SK_OVERRIDE { return true; }
167
162 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { 168 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE {
163 const GrArithmeticXPFactory& xpf = xpfBase.cast<GrArithmeticXPFactory>() ; 169 const GrArithmeticXPFactory& xpf = xpfBase.cast<GrArithmeticXPFactory>() ;
164 if (fK1 != xpf.fK1 || 170 if (fK1 != xpf.fK1 ||
165 fK2 != xpf.fK2 || 171 fK2 != xpf.fK2 ||
166 fK3 != xpf.fK3 || 172 fK3 != xpf.fK3 ||
167 fK4 != xpf.fK4 || 173 fK4 != xpf.fK4 ||
168 fEnforcePMColor != xpf.fEnforcePMColor) { 174 fEnforcePMColor != xpf.fEnforcePMColor) {
169 return false; 175 return false;
170 } 176 }
171 return true; 177 return true;
172 } 178 }
173 179
174 GR_DECLARE_XP_FACTORY_TEST; 180 GR_DECLARE_XP_FACTORY_TEST;
175 181
176 float fK1, fK2, fK3, fK4; 182 float fK1, fK2, fK3, fK4;
177 bool fEnforcePMColor; 183 bool fEnforcePMColor;
178 184
179 typedef GrXPFactory INHERITED; 185 typedef GrXPFactory INHERITED;
180 }; 186 };
181 187
182 #endif 188 #endif
183 #endif 189 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698