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

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

Issue 504203004: Attach GrOptDrawState into shader building pipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@opt2
Patch Set: Rebase 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
« 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 "GrDrawTargetCaps.h" 10 #include "GrDrawTargetCaps.h"
11 #include "GrOptDrawState.h" 11 #include "GrOptDrawState.h"
12 #include "GrPaint.h" 12 #include "GrPaint.h"
13 13
14 //////////////////////////////////////////////////////////////////////////////s 14 //////////////////////////////////////////////////////////////////////////////s
15 15
16 GrOptDrawState* GrDrawState::createOptState() const { 16 GrOptDrawState* GrDrawState::createOptState() const {
17 if (NULL == fCachedOptState) { 17 if (NULL == fCachedOptState) {
18 fCachedOptState = SkNEW_ARGS(GrOptDrawState, (*this)); 18 GrBlendCoeff srcCoeff;
19 GrBlendCoeff dstCoeff;
20 BlendOptFlags blendFlags = this->getBlendOpts(false, &srcCoeff, &dstCoef f);
21 fCachedOptState = SkNEW_ARGS(GrOptDrawState, (*this, blendFlags, srcCoef f, dstCoeff));
19 } else { 22 } else {
20 SkASSERT(GrOptDrawState(*this) == *fCachedOptState); 23 #ifdef SK_DEBUG
24 GrBlendCoeff srcCoeff;
25 GrBlendCoeff dstCoeff;
26 BlendOptFlags blendFlags = this->getBlendOpts(false, &srcCoeff, &dstCoef f);
27 SkASSERT(GrOptDrawState(*this, blendFlags, srcCoeff, dstCoeff) == *fCach edOptState);
28 #endif
21 } 29 }
22 fCachedOptState->ref(); 30 fCachedOptState->ref();
23 return fCachedOptState; 31 return fCachedOptState;
24 } 32 }
25 33
26 //////////////////////////////////////////////////////////////////////////////s 34 //////////////////////////////////////////////////////////////////////////////s
27 35
28 GrDrawState::CombinedState GrDrawState::CombineIfPossible( 36 GrDrawState::CombinedState GrDrawState::CombineIfPossible(
29 const GrDrawState& a, const GrDrawState& b, const GrDrawTargetCaps& caps) { 37 const GrDrawState& a, const GrDrawState& b, const GrDrawTargetCaps& caps) {
30 38
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 fStencilSettings = that.fStencilSettings; 107 fStencilSettings = that.fStencilSettings;
100 fCoverage = that.fCoverage; 108 fCoverage = that.fCoverage;
101 fDrawFace = that.fDrawFace; 109 fDrawFace = that.fDrawFace;
102 if (that.hasGeometryProcessor()) { 110 if (that.hasGeometryProcessor()) {
103 fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*that.fGeometryProce ssor.get()))); 111 fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*that.fGeometryProce ssor.get())));
104 } else { 112 } else {
105 fGeometryProcessor.reset(NULL); 113 fGeometryProcessor.reset(NULL);
106 } 114 }
107 fColorStages = that.fColorStages; 115 fColorStages = that.fColorStages;
108 fCoverageStages = that.fCoverageStages; 116 fCoverageStages = that.fCoverageStages;
109 fOptSrcBlend = that.fOptSrcBlend;
110 fOptDstBlend = that.fOptDstBlend;
111 fBlendOptFlags = that.fBlendOptFlags;
112 117
113 fHints = that.fHints; 118 fHints = that.fHints;
114 119
115 SkRefCnt_SafeAssign(fCachedOptState, that.fCachedOptState); 120 SkRefCnt_SafeAssign(fCachedOptState, that.fCachedOptState);
116 121
117 memcpy(fFixedFunctionVertexAttribIndices, 122 memcpy(fFixedFunctionVertexAttribIndices,
118 that.fFixedFunctionVertexAttribIndices, 123 that.fFixedFunctionVertexAttribIndices,
119 sizeof(fFixedFunctionVertexAttribIndices)); 124 sizeof(fFixedFunctionVertexAttribIndices));
120 return *this; 125 return *this;
121 } 126 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 297
293 bool GrDrawState::couldApplyCoverage(const GrDrawTargetCaps& caps) const { 298 bool GrDrawState::couldApplyCoverage(const GrDrawTargetCaps& caps) const {
294 if (caps.dualSourceBlendingSupport()) { 299 if (caps.dualSourceBlendingSupport()) {
295 return true; 300 return true;
296 } 301 }
297 // we can correctly apply coverage if a) we have dual source blending 302 // we can correctly apply coverage if a) we have dual source blending
298 // or b) one of our blend optimizations applies 303 // or b) one of our blend optimizations applies
299 // or c) the src, dst blend coeffs are 1,0 and we will read Dst Color 304 // or c) the src, dst blend coeffs are 1,0 and we will read Dst Color
300 GrBlendCoeff srcCoeff; 305 GrBlendCoeff srcCoeff;
301 GrBlendCoeff dstCoeff; 306 GrBlendCoeff dstCoeff;
302 GrRODrawState::BlendOptFlags flag = this->getBlendOpts(true, &srcCoeff, &dst Coeff); 307 BlendOptFlags flag = this->getBlendOpts(true, &srcCoeff, &dstCoeff);
303 return GrRODrawState::kNone_BlendOpt != flag || 308 return GrRODrawState::kNone_BlendOpt != flag ||
304 (this->willEffectReadDstColor() && 309 (this->willEffectReadDstColor() &&
305 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); 310 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff);
306 } 311 }
307 312
308 ////////////////////////////////////////////////////////////////////////////// 313 //////////////////////////////////////////////////////////////////////////////
309 314
310 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS tate) { 315 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS tate) {
311 SkASSERT(drawState); 316 SkASSERT(drawState);
312 fDrawState = drawState; 317 fDrawState = drawState;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix); 453 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix);
449 } 454 }
450 455
451 int numCoverageStages = fDrawState->numCoverageStages(); 456 int numCoverageStages = fDrawState->numCoverageStages();
452 for (int s = 0; s < numCoverageStages; ++s, ++i) { 457 for (int s = 0; s < numCoverageStages; ++s, ++i) {
453 fDrawState->getCoverageStage(s).saveCoordChange(&fSavedCoordChanges[i]); 458 fDrawState->getCoverageStage(s).saveCoordChange(&fSavedCoordChanges[i]);
454 fDrawState->fCoverageStages[s].localCoordChange(coordChangeMatrix); 459 fDrawState->fCoverageStages[s].localCoordChange(coordChangeMatrix);
455 } 460 }
456 } 461 }
457 462
463 ////////////////////////////////////////////////////////////////////////////////
464
465 void GrDrawState::invalidateOptState() const {
466 SkSafeSetNull(fCachedOptState);
467 }
468
469 ////////////////////////////////////////////////////////////////////////////////
470
471 GrDrawState::~GrDrawState() {
472 SkSafeUnref(fCachedOptState);
473 SkASSERT(0 == fBlockEffectRemovalCnt);
474 }
475
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