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

Side by Side Diff: src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp

Issue 900883002: Revert of Move DstCopy on gpu into the GrXferProcessor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 2014 Google Inc. 2 * Copyright 2014 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 "GrGLFragmentShaderBuilder.h" 8 #include "GrGLFragmentShaderBuilder.h"
9 #include "GrGLShaderStringBuilder.h" 9 #include "GrGLShaderStringBuilder.h"
10 #include "GrGLProgramBuilder.h" 10 #include "GrGLProgramBuilder.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 gpu->glCaps().fbFetchExtensionString()); 172 gpu->glCaps().fbFetchExtensionString());
173 173
174 // Some versions of this extension string require declaring custom color output on ES 3.0+ 174 // Some versions of this extension string require declaring custom color output on ES 3.0+
175 const char* fbFetchColorName = gpu->glCaps().fbFetchColorName(); 175 const char* fbFetchColorName = gpu->glCaps().fbFetchColorName();
176 if (gpu->glCaps().fbFetchNeedsCustomOutput()) { 176 if (gpu->glCaps().fbFetchNeedsCustomOutput()) {
177 this->enableCustomOutput(); 177 this->enableCustomOutput();
178 fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOu t_TypeModifier); 178 fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOu t_TypeModifier);
179 fbFetchColorName = declared_color_output_name(); 179 fbFetchColorName = declared_color_output_name();
180 } 180 }
181 return fbFetchColorName; 181 return fbFetchColorName;
182 } else if (fProgramBuilder->fUniformHandles.fDstCopySamplerUni.isValid()) {
183 return kDstCopyColorName;
182 } else { 184 } else {
183 return kDstCopyColorName; 185 return "";
184 } 186 }
187 }
188
189 void GrGLFragmentShaderBuilder::emitCodeToReadDstTexture() {
190 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & fProgramBuilder->head er().fDstReadKey);
191 const char* dstCopyTopLeftName;
192 const char* dstCopyCoordScaleName;
193 const char* dstCopySamplerName;
194 uint32_t configMask;
195 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & fProgramBuilder->header().fDstR eadKey)) {
196 configMask = kA_GrColorComponentFlag;
197 } else {
198 configMask = kRGBA_GrColorComponentFlags;
199 }
200 fProgramBuilder->fUniformHandles.fDstCopySamplerUni =
201 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility ,
202 kSampler2D_GrSLType,
203 kDefault_GrSLPrecision,
204 "DstCopySampler",
205 &dstCopySamplerName);
206 fProgramBuilder->fUniformHandles.fDstCopyTopLeftUni =
207 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility ,
208 kVec2f_GrSLType,
209 kDefault_GrSLPrecision,
210 "DstCopyUpperLeft",
211 &dstCopyTopLeftName);
212 fProgramBuilder->fUniformHandles.fDstCopyScaleUni =
213 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility ,
214 kVec2f_GrSLType,
215 kDefault_GrSLPrecision,
216 "DstCopyCoordScale",
217 &dstCopyCoordScaleName);
218 const char* fragPos = this->fragmentPosition();
219
220 this->codeAppend("// Read color from copy of the destination.\n");
221 this->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;",
222 fragPos, dstCopyTopLeftName, dstCopyCoordScaleName);
223 if (!topDown) {
224 this->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;");
225 }
226 this->codeAppendf("vec4 %s = ", GrGLFragmentShaderBuilder::kDstCopyColorName );
227 this->appendTextureLookup(dstCopySamplerName,
228 "_dstTexCoord",
229 configMask,
230 "rgba");
231 this->codeAppend(";");
185 } 232 }
186 233
187 void GrGLFragmentShaderBuilder::enableCustomOutput() { 234 void GrGLFragmentShaderBuilder::enableCustomOutput() {
188 if (!fHasCustomColorOutput) { 235 if (!fHasCustomColorOutput) {
189 fHasCustomColorOutput = true; 236 fHasCustomColorOutput = true;
190 fCustomColorOutputIndex = fOutputs.count(); 237 fCustomColorOutputIndex = fOutputs.count();
191 fOutputs.push_back().set(kVec4f_GrSLType, 238 fOutputs.push_back().set(kVec4f_GrSLType,
192 GrGLShaderVar::kOut_TypeModifier, 239 GrGLShaderVar::kOut_TypeModifier,
193 declared_color_output_name()); 240 declared_color_output_name());
194 } 241 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 297 }
251 } 298 }
252 299
253 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec) { 300 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec) {
254 v->fFsIn = v->fVsOut; 301 v->fFsIn = v->fVsOut;
255 if (v->fGsOut) { 302 if (v->fGsOut) {
256 v->fFsIn = v->fGsOut; 303 v->fFsIn = v->fGsOut;
257 } 304 }
258 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v- >fFsIn, fsPrec); 305 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v- >fFsIn, fsPrec);
259 } 306 }
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLFragmentShaderBuilder.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698