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

Unified Diff: src/gpu/GrDrawState.h

Issue 368913003: Remove deferred version of GrDrawState. (Closed) Base URL: https://skia.googlesource.com/skia.git@citer
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawState.h
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 4e226c5eb01327e389bbf398187609a0dde5e3d3..11a5af9870b2056d509b5ea6048574ab48fbbc23 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -902,7 +902,7 @@ private:
fCommon.fDrawFace = kBoth_DrawFace;
}
- /** Fields that are identical in GrDrawState and GrDrawState::DeferredState. */
+ /** This will be removed soon. The fields will become members of GrDrawState. */
struct CommonState {
// These fields are roughly sorted by decreasing likelihood of being different in op==
GrColor fColor;
@@ -941,101 +941,6 @@ private:
bool operator!= (const CommonState& other) const { return !(*this == other); }
};
- /** GrDrawState uses GrEffectStages to hold stage state which holds a ref on GrEffectRef.
- DeferredState must directly reference GrEffects, however. */
- struct SavedEffectStage {
- SavedEffectStage() : fEffect(NULL) {}
- const GrEffect* fEffect;
- GrEffectStage::SavedCoordChange fCoordChange;
- };
-
-public:
- /**
- * DeferredState contains all of the data of a GrDrawState but does not hold refs on GrResource
- * objects. Resources are allowed to hit zero ref count while in DeferredStates. Their internal
- * dispose mechanism returns them to the cache. This allows recycling resources through the
- * the cache while they are in a deferred draw queue.
- */
- class DeferredState {
- public:
- DeferredState() : fRenderTarget(NULL) {
- SkDEBUGCODE(fInitialized = false;)
- }
- // TODO: Remove this when DeferredState no longer holds a ref to the RT
- ~DeferredState() { SkSafeUnref(fRenderTarget); }
-
- void saveFrom(const GrDrawState& drawState) {
- fCommon = drawState.fCommon;
- // TODO: Here we will copy the GrRenderTarget pointer without taking a ref.
- fRenderTarget = drawState.fRenderTarget.get();
- SkSafeRef(fRenderTarget);
- // Here we ref the effects directly rather than the effect-refs. TODO: When the effect-
- // ref gets fully unref'ed it will cause the underlying effect to unref its resources
- // and recycle them to the cache (if no one else is holding a ref to the resources).
- fStages.reset(drawState.fColorStages.count() + drawState.fCoverageStages.count());
- fColorStageCnt = drawState.fColorStages.count();
- for (int i = 0; i < fColorStageCnt; ++i) {
- fStages[i].saveFrom(drawState.fColorStages[i]);
- }
- for (int i = 0; i < drawState.fCoverageStages.count(); ++i) {
- fStages[i + fColorStageCnt].saveFrom(drawState.fCoverageStages[i]);
- }
- SkDEBUGCODE(fInitialized = true;)
- }
-
- void restoreTo(GrDrawState* drawState) const {
- SkASSERT(fInitialized);
- drawState->fCommon = fCommon;
- drawState->setRenderTarget(fRenderTarget);
- // reinflate color/cov stage arrays.
- drawState->fColorStages.reset();
- for (int i = 0; i < fColorStageCnt; ++i) {
- SkNEW_APPEND_TO_TARRAY(&drawState->fColorStages, GrEffectStage, (fStages[i]));
- }
- int coverageStageCnt = fStages.count() - fColorStageCnt;
- drawState->fCoverageStages.reset();
- for (int i = 0; i < coverageStageCnt; ++i) {
- SkNEW_APPEND_TO_TARRAY(&drawState->fCoverageStages,
- GrEffectStage, (fStages[i + fColorStageCnt]));
- }
- }
-
- bool isEqual(const GrDrawState& state) const {
- int numCoverageStages = fStages.count() - fColorStageCnt;
- if (fRenderTarget != state.fRenderTarget.get() ||
- fColorStageCnt != state.fColorStages.count() ||
- numCoverageStages != state.fCoverageStages.count() ||
- fCommon != state.fCommon) {
- return false;
- }
- bool explicitLocalCoords = state.hasLocalCoordAttribute();
- for (int i = 0; i < fColorStageCnt; ++i) {
- if (!fStages[i].isEqual(state.fColorStages[i], explicitLocalCoords)) {
- return false;
- }
- }
- for (int i = 0; i < numCoverageStages; ++i) {
- int s = fColorStageCnt + i;
- if (!fStages[s].isEqual(state.fCoverageStages[i], explicitLocalCoords)) {
- return false;
- }
- }
- return true;
- }
-
- private:
- typedef SkAutoSTArray<8, GrEffectStage::DeferredStage> DeferredStageArray;
-
- GrRenderTarget* fRenderTarget;
- CommonState fCommon;
- int fColorStageCnt;
- DeferredStageArray fStages;
-
- SkDEBUGCODE(bool fInitialized;)
- };
-
-private:
-
SkAutoTUnref<GrRenderTarget> fRenderTarget;
CommonState fCommon;
« no previous file with comments | « no previous file | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698