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

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

Issue 597323002: Split GrDrawState and GrOptDrawState into separate classes and remove base class. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More 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/GrOptDrawState.h ('k') | src/gpu/GrRODrawState.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 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"
11 #include "GrDrawTargetCaps.h" 11 #include "GrDrawTargetCaps.h"
12 #include "GrGpu.h" 12 #include "GrGpu.h"
13 13
14 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, 14 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
15 BlendOptFlags blendOptFlags, 15 BlendOptFlags blendOptFlags,
16 GrBlendCoeff optSrcCoeff, 16 GrBlendCoeff optSrcCoeff,
17 GrBlendCoeff optDstCoeff, 17 GrBlendCoeff optDstCoeff,
18 const GrDrawTargetCaps& caps) : INHERITED(drawSta te) { 18 const GrDrawTargetCaps& caps) {
19 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()),
20 GrIORef::kWrite_IOType);
19 fColor = drawState.getColor(); 21 fColor = drawState.getColor();
20 fCoverage = drawState.getCoverage(); 22 fCoverage = drawState.getCoverage();
21 fViewMatrix = drawState.getViewMatrix(); 23 fViewMatrix = drawState.getViewMatrix();
22 fBlendConstant = drawState.getBlendConstant(); 24 fBlendConstant = drawState.getBlendConstant();
23 fFlagBits = drawState.getFlagBits(); 25 fFlagBits = drawState.getFlagBits();
24 fVAPtr = drawState.getVertexAttribs(); 26 fVAPtr = drawState.getVertexAttribs();
25 fVACount = drawState.getVertexAttribCount(); 27 fVACount = drawState.getVertexAttribCount();
26 fVAStride = drawState.getVertexStride(); 28 fVAStride = drawState.getVertexStride();
27 fStencilSettings = drawState.getStencil(); 29 fStencilSettings = drawState.getStencil();
28 fDrawFace = drawState.getDrawFace(); 30 fDrawFace = (DrawFace)drawState.getDrawFace();
29 fBlendOptFlags = blendOptFlags; 31 fBlendOptFlags = blendOptFlags;
30 fSrcBlend = optSrcCoeff; 32 fSrcBlend = optSrcCoeff;
31 fDstBlend = optDstCoeff; 33 fDstBlend = optDstCoeff;
32 34
33 memcpy(fFixedFunctionVertexAttribIndices, 35 memcpy(fFixedFunctionVertexAttribIndices,
34 drawState.getFixedFunctionVertexAttribIndices(), 36 drawState.getFixedFunctionVertexAttribIndices(),
35 sizeof(fFixedFunctionVertexAttribIndices)); 37 sizeof(fFixedFunctionVertexAttribIndices));
36 38
37 39
38 fInputColorIsUsed = true; 40 fInputColorIsUsed = true;
39 fInputCoverageIsUsed = true; 41 fInputCoverageIsUsed = true;
40 42
41 if (drawState.hasGeometryProcessor()) { 43 if (drawState.hasGeometryProcessor()) {
42 fGeometryProcessor.reset(SkNEW_ARGS(GrGeometryStage, (*drawState.getGeom etryProcessor()))); 44 fGeometryProcessor.reset(SkNEW_ARGS(GrGeometryStage, (*drawState.getGeom etryProcessor())));
43 } else { 45 } else {
44 fGeometryProcessor.reset(NULL); 46 fGeometryProcessor.reset(NULL);
45 } 47 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 for (int s = 0; s < this->numCoverageStages(); ++s) { 257 for (int s = 0; s < this->numCoverageStages(); ++s) {
256 const GrFragmentStage& stage = this->getCoverageStage(s); 258 const GrFragmentStage& stage = this->getCoverageStage(s);
257 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition); 259 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
258 } 260 }
259 if (this->hasGeometryProcessor()) { 261 if (this->hasGeometryProcessor()) {
260 const GrGeometryStage& stage = *this->getGeometryProcessor(); 262 const GrGeometryStage& stage = *this->getGeometryProcessor();
261 fReadsFragPosition = fReadsFragPosition || stage.getProcessor()->willRea dFragmentPosition(); 263 fReadsFragPosition = fReadsFragPosition || stage.getProcessor()->willRea dFragmentPosition();
262 } 264 }
263 } 265 }
264 266
267 ////////////////////////////////////////////////////////////////////////////////
268
265 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { 269 bool GrOptDrawState::operator== (const GrOptDrawState& that) const {
266 return this->isEqual(that); 270 return this->isEqual(that);
267 } 271 }
268 272
273 bool GrOptDrawState::isEqual(const GrOptDrawState& that) const {
274 bool usingVertexColors = this->hasColorVertexAttribute();
275 if (!usingVertexColors && this->fColor != that.fColor) {
276 return false;
277 }
278
279 if (this->getRenderTarget() != that.getRenderTarget() ||
280 this->fColorStages.count() != that.fColorStages.count() ||
281 this->fCoverageStages.count() != that.fCoverageStages.count() ||
282 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) ||
283 this->fSrcBlend != that.fSrcBlend ||
284 this->fDstBlend != that.fDstBlend ||
285 this->fBlendConstant != that.fBlendConstant ||
286 this->fFlagBits != that.fFlagBits ||
287 this->fVACount != that.fVACount ||
288 this->fVAStride != that.fVAStride ||
289 memcmp(this->fVAPtr, that.fVAPtr, this->fVACount * sizeof(GrVertexAttrib )) ||
290 this->fStencilSettings != that.fStencilSettings ||
291 this->fDrawFace != that.fDrawFace ||
292 this->fInputColorIsUsed != that.fInputColorIsUsed ||
293 this->fInputCoverageIsUsed != that.fInputCoverageIsUsed ||
294 this->fReadsDst != that.fReadsDst ||
295 this->fReadsFragPosition != that.fReadsFragPosition ||
296 this->fRequiresLocalCoordAttrib != that.fRequiresLocalCoordAttrib ||
297 this->fPrimaryOutputType != that.fPrimaryOutputType ||
298 this->fSecondaryOutputType != that.fSecondaryOutputType) {
299 return false;
300 }
301
302 bool usingVertexCoverage = this->hasCoverageVertexAttribute();
303 if (!usingVertexCoverage && this->fCoverage != that.fCoverage) {
304 return false;
305 }
306
307 bool explicitLocalCoords = this->hasLocalCoordAttribute();
308 if (this->hasGeometryProcessor()) {
309 if (!that.hasGeometryProcessor()) {
310 return false;
311 } else if (!GrProcessorStage::AreCompatible(*this->getGeometryProcessor( ),
312 *that.getGeometryProcessor() ,
313 explicitLocalCoords)) {
314 return false;
315 }
316 } else if (that.hasGeometryProcessor()) {
317 return false;
318 }
319
320 for (int i = 0; i < this->numColorStages(); i++) {
321 if (!GrProcessorStage::AreCompatible(this->getColorStage(i), that.getCol orStage(i),
322 explicitLocalCoords)) {
323 return false;
324 }
325 }
326 for (int i = 0; i < this->numCoverageStages(); i++) {
327 if (!GrProcessorStage::AreCompatible(this->getCoverageStage(i), that.get CoverageStage(i),
328 explicitLocalCoords)) {
329 return false;
330 }
331 }
332
333 SkASSERT(0 == memcmp(this->fFixedFunctionVertexAttribIndices,
334 that.fFixedFunctionVertexAttribIndices,
335 sizeof(this->fFixedFunctionVertexAttribIndices)));
336
337 return true;
338 }
339
OLDNEW
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | src/gpu/GrRODrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698