drawRect(rect, matrix, stageEnableBitfield, NULL, NULL);
}
+ /**
+ * Clear the entire render target. Ignores the clip an all other draw state
+ * (blend mode, stages, etc).
+ */
+ virtual void clear(GrColor color) = 0;
+
///////////////////////////////////////////////////////////////////////////
class AutoStateRestore : ::GrNoncopyable {
GrIndexBuffer* createIndexBuffer(uint32_t size, bool dynamic);
/**
- * Clear the entire render target, ignoring any clips/scissors.
- *
- * This is issued to the GPU driver immediately.
- */
- void clear(GrColor color);
-
- /**
* Are 8 bit paletted textures supported.
*
* @return true if 8bit palette textures are supported, false otherwise
virtual void drawNonIndexed(GrPrimitiveType type,
int startVertex,
int vertexCount);
+ virtual void clear(GrColor color);
/**
* Installs a path renderer that will be used to draw paths that are
int* vertexCount,
int* indexCount) const;
+ virtual void clear(GrColor color);
+
private:
struct Draw {
const GrIndexBuffer* fIndexBuffer;
};
+ struct Clear {
+ int fBeforeDrawIdx;
+ GrColor fColor;
+ };
+
virtual bool onAcquireGeometry(GrVertexLayout vertexLayout,
void** vertices,
void** indices);
GrTAllocator<Draw> fDraws;
GrTAllocator<SavedDrawState> fStates;
+ GrTAllocator<Clear> fClears;
GrTAllocator<GrClip> fClips;
bool fClipSet;
kDrawPreallocCnt = 8,
kStatePreallocCnt = 8,
kClipPreallocCnt = 8,
+ kClearPreallocCnt = 4,
};
GrAlignedSTStorage<kDrawPreallocCnt, Draw> fDrawStorage;
GrAlignedSTStorage<kStatePreallocCnt, SavedDrawState> fStateStorage;
GrAlignedSTStorage<kClipPreallocCnt, GrClip> fClipStorage;
+ GrAlignedSTStorage<kClearPreallocCnt, Clear> fClearStorage;
typedef GrDrawTarget INHERITED;
};
GrIndexBufferAllocPool* indexPool) :
fDraws(&fDrawStorage),
fStates(&fStateStorage),
+ fClears(&fClearStorage),
fClips(&fClipStorage),
fClipSet(true),
draw.fIndexBuffer = NULL;
}
+void GrInOrderDrawBuffer::clear(GrColor color) {
+ Clear& clr = fClears.push_back();
+ clr.fColor = color;
+ clr.fBeforeDrawIdx = fDraws.count();
+
+ // We could do something smart and remove previous draws and clears to the
+ // current render target. If we get that smart we have to make sure those
+ // draws aren't read before this clear (render-to-texture).
+}
+
void GrInOrderDrawBuffer::reset() {
GrAssert(!fReservedGeometry.fLocked);
uint32_t numStates = fStates.count();
fDraws.reset();
fStates.reset();
+ fClears.reset();
+
fVertexPool.reset();
fIndexPool.reset();
uint32_t currState = ~0;
uint32_t currClip = ~0;
+ uint32_t currClear = 0;
for (uint32_t i = 0; i < numDraws; ++i) {
+ while (currClear < fClears.count() &&
+ i == fClears[currClear].fBeforeDrawIdx) {
+ target->clear(fClears[currClear].fColor);
+ ++currClear;
+ }
+
const Draw& draw = fDraws[i];
if (draw.fStateChanged) {
++currState;
draw.fVertexCount);
}
}
+ while (currClear < fClears.count()) {
+ GrAssert(fDraws.count() == fClears[currClear].fBeforeDrawIdx);
+ target->clear(fClears[currClear].fColor);
+ ++currClear;
+ }
}
bool GrInOrderDrawBuffer::geometryHints(GrVertexLayout vertexLayout,