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

Side by Side Diff: src/gpu/GrDrawState.cpp

Issue 611653002: Cleanup of shader building system (Closed) Base URL: https://skia.googlesource.com/skia.git@solo_gp
Patch Set: name changes Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "GrDrawState.h" 8 #include "GrDrawState.h"
9 9
10 #include "GrOptDrawState.h" 10 #include "GrOptDrawState.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 bool GrDrawState::validateVertexAttribs() const { 283 bool GrDrawState::validateVertexAttribs() const {
284 // check consistency of effects and attributes 284 // check consistency of effects and attributes
285 GrSLType slTypes[kMaxVertexAttribCnt]; 285 GrSLType slTypes[kMaxVertexAttribCnt];
286 for (int i = 0; i < kMaxVertexAttribCnt; ++i) { 286 for (int i = 0; i < kMaxVertexAttribCnt; ++i) {
287 slTypes[i] = static_cast<GrSLType>(-1); 287 slTypes[i] = static_cast<GrSLType>(-1);
288 } 288 }
289 289
290 if (this->hasGeometryProcessor()) { 290 if (this->hasGeometryProcessor()) {
291 const GrGeometryStage& stage = *this->getGeometryProcessor(); 291 const GrGeometryStage& stage = *this->getGeometryProcessor();
292 const GrGeometryProcessor* gp = stage.getGeometryProcessor(); 292 const GrGeometryProcessor* gp = stage.getProcessor();
293 SkASSERT(gp); 293 SkASSERT(gp);
294 // make sure that any attribute indices have the correct binding type, t hat the attrib 294 // make sure that any attribute indices have the correct binding type, t hat the attrib
295 // type and effect's shader lang type are compatible, and that attribute s shared by 295 // type and effect's shader lang type are compatible, and that attribute s shared by
296 // multiple effects use the same shader lang type. 296 // multiple effects use the same shader lang type.
297 const GrGeometryProcessor::VertexAttribArray& s = gp->getVertexAttribs() ; 297 const GrGeometryProcessor::VertexAttribArray& s = gp->getVertexAttribs() ;
298 298
299 int effectIndex = 0; 299 int effectIndex = 0;
300 for (int index = 0; index < fVACount; index++) { 300 for (int index = 0; index < fVACount; index++) {
301 if (kGeometryProcessor_GrVertexAttribBinding != fVAPtr[index].fBindi ng) { 301 if (kGeometryProcessor_GrVertexAttribBinding != fVAPtr[index].fBindi ng) {
302 // we only care about effect bindings 302 // we only care about effect bindings
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified. 426 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified.
427 if (this->hasCoverageVertexAttribute()) { 427 if (this->hasCoverageVertexAttribute()) {
428 inout.fValidFlags = 0; 428 inout.fValidFlags = 0;
429 } else { 429 } else {
430 inout.fColor = fCoverage; 430 inout.fColor = fCoverage;
431 inout.fValidFlags = kRGBA_GrColorComponentFlags; 431 inout.fValidFlags = kRGBA_GrColorComponentFlags;
432 } 432 }
433 433
434 // Run through the coverage stages and see if the coverage will be all ones at the end. 434 // Run through the coverage stages and see if the coverage will be all ones at the end.
435 if (this->hasGeometryProcessor()) { 435 if (this->hasGeometryProcessor()) {
436 const GrGeometryProcessor* gp = fGeometryProcessor->getGeometryProcessor (); 436 const GrGeometryProcessor* gp = fGeometryProcessor->getProcessor();
437 gp->computeInvariantOutput(&inout); 437 gp->computeInvariantOutput(&inout);
438 } 438 }
439 for (int s = 0; s < this->numCoverageStages(); ++s) { 439 for (int s = 0; s < this->numCoverageStages(); ++s) {
440 const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); 440 const GrProcessor* processor = this->getCoverageStage(s).getProcessor();
441 processor->computeInvariantOutput(&inout); 441 processor->computeInvariantOutput(&inout);
442 } 442 }
443 return inout.isSolidWhite(); 443 return inout.isSolidWhite();
444 } 444 }
445 445
446 ////////////////////////////////////////////////////////////////////////////// 446 //////////////////////////////////////////////////////////////////////////////
447 447
448 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS tate) { 448 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS tate) {
449 SkASSERT(drawState); 449 SkASSERT(drawState);
450 fDrawState = drawState; 450 fDrawState = drawState;
451 fVAPtr = drawState->fVAPtr; 451 fVAPtr = drawState->fVAPtr;
452 fVACount = drawState->fVACount; 452 fVACount = drawState->fVACount;
453 fVAStride = drawState->fVAStride; 453 fVAStride = drawState->fVAStride;
454 fDrawState->setDefaultVertexAttribs(); 454 fDrawState->setDefaultVertexAttribs();
455 } 455 }
456 456
457 //////////////////////////////////////////////////////////////////////////////s 457 //////////////////////////////////////////////////////////////////////////////s
458 458
459 bool GrDrawState::willEffectReadDstColor() const { 459 bool GrDrawState::willEffectReadDstColor() const {
460 if (!this->isColorWriteDisabled()) { 460 if (!this->isColorWriteDisabled()) {
461 for (int s = 0; s < this->numColorStages(); ++s) { 461 for (int s = 0; s < this->numColorStages(); ++s) {
462 if (this->getColorStage(s).getFragmentProcessor()->willReadDstColor( )) { 462 if (this->getColorStage(s).getProcessor()->willReadDstColor()) {
463 return true; 463 return true;
464 } 464 }
465 } 465 }
466 } 466 }
467 for (int s = 0; s < this->numCoverageStages(); ++s) { 467 for (int s = 0; s < this->numCoverageStages(); ++s) {
468 if (this->getCoverageStage(s).getFragmentProcessor()->willReadDstColor() ) { 468 if (this->getCoverageStage(s).getProcessor()->willReadDstColor()) {
469 return true; 469 return true;
470 } 470 }
471 } 471 }
472 return false; 472 return false;
473 } 473 }
474 474
475 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { 475 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) {
476 if (fDrawState) { 476 if (fDrawState) {
477 // See the big comment on the class definition about GPs. 477 // See the big comment on the class definition about GPs.
478 if (SK_InvalidUniqueID == fOriginalGPID) { 478 if (SK_InvalidUniqueID == fOriginalGPID) {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 } 799 }
800 800
801 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if 801 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if
802 // coverage and color both have A==1. 802 // coverage and color both have A==1.
803 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); 803 return (inoutColor.isOpaque() && inoutCoverage.isOpaque());
804 } 804 }
805 805
806 return inoutColor.isOpaque(); 806 return inoutColor.isOpaque();
807 } 807 }
808 808
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698