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

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

Issue 504203004: Attach GrOptDrawState into shader building pipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@opt2
Patch Set: Remove BlendOpt Cache Created 6 years, 3 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 "GrRODrawState.h" 8 #include "GrRODrawState.h"
9 9
10 #include "GrDrawTargetCaps.h" 10 #include "GrDrawTargetCaps.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 srcCoeff = &bogusSrcCoeff; 179 srcCoeff = &bogusSrcCoeff;
180 } 180 }
181 if (NULL == dstCoeff) { 181 if (NULL == dstCoeff) {
182 dstCoeff = &bogusDstCoeff; 182 dstCoeff = &bogusDstCoeff;
183 } 183 }
184 184
185 if (forceCoverage) { 185 if (forceCoverage) {
186 return this->calcBlendOpts(true, srcCoeff, dstCoeff); 186 return this->calcBlendOpts(true, srcCoeff, dstCoeff);
187 } 187 }
188 188
189 if (0 == (fBlendOptFlags & kInvalid_BlendOptFlag)) { 189 return this->calcBlendOpts(forceCoverage, srcCoeff, dstCoeff);
190 *srcCoeff = fOptSrcBlend;
191 *dstCoeff = fOptDstBlend;
192 return fBlendOptFlags;
193 }
194
195 fBlendOptFlags = this->calcBlendOpts(forceCoverage, srcCoeff, dstCoeff);
196 fOptSrcBlend = *srcCoeff;
197 fOptDstBlend = *dstCoeff;
198
199 return fBlendOptFlags;
200 } 190 }
201 191
202 GrRODrawState::BlendOptFlags GrRODrawState::calcBlendOpts(bool forceCoverage, 192 GrRODrawState::BlendOptFlags GrRODrawState::calcBlendOpts(bool forceCoverage,
203 GrBlendCoeff* srcCoeff , 193 GrBlendCoeff* srcCoeff ,
204 GrBlendCoeff* dstCoeff ) const { 194 GrBlendCoeff* dstCoeff ) const {
205 *srcCoeff = this->getSrcBlendCoeff(); 195 *srcCoeff = this->getSrcBlendCoeff();
206 *dstCoeff = this->getDstBlendCoeff(); 196 *dstCoeff = this->getDstBlendCoeff();
207 197
208 if (this->isColorWriteDisabled()) { 198 if (this->isColorWriteDisabled()) {
209 *srcCoeff = kZero_GrBlendCoeff; 199 *srcCoeff = kZero_GrBlendCoeff;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if 353 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if
364 // coverage and color both have A==1. 354 // coverage and color both have A==1.
365 return (kA_GrColorComponentFlag & validComponentFlags & coverageComponen tFlags) && 355 return (kA_GrColorComponentFlag & validComponentFlags & coverageComponen tFlags) &&
366 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage ); 356 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage );
367 357
368 } 358 }
369 359
370 return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnp ackA(color); 360 return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnp ackA(color);
371 } 361 }
372 362
373 ////////////////////////////////////////////////////////////////////////////////
374
375 bool GrRODrawState::canIgnoreColorAttribute() const {
376 if (fBlendOptFlags & kInvalid_BlendOptFlag) {
377 this->getBlendOpts();
378 }
379 return SkToBool(fBlendOptFlags & (GrRODrawState::kEmitTransBlack_BlendOptFla g |
380 GrRODrawState::kEmitCoverage_BlendOptFlag) );
381 }
382
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698