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

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

Issue 630063002: Make createOptDrawState return NULL if we would end up not drawing (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase and Nits 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
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrOptDrawState.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 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"
11 #include "GrPaint.h" 11 #include "GrPaint.h"
12 12
13 //////////////////////////////////////////////////////////////////////////////s 13 //////////////////////////////////////////////////////////////////////////////s
14 14
15 GrOptDrawState* GrDrawState::createOptState(const GrDrawTargetCaps& caps) const {
16 if (NULL == fCachedOptState || caps.getUniqueID() != fCachedCapsID) {
17 GrBlendCoeff srcCoeff;
18 GrBlendCoeff dstCoeff;
19 GrOptDrawState::BlendOptFlags blendFlags =
20 (GrOptDrawState::BlendOptFlags) this->getBlendOpts(false, &srcCoeff, &dstCoeff);
21 fCachedOptState = SkNEW_ARGS(GrOptDrawState, (*this, blendFlags, srcCoef f, dstCoeff, caps));
22 fCachedCapsID = caps.getUniqueID();
23 } else {
24 #ifdef SK_DEBUG
25 GrBlendCoeff srcCoeff;
26 GrBlendCoeff dstCoeff;
27 GrOptDrawState::BlendOptFlags blendFlags =
28 (GrOptDrawState::BlendOptFlags) this->getBlendOpts(false, &srcCoeff, &dstCoeff);
29 SkASSERT(GrOptDrawState(*this, blendFlags, srcCoeff, dstCoeff, caps) == *fCachedOptState);
30 #endif
31 }
32 fCachedOptState->ref();
33 return fCachedOptState;
34 }
35
36 //////////////////////////////////////////////////////////////////////////////s
37
38 bool GrDrawState::isEqual(const GrDrawState& that) const { 15 bool GrDrawState::isEqual(const GrDrawState& that) const {
39 bool usingVertexColors = this->hasColorVertexAttribute(); 16 bool usingVertexColors = this->hasColorVertexAttribute();
40 if (!usingVertexColors && this->fColor != that.fColor) { 17 if (!usingVertexColors && this->fColor != that.fColor) {
41 return false; 18 return false;
42 } 19 }
43 20
44 if (this->getRenderTarget() != that.getRenderTarget() || 21 if (this->getRenderTarget() != that.getRenderTarget() ||
45 this->fColorStages.count() != that.fColorStages.count() || 22 this->fColorStages.count() != that.fColorStages.count() ||
46 this->fCoverageStages.count() != that.fCoverageStages.count() || 23 this->fCoverageStages.count() != that.fCoverageStages.count() ||
47 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || 24 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) ||
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 } 776 }
800 777
801 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if 778 // 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. 779 // coverage and color both have A==1.
803 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); 780 return (inoutColor.isOpaque() && inoutCoverage.isOpaque());
804 } 781 }
805 782
806 return inoutColor.isOpaque(); 783 return inoutColor.isOpaque();
807 } 784 }
808 785
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrOptDrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698