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

Side by Side Diff: src/gpu/gl/GrGLProgram.cpp

Issue 23875048: Use explicitly-sized enums in GrGLProgramDesc::KeyHeader (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix build error with tests Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/gpu/gl/GrGLProgramDesc.h » ('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 2011 Google Inc. 2 * Copyright 2011 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 "GrGLProgram.h" 8 #include "GrGLProgram.h"
9 9
10 #include "GrAllocator.h" 10 #include "GrAllocator.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 221 }
222 222
223 // incoming color to current stage being processed. 223 // incoming color to current stage being processed.
224 SkString inColor = builder.getInputColor(); 224 SkString inColor = builder.getInputColor();
225 GrSLConstantVec knownColorValue = builder.getKnownColorValue(); 225 GrSLConstantVec knownColorValue = builder.getKnownColorValue();
226 226
227 // Get the coeffs for the Mode-based color filter, determine if color is nee ded. 227 // Get the coeffs for the Mode-based color filter, determine if color is nee ded.
228 SkXfermode::Coeff colorCoeff; 228 SkXfermode::Coeff colorCoeff;
229 SkXfermode::Coeff filterColorCoeff; 229 SkXfermode::Coeff filterColorCoeff;
230 SkAssertResult( 230 SkAssertResult(
231 SkXfermode::ModeAsCoeff(static_cast<SkXfermode::Mode>(header.fColorFilte rXfermode), 231 SkXfermode::ModeAsCoeff(header.fColorFilterXfermode,
232 &filterColorCoeff, 232 &filterColorCoeff,
233 &colorCoeff)); 233 &colorCoeff));
234 bool needColor, needFilterColor; 234 bool needColor, needFilterColor;
235 need_blend_inputs(filterColorCoeff, colorCoeff, &needFilterColor, &needColor ); 235 need_blend_inputs(filterColorCoeff, colorCoeff, &needFilterColor, &needColor );
236 236
237 // used in order for builder to return the per-stage uniform handles. 237 // used in order for builder to return the per-stage uniform handles.
238 typedef SkTArray<GrGLUniformManager::UniformHandle, true>* UniHandleArrayPtr ; 238 typedef SkTArray<GrGLUniformManager::UniformHandle, true>* UniHandleArrayPtr ;
239 int maxColorOrCovEffectCnt = GrMax(fDesc.numColorEffects(), fDesc.numCoverag eEffects()); 239 int maxColorOrCovEffectCnt = GrMax(fDesc.numColorEffects(), fDesc.numCoverag eEffects());
240 SkAutoTArray<UniHandleArrayPtr> effectUniformArrays(maxColorOrCovEffectCnt); 240 SkAutoTArray<UniHandleArrayPtr> effectUniformArrays(maxColorOrCovEffectCnt);
241 SkAutoTArray<GrGLEffect*> glEffects(maxColorOrCovEffectCnt); 241 SkAutoTArray<GrGLEffect*> glEffects(maxColorOrCovEffectCnt);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 if (header.fDiscardIfZeroCoverage && kOnes_GrSLConstantVec != knownCoverageV alue) { 304 if (header.fDiscardIfZeroCoverage && kOnes_GrSLConstantVec != knownCoverageV alue) {
305 if (kZeros_GrSLConstantVec == knownCoverageValue) { 305 if (kZeros_GrSLConstantVec == knownCoverageValue) {
306 // This is unfortunate. 306 // This is unfortunate.
307 builder.fsCodeAppend("\tdiscard;\n"); 307 builder.fsCodeAppend("\tdiscard;\n");
308 } else { 308 } else {
309 builder.fsCodeAppendf("\tif (all(lessThanEqual(%s, vec4(0.0)))) {\n\ t\tdiscard;\n\t}\n", 309 builder.fsCodeAppendf("\tif (all(lessThanEqual(%s, vec4(0.0)))) {\n\ t\tdiscard;\n\t}\n",
310 inCoverage.c_str()); 310 inCoverage.c_str());
311 } 311 }
312 } 312 }
313 313
314 GrGLProgramDesc::CoverageOutput coverageOutput = 314 if (GrGLProgramDesc::CoverageOutputUsesSecondaryOutput(header.fCoverageOutpu t)) {
315 static_cast<GrGLProgramDesc::CoverageOutput>(header.fCoverageOutput);
316 if (GrGLProgramDesc::CoverageOutputUsesSecondaryOutput(coverageOutput)) {
317 const char* secondaryOutputName = builder.enableSecondaryOutput(); 315 const char* secondaryOutputName = builder.enableSecondaryOutput();
318 316
319 // default coeff to ones for kCoverage_DualSrcOutput 317 // default coeff to ones for kCoverage_DualSrcOutput
320 SkString coeff; 318 SkString coeff;
321 GrSLConstantVec knownCoeffValue = kOnes_GrSLConstantVec; 319 GrSLConstantVec knownCoeffValue = kOnes_GrSLConstantVec;
322 if (GrGLProgramDesc::kSecondaryCoverageISA_CoverageOutput == header.fCov erageOutput) { 320 if (GrGLProgramDesc::kSecondaryCoverageISA_CoverageOutput == header.fCov erageOutput) {
323 // Get (1-A) into coeff 321 // Get (1-A) into coeff
324 SkString inColorAlpha; 322 SkString inColorAlpha;
325 GrGLSLGetComponent4f(&inColorAlpha, 323 GrGLSLGetComponent4f(&inColorAlpha,
326 inColor.c_str(), 324 inColor.c_str(),
327 kA_GrColorComponentFlag, 325 kA_GrColorComponentFlag,
328 knownColorValue, 326 knownColorValue,
329 true); 327 true);
330 knownCoeffValue = GrGLSLSubtractf<1>(&coeff, 328 knownCoeffValue = GrGLSLSubtractf<1>(&coeff,
331 NULL, 329 NULL,
332 inColorAlpha.c_str(), 330 inColorAlpha.c_str(),
333 kOnes_GrSLConstantVec, 331 kOnes_GrSLConstantVec,
334 knownColorValue, 332 knownColorValue,
335 true); 333 true);
336 } else if (GrGLProgramDesc::kSecondaryCoverageISC_CoverageOutput == cove rageOutput) { 334 } else if (GrGLProgramDesc::kSecondaryCoverageISC_CoverageOutput == head er.fCoverageOutput) {
337 // Get (1-RGBA) into coeff 335 // Get (1-RGBA) into coeff
338 knownCoeffValue = GrGLSLSubtractf<4>(&coeff, 336 knownCoeffValue = GrGLSLSubtractf<4>(&coeff,
339 NULL, 337 NULL,
340 inColor.c_str(), 338 inColor.c_str(),
341 kOnes_GrSLConstantVec, 339 kOnes_GrSLConstantVec,
342 knownColorValue, 340 knownColorValue,
343 true); 341 true);
344 } 342 }
345 // Get coeff * coverage into modulate and then write that to the dual so urce output. 343 // Get coeff * coverage into modulate and then write that to the dual so urce output.
346 SkString modulate; 344 SkString modulate;
(...skipping 11 matching lines...) Expand all
358 356
359 // Get "color * coverage" into fragColor 357 // Get "color * coverage" into fragColor
360 SkString fragColor; 358 SkString fragColor;
361 GrSLConstantVec knownFragColorValue = GrGLSLModulatef<4>(&fragColor, 359 GrSLConstantVec knownFragColorValue = GrGLSLModulatef<4>(&fragColor,
362 inColor.c_str(), 360 inColor.c_str(),
363 inCoverage.c_str(), 361 inCoverage.c_str(),
364 knownColorValue, 362 knownColorValue,
365 knownCoverageValue, 363 knownCoverageValue,
366 true); 364 true);
367 // Now tack on "+(1-coverage)dst onto the frag color if we were asked to do so. 365 // Now tack on "+(1-coverage)dst onto the frag color if we were asked to do so.
368 if (GrGLProgramDesc::kCombineWithDst_CoverageOutput == coverageOutput) { 366 if (GrGLProgramDesc::kCombineWithDst_CoverageOutput == header.fCoverageOutpu t) {
369 SkString dstCoeff; 367 SkString dstCoeff;
370 GrSLConstantVec knownDstCoeffValue = GrGLSLSubtractf<4>(&dstCoeff, 368 GrSLConstantVec knownDstCoeffValue = GrGLSLSubtractf<4>(&dstCoeff,
371 NULL, 369 NULL,
372 inCoverage.c_str (), 370 inCoverage.c_str (),
373 kOnes_GrSLConsta ntVec, 371 kOnes_GrSLConsta ntVec,
374 knownCoverageVal ue, 372 knownCoverageVal ue,
375 true); 373 true);
376 SkString dstContribution; 374 SkString dstContribution;
377 GrSLConstantVec knownDstContributionValue = GrGLSLModulatef<4>(&dstContr ibution, 375 GrSLConstantVec knownDstContributionValue = GrGLSLModulatef<4>(&dstContr ibution,
378 dstCoeff. c_str(), 376 dstCoeff. c_str(),
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 625
628 fMatrixState.fViewMatrix = drawState.getViewMatrix(); 626 fMatrixState.fViewMatrix = drawState.getViewMatrix();
629 fMatrixState.fRenderTargetSize = size; 627 fMatrixState.fRenderTargetSize = size;
630 fMatrixState.fRenderTargetOrigin = rt->origin(); 628 fMatrixState.fRenderTargetOrigin = rt->origin();
631 629
632 GrGLfloat viewMatrix[3 * 3]; 630 GrGLfloat viewMatrix[3 * 3];
633 fMatrixState.getGLMatrix<3>(viewMatrix); 631 fMatrixState.getGLMatrix<3>(viewMatrix);
634 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, viewMatrix); 632 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, viewMatrix);
635 } 633 }
636 } 634 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698