Index: src/gpu/GrOptDrawState.cpp |
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp |
index 742ffade125f8b448af7ea6a3487396ea8d486af..bf6b79e01957b07f939ba4f71e8110d19a455d8d 100644 |
--- a/src/gpu/GrOptDrawState.cpp |
+++ b/src/gpu/GrOptDrawState.cpp |
@@ -7,6 +7,7 @@ |
#include "GrOptDrawState.h" |
+#include "GrBatch.h" |
#include "GrDrawState.h" |
#include "GrDrawTargetCaps.h" |
#include "GrGpu.h" |
@@ -19,15 +20,46 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
const GrScissorState& scissorState, |
const GrDeviceCoordTexture* dstCopy, |
GrGpu::DrawType drawType) |
- : fFinalized(false) { |
- fDrawType = drawType; |
- |
+ : fDrawType(drawType) |
+ , fFinalized(false) { |
fPrimitiveProcessor.reset(primProc); |
- |
const GrProcOptInfo& colorPOI = drawState.colorProcInfo(fPrimitiveProcessor); |
const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(fPrimitiveProcessor); |
+ GrGeometryProcessor::InitBT init; |
+ this->internalConstructor(&init, drawState, colorPOI, coveragePOI, caps, scissorState, dstCopy); |
+ |
+ fPrimitiveProcessor->initBatchTracker(&fBatchTracker, init); |
+} |
+ |
+GrOptDrawState::GrOptDrawState(GrBatch* batch, |
+ const GrDrawState& drawState, |
+ const GrDrawTargetCaps& caps, |
+ const GrScissorState& scissorState, |
+ const GrDeviceCoordTexture* dstCopy, |
+ GrGpu::DrawType drawType) |
+ : fDrawType(drawType) |
+ , fFinalized(false){ |
+ GrBatchOpt batchOpt; |
+ batchOpt.fCanTweakAlphaForCoverage = drawState.canTweakAlphaForCoverage(); |
+ batch->initBatchOpt(batchOpt); |
+ const GrProcOptInfo& colorPOI = drawState.colorProcInfo(batch); |
+ const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(batch); |
+ |
+ GrGeometryProcessor::InitBT init; |
+ this->internalConstructor(&init, drawState, colorPOI, coveragePOI, caps, scissorState, dstCopy); |
+ |
+ batch->initBatchTracker(init); |
+} |
+ |
+void GrOptDrawState::internalConstructor(GrGeometryProcessor::InitBT* init, |
+ const GrDrawState& drawState, |
+ const GrProcOptInfo& colorPOI, |
+ const GrProcOptInfo& coveragePOI, |
+ const GrDrawTargetCaps& caps, |
+ const GrScissorState& scissorState, |
+ const GrDeviceCoordTexture* dstCopy) { |
// Create XferProcessor from DS's XPFactory |
SkAutoTUnref<GrXferProcessor> xferProcessor( |
drawState.getXPFactory()->createXferProcessor(colorPOI, coveragePOI)); |
@@ -110,12 +142,10 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
} |
// let the GP init the batch tracker |
- GrGeometryProcessor::InitBT init; |
- init.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag); |
- init.fOverrideColor = init.fColorIgnored ? GrColor_ILLEGAL : overrideColor; |
- init.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag); |
- init.fUsesLocalCoords = usesLocalCoords; |
- fPrimitiveProcessor->initBatchTracker(&fBatchTracker, init); |
+ init->fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag); |
+ init->fOverrideColor = init->fColorIgnored ? GrColor_ILLEGAL : overrideColor; |
+ init->fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag); |
+ init->fUsesLocalCoords = usesLocalCoords; |
} |
void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds, |
@@ -158,7 +188,7 @@ void GrOptDrawState::finalize(GrGpu* gpu) { |
//////////////////////////////////////////////////////////////////////////////// |
-bool GrOptDrawState::combineIfPossible(const GrOptDrawState& that) { |
+bool GrOptDrawState::combineIfPossible(GrOptDrawState& that) { |
if (fDescInfo != that.fDescInfo) { |
return false; |
} |
@@ -175,9 +205,16 @@ bool GrOptDrawState::combineIfPossible(const GrOptDrawState& that) { |
return false; |
} |
- if (!this->getPrimitiveProcessor()->canMakeEqual(fBatchTracker, |
- *that.getPrimitiveProcessor(), |
- that.getBatchTracker())) { |
+ // TODO remove this when we have Batch. This is confusing because some OptStates have primitive |
+ // processors and some are associated with batches |
+ if (SkToBool(this->getPrimitiveProcessor()) != SkToBool(that.getPrimitiveProcessor())) { |
+ return false; |
+ } |
+ |
+ if (this->getPrimitiveProcessor() && that.getPrimitiveProcessor() && |
+ !this->getPrimitiveProcessor()->canMakeEqual(fBatchTracker, |
+ *that.getPrimitiveProcessor(), |
+ that.getBatchTracker())) { |
return false; |
} |
@@ -193,9 +230,6 @@ bool GrOptDrawState::combineIfPossible(const GrOptDrawState& that) { |
return false; |
} |
} |
- |
- // Now update the GrPrimitiveProcessor's batch tracker |
- fPrimitiveProcessor->makeEqual(&fBatchTracker, that.getBatchTracker()); |
return true; |
} |