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

Side by Side Diff: src/gpu/effects/GrCustomXfermode.cpp

Issue 1440073002: Move XferProcessors to glsl (Closed) Base URL: https://skia.googlesource.com/skia.git@fragProcs
Patch Set: Created 5 years, 1 month 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/GrCoverageSetOpXP.cpp ('k') | src/gpu/effects/GrDisableColorXP.cpp » ('j') | 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 #include "effects/GrCustomXfermode.h" 8 #include "effects/GrCustomXfermode.h"
9 9
10 #include "GrCoordTransform.h" 10 #include "GrCoordTransform.h"
11 #include "GrContext.h" 11 #include "GrContext.h"
12 #include "GrFragmentProcessor.h" 12 #include "GrFragmentProcessor.h"
13 #include "GrInvariantOutput.h" 13 #include "GrInvariantOutput.h"
14 #include "GrProcessor.h" 14 #include "GrProcessor.h"
15 #include "GrTexture.h" 15 #include "GrTexture.h"
16 #include "GrTextureAccess.h" 16 #include "GrTextureAccess.h"
17 #include "SkXfermode.h" 17 #include "SkXfermode.h"
18 #include "gl/GrGLXferProcessor.h"
19 #include "glsl/GrGLSLBlend.h" 18 #include "glsl/GrGLSLBlend.h"
20 #include "glsl/GrGLSLCaps.h" 19 #include "glsl/GrGLSLCaps.h"
21 #include "glsl/GrGLSLFragmentProcessor.h" 20 #include "glsl/GrGLSLFragmentProcessor.h"
22 #include "glsl/GrGLSLFragmentShaderBuilder.h" 21 #include "glsl/GrGLSLFragmentShaderBuilder.h"
23 #include "glsl/GrGLSLProgramBuilder.h" 22 #include "glsl/GrGLSLProgramBuilder.h"
24 #include "glsl/GrGLSLProgramDataManager.h" 23 #include "glsl/GrGLSLProgramDataManager.h"
24 #include "glsl/GrGLSLXferProcessor.h"
25 25
26 bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) { 26 bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) {
27 return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMode; 27 return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMode;
28 } 28 }
29 29
30 /////////////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////////////
31 // Static helpers 31 // Static helpers
32 /////////////////////////////////////////////////////////////////////////////// 32 ///////////////////////////////////////////////////////////////////////////////
33 33
34 static GrBlendEquation hw_blend_equation(SkXfermode::Mode mode) { 34 static GrBlendEquation hw_blend_equation(SkXfermode::Mode mode) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 CustomXP(const DstTexture* dstTexture, bool hasMixedSamples, SkXfermode::Mod e mode) 82 CustomXP(const DstTexture* dstTexture, bool hasMixedSamples, SkXfermode::Mod e mode)
83 : INHERITED(dstTexture, true, hasMixedSamples), 83 : INHERITED(dstTexture, true, hasMixedSamples),
84 fMode(mode), 84 fMode(mode),
85 fHWBlendEquation(static_cast<GrBlendEquation>(-1)) { 85 fHWBlendEquation(static_cast<GrBlendEquation>(-1)) {
86 this->initClassID<CustomXP>(); 86 this->initClassID<CustomXP>();
87 } 87 }
88 88
89 const char* name() const override { return "Custom Xfermode"; } 89 const char* name() const override { return "Custom Xfermode"; }
90 90
91 GrGLXferProcessor* createGLInstance() const override; 91 GrGLSLXferProcessor* createGLInstance() const override;
92 92
93 SkXfermode::Mode mode() const { return fMode; } 93 SkXfermode::Mode mode() const { return fMode; }
94 bool hasHWBlendEquation() const { return -1 != static_cast<int>(fHWBlendEqua tion); } 94 bool hasHWBlendEquation() const { return -1 != static_cast<int>(fHWBlendEqua tion); }
95 95
96 GrBlendEquation hwBlendEquation() const { 96 GrBlendEquation hwBlendEquation() const {
97 SkASSERT(this->hasHWBlendEquation()); 97 SkASSERT(this->hasHWBlendEquation());
98 return fHWBlendEquation; 98 return fHWBlendEquation;
99 } 99 }
100 100
101 private: 101 private:
(...skipping 12 matching lines...) Expand all
114 bool onIsEqual(const GrXferProcessor& xpBase) const override; 114 bool onIsEqual(const GrXferProcessor& xpBase) const override;
115 115
116 const SkXfermode::Mode fMode; 116 const SkXfermode::Mode fMode;
117 const GrBlendEquation fHWBlendEquation; 117 const GrBlendEquation fHWBlendEquation;
118 118
119 typedef GrXferProcessor INHERITED; 119 typedef GrXferProcessor INHERITED;
120 }; 120 };
121 121
122 /////////////////////////////////////////////////////////////////////////////// 122 ///////////////////////////////////////////////////////////////////////////////
123 123
124 class GLCustomXP : public GrGLXferProcessor { 124 class GLCustomXP : public GrGLSLXferProcessor {
125 public: 125 public:
126 GLCustomXP(const GrXferProcessor&) {} 126 GLCustomXP(const GrXferProcessor&) {}
127 ~GLCustomXP() override {} 127 ~GLCustomXP() override {}
128 128
129 static void GenKey(const GrXferProcessor& p, const GrGLSLCaps& caps, GrProce ssorKeyBuilder* b) { 129 static void GenKey(const GrXferProcessor& p, const GrGLSLCaps& caps, GrProce ssorKeyBuilder* b) {
130 const CustomXP& xp = p.cast<CustomXP>(); 130 const CustomXP& xp = p.cast<CustomXP>();
131 uint32_t key = 0; 131 uint32_t key = 0;
132 if (xp.hasHWBlendEquation()) { 132 if (xp.hasHWBlendEquation()) {
133 SkASSERT(caps.advBlendEqInteraction() > 0); // 0 will mean !xp.hasH WBlendEquation(). 133 SkASSERT(caps.advBlendEqInteraction() > 0); // 0 will mean !xp.hasH WBlendEquation().
134 key |= caps.advBlendEqInteraction(); 134 key |= caps.advBlendEqInteraction();
(...skipping 28 matching lines...) Expand all
163 const char* outColor, const GrXferProcessor& pr oc) override { 163 const char* outColor, const GrXferProcessor& pr oc) override {
164 const CustomXP& xp = proc.cast<CustomXP>(); 164 const CustomXP& xp = proc.cast<CustomXP>();
165 SkASSERT(!xp.hasHWBlendEquation()); 165 SkASSERT(!xp.hasHWBlendEquation());
166 166
167 GrGLSLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder(); 167 GrGLSLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
168 GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.mode ()); 168 GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.mode ());
169 } 169 }
170 170
171 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over ride {} 171 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over ride {}
172 172
173 typedef GrGLXferProcessor INHERITED; 173 typedef GrGLSLXferProcessor INHERITED;
174 }; 174 };
175 175
176 /////////////////////////////////////////////////////////////////////////////// 176 ///////////////////////////////////////////////////////////////////////////////
177 177
178 void CustomXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder * b) const { 178 void CustomXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder * b) const {
179 GLCustomXP::GenKey(*this, caps, b); 179 GLCustomXP::GenKey(*this, caps, b);
180 } 180 }
181 181
182 GrGLXferProcessor* CustomXP::createGLInstance() const { 182 GrGLSLXferProcessor* CustomXP::createGLInstance() const {
183 SkASSERT(this->willReadDstColor() != this->hasHWBlendEquation()); 183 SkASSERT(this->willReadDstColor() != this->hasHWBlendEquation());
184 return new GLCustomXP(*this); 184 return new GLCustomXP(*this);
185 } 185 }
186 186
187 bool CustomXP::onIsEqual(const GrXferProcessor& other) const { 187 bool CustomXP::onIsEqual(const GrXferProcessor& other) const {
188 const CustomXP& s = other.cast<CustomXP>(); 188 const CustomXP& s = other.cast<CustomXP>();
189 return fMode == s.fMode && fHWBlendEquation == s.fHWBlendEquation; 189 return fMode == s.fMode && fHWBlendEquation == s.fHWBlendEquation;
190 } 190 }
191 191
192 GrXferProcessor::OptFlags CustomXP::onGetOptimizations(const GrProcOptInfo& colo rPOI, 192 GrXferProcessor::OptFlags CustomXP::onGetOptimizations(const GrProcOptInfo& colo rPOI,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 392
393 /////////////////////////////////////////////////////////////////////////////// 393 ///////////////////////////////////////////////////////////////////////////////
394 394
395 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { 395 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) {
396 if (!GrCustomXfermode::IsSupportedMode(mode)) { 396 if (!GrCustomXfermode::IsSupportedMode(mode)) {
397 return nullptr; 397 return nullptr;
398 } else { 398 } else {
399 return new CustomXPFactory(mode); 399 return new CustomXPFactory(mode);
400 } 400 }
401 } 401 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrCoverageSetOpXP.cpp ('k') | src/gpu/effects/GrDisableColorXP.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698