OLD | NEW |
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 "GrOptDrawState.h" | 8 #include "GrOptDrawState.h" |
9 | 9 |
10 #include "GrDrawState.h" | 10 #include "GrDrawState.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 // When path rendering the stencil settings are not always set on the draw s
tate | 61 // When path rendering the stencil settings are not always set on the draw s
tate |
62 // so we must check the draw type. In cases where we will skip drawing we si
mply return a | 62 // so we must check the draw type. In cases where we will skip drawing we si
mply return a |
63 // null GrOptDrawState. | 63 // null GrOptDrawState. |
64 if (!xferProcessor || (GrXferProcessor::kSkipDraw_OptFlag & optFlags)) { | 64 if (!xferProcessor || (GrXferProcessor::kSkipDraw_OptFlag & optFlags)) { |
65 // Set the fields that don't default init and return. The lack of a rend
er target will | 65 // Set the fields that don't default init and return. The lack of a rend
er target will |
66 // indicate that this can be skipped. | 66 // indicate that this can be skipped. |
67 fFlags = 0; | 67 fFlags = 0; |
68 fDrawFace = GrDrawState::kInvalid_DrawFace; | 68 fDrawFace = GrDrawState::kInvalid_DrawFace; |
69 fViewMatrix.reset(); | |
70 return; | 69 return; |
71 } | 70 } |
72 | 71 |
73 fRenderTarget.reset(drawState.fRenderTarget.get()); | 72 fRenderTarget.reset(drawState.fRenderTarget.get()); |
74 SkASSERT(fRenderTarget); | 73 SkASSERT(fRenderTarget); |
75 fScissorState = scissorState; | 74 fScissorState = scissorState; |
76 fViewMatrix = fPrimitiveProcessor->viewMatrix(); | |
77 fStencilSettings = drawState.getStencil(); | 75 fStencilSettings = drawState.getStencil(); |
78 fDrawFace = drawState.getDrawFace(); | 76 fDrawFace = drawState.getDrawFace(); |
79 // TODO move this out of optDrawState | 77 // TODO move this out of optDrawState |
80 if (dstCopy) { | 78 if (dstCopy) { |
81 fDstCopy = *dstCopy; | 79 fDstCopy = *dstCopy; |
82 } | 80 } |
83 | 81 |
84 fFlags = 0; | 82 fFlags = 0; |
85 if (drawState.isHWAntialias()) { | 83 if (drawState.isHWAntialias()) { |
86 fFlags |= kHWAA_Flag; | 84 fFlags |= kHWAA_Flag; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 171 |
174 bool GrOptDrawState::combineIfPossible(const GrOptDrawState& that) { | 172 bool GrOptDrawState::combineIfPossible(const GrOptDrawState& that) { |
175 if (fDescInfo != that.fDescInfo) { | 173 if (fDescInfo != that.fDescInfo) { |
176 return false; | 174 return false; |
177 } | 175 } |
178 | 176 |
179 if (this->getRenderTarget() != that.getRenderTarget() || | 177 if (this->getRenderTarget() != that.getRenderTarget() || |
180 this->fFragmentStages.count() != that.fFragmentStages.count() || | 178 this->fFragmentStages.count() != that.fFragmentStages.count() || |
181 this->fNumColorStages != that.fNumColorStages || | 179 this->fNumColorStages != that.fNumColorStages || |
182 this->fScissorState != that.fScissorState || | 180 this->fScissorState != that.fScissorState || |
183 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || | |
184 this->fDrawType != that.fDrawType || | 181 this->fDrawType != that.fDrawType || |
185 this->fFlags != that.fFlags || | 182 this->fFlags != that.fFlags || |
186 this->fStencilSettings != that.fStencilSettings || | 183 this->fStencilSettings != that.fStencilSettings || |
187 this->fDrawFace != that.fDrawFace || | 184 this->fDrawFace != that.fDrawFace || |
188 this->fDstCopy.texture() != that.fDstCopy.texture()) { | 185 this->fDstCopy.texture() != that.fDstCopy.texture()) { |
189 return false; | 186 return false; |
190 } | 187 } |
191 | 188 |
192 if (!this->getPrimitiveProcessor()->canMakeEqual(fBatchTracker, | 189 if (!this->getPrimitiveProcessor()->canMakeEqual(fBatchTracker, |
193 *that.getPrimitiveProcessor
(), | 190 *that.getPrimitiveProcessor
(), |
(...skipping 12 matching lines...) Expand all Loading... |
206 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { | 203 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { |
207 return false; | 204 return false; |
208 } | 205 } |
209 } | 206 } |
210 | 207 |
211 // Now update the GrPrimitiveProcessor's batch tracker | 208 // Now update the GrPrimitiveProcessor's batch tracker |
212 fPrimitiveProcessor->makeEqual(&fBatchTracker, that.getBatchTracker()); | 209 fPrimitiveProcessor->makeEqual(&fBatchTracker, that.getBatchTracker()); |
213 return true; | 210 return true; |
214 } | 211 } |
215 | 212 |
OLD | NEW |