| Index: src/gpu/GrInOrderDrawBuffer.h
|
| diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
|
| index e6ed06eadbf518b326f3df3a952bea0c524a4f0b..dc43050b8c08423aecee57e7b20b5c35bb00cbd3 100644
|
| --- a/src/gpu/GrInOrderDrawBuffer.h
|
| +++ b/src/gpu/GrInOrderDrawBuffer.h
|
| @@ -11,6 +11,7 @@
|
| #include "GrDrawTarget.h"
|
| #include "GrAllocPool.h"
|
| #include "GrAllocator.h"
|
| +#include "GrCmdBuffer.h"
|
| #include "GrIndexBuffer.h"
|
| #include "GrRenderTarget.h"
|
| #include "GrPath.h"
|
| @@ -87,7 +88,7 @@ protected:
|
| virtual void clipWillBeSet(const GrClipData* newClip) SK_OVERRIDE;
|
|
|
| private:
|
| - enum Cmd {
|
| + enum {
|
| kDraw_Cmd = 1,
|
| kStencilPath_Cmd = 2,
|
| kSetState_Cmd = 3,
|
| @@ -98,8 +99,12 @@ private:
|
| kDrawPaths_Cmd = 8,
|
| };
|
|
|
| - class Draw : public DrawInfo {
|
| + typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
|
| + typedef GrCmdBuffer<TCmdAlign> CmdBuffer;
|
| +
|
| + class Draw : public DrawInfo, public CmdBuffer::Cmd {
|
| public:
|
| + enum { kCmdType = kDraw_Cmd };
|
| Draw(const DrawInfo& info, const GrVertexBuffer* vb, const GrIndexBuffer* ib)
|
| : DrawInfo(info)
|
| , fVertexBuffer(vb)
|
| @@ -108,27 +113,35 @@ private:
|
| const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); }
|
| const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); }
|
|
|
| + virtual void execute(GrDrawTarget*);
|
| +
|
| private:
|
| GrPendingIOResource<const GrVertexBuffer, GrIORef::kRead_IOType> fVertexBuffer;
|
| GrPendingIOResource<const GrIndexBuffer, GrIORef::kRead_IOType> fIndexBuffer;
|
| };
|
|
|
| - struct StencilPath : public ::SkNoncopyable {
|
| + struct StencilPath : public CmdBuffer::Cmd {
|
| + enum { kCmdType = kStencilPath_Cmd };
|
| StencilPath(const GrPath* path) : fPath(path) {}
|
|
|
| const GrPath* path() const { return fPath.get(); }
|
|
|
| + virtual void execute(GrDrawTarget*);
|
| +
|
| SkPath::FillType fFill;
|
|
|
| private:
|
| GrPendingIOResource<const GrPath, GrIORef::kRead_IOType> fPath;
|
| };
|
|
|
| - struct DrawPath : public ::SkNoncopyable {
|
| + struct DrawPath : public CmdBuffer::Cmd {
|
| + enum { kCmdType = kDrawPath_Cmd };
|
| DrawPath(const GrPath* path) : fPath(path) {}
|
|
|
| const GrPath* path() const { return fPath.get(); }
|
|
|
| + virtual void execute(GrDrawTarget*);
|
| +
|
| SkPath::FillType fFill;
|
| GrDeviceCoordTexture fDstCopy;
|
|
|
| @@ -136,38 +149,36 @@ private:
|
| GrPendingIOResource<const GrPath, GrIORef::kRead_IOType> fPath;
|
| };
|
|
|
| - struct DrawPaths : public ::SkNoncopyable {
|
| + struct DrawPaths : public CmdBuffer::Cmd {
|
| + enum { kCmdType = kDrawPaths_Cmd };
|
| DrawPaths(const GrPathRange* pathRange)
|
| : fPathRange(pathRange) {}
|
|
|
| - ~DrawPaths() {
|
| - if (fTransforms) {
|
| - SkDELETE_ARRAY(fTransforms);
|
| - }
|
| - if (fIndices) {
|
| - SkDELETE_ARRAY(fIndices);
|
| - }
|
| - }
|
| -
|
| const GrPathRange* pathRange() const { return fPathRange.get(); }
|
| + uint32_t* indices() { return fData; }
|
| + float* transforms() { return reinterpret_cast<float*>(&fData[fCount]); }
|
| +
|
| + virtual void execute(GrDrawTarget*);
|
|
|
| - uint32_t* fIndices;
|
| size_t fCount;
|
| - float* fTransforms;
|
| PathTransformType fTransformsType;
|
| SkPath::FillType fFill;
|
| GrDeviceCoordTexture fDstCopy;
|
|
|
| private:
|
| GrPendingIOResource<const GrPathRange, GrIORef::kRead_IOType> fPathRange;
|
| + uint32_t fData[0];
|
| };
|
|
|
| // This is also used to record a discard by setting the color to GrColor_ILLEGAL
|
| - struct Clear : public ::SkNoncopyable {
|
| + struct Clear : public CmdBuffer::Cmd {
|
| + enum { kCmdType = kClear_Cmd };
|
| Clear(GrRenderTarget* rt) : fRenderTarget(rt) {}
|
| - ~Clear() { }
|
| +
|
| GrRenderTarget* renderTarget() const { return fRenderTarget.get(); }
|
|
|
| + virtual void execute(GrDrawTarget*);
|
| +
|
| SkIRect fRect;
|
| GrColor fColor;
|
| bool fCanIgnoreRect;
|
| @@ -176,12 +187,15 @@ private:
|
| GrPendingIOResource<GrRenderTarget, GrIORef::kWrite_IOType> fRenderTarget;
|
| };
|
|
|
| - struct CopySurface : public ::SkNoncopyable {
|
| + struct CopySurface : public CmdBuffer::Cmd {
|
| + enum { kCmdType = kCopySurface_Cmd };
|
| CopySurface(GrSurface* dst, GrSurface* src) : fDst(dst), fSrc(src) {}
|
|
|
| GrSurface* dst() const { return fDst.get(); }
|
| GrSurface* src() const { return fSrc.get(); }
|
|
|
| + virtual void execute(GrDrawTarget*);
|
| +
|
| SkIPoint fDstPoint;
|
| SkIRect fSrcRect;
|
|
|
| @@ -190,9 +204,28 @@ private:
|
| GrPendingIOResource<GrSurface, GrIORef::kRead_IOType> fSrc;
|
| };
|
|
|
| - struct Clip : public ::SkNoncopyable {
|
| - SkClipStack fStack;
|
| - SkIPoint fOrigin;
|
| + struct SetState : public CmdBuffer::Cmd {
|
| + enum { kCmdType = kSetState_Cmd };
|
| + SetState(const GrDrawState& state) : fState(state) {}
|
| +
|
| + virtual void execute(GrDrawTarget*);
|
| +
|
| + GrDrawState fState;
|
| + };
|
| +
|
| + struct SetClip : public CmdBuffer::Cmd {
|
| + enum { kCmdType = kSetClip_Cmd };
|
| + SetClip(const GrClipData* clipData) : fStackStorage(*clipData->fClipStack) {
|
| + fClipData.fClipStack = &fStackStorage;
|
| + fClipData.fOrigin = clipData->fOrigin;
|
| + }
|
| +
|
| + virtual void execute(GrDrawTarget*);
|
| +
|
| + GrClipData fClipData;
|
| +
|
| + private:
|
| + SkClipStack fStackStorage;
|
| };
|
|
|
| // overrides from GrDrawTarget
|
| @@ -247,57 +280,25 @@ private:
|
| // Determines whether the current draw operation requieres a new drawstate and if so records it.
|
| void recordStateIfNecessary();
|
| // We lazily record clip changes in order to skip clips that have no effect.
|
| - bool needsNewClip() const;
|
| -
|
| - // these functions record a command
|
| - void recordState();
|
| - void recordClip();
|
| - Draw* recordDraw(const DrawInfo&, const GrVertexBuffer*, const GrIndexBuffer*);
|
| - StencilPath* recordStencilPath(const GrPath*);
|
| - DrawPath* recordDrawPath(const GrPath*);
|
| - DrawPaths* recordDrawPaths(const GrPathRange*);
|
| - Clear* recordClear(GrRenderTarget*);
|
| - CopySurface* recordCopySurface(GrSurface* dst, GrSurface* src);
|
| + void recordClipIfNecessary();
|
| + // Records any trace markers for a command after adding it to the buffer.
|
| + void recordTraceMarkersIfNecessary();
|
|
|
| virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; }
|
| - void addToCmdBuffer(uint8_t cmd);
|
|
|
| // TODO: Use a single allocator for commands and records
|
| enum {
|
| - kCmdPreallocCnt = 32,
|
| - kDrawPreallocCnt = 16,
|
| - kStencilPathPreallocCnt = 8,
|
| - kDrawPathPreallocCnt = 8,
|
| - kDrawPathsPreallocCnt = 8,
|
| - kStatePreallocCnt = 8,
|
| - kClipPreallocCnt = 8,
|
| - kClearPreallocCnt = 8,
|
| - kGeoPoolStatePreAllocCnt = 4,
|
| - kCopySurfacePreallocCnt = 4,
|
| + kCmdBufferInitialSizeInBytes = 64 * 1024,
|
| + kGeoPoolStatePreAllocCnt = 4,
|
| };
|
|
|
| - typedef GrTAllocator<Draw> DrawAllocator;
|
| - typedef GrTAllocator<StencilPath> StencilPathAllocator;
|
| - typedef GrTAllocator<DrawPath> DrawPathAllocator;
|
| - typedef GrTAllocator<DrawPaths> DrawPathsAllocator;
|
| - typedef GrTAllocator<GrDrawState> StateAllocator;
|
| - typedef GrTAllocator<Clear> ClearAllocator;
|
| - typedef GrTAllocator<CopySurface> CopySurfaceAllocator;
|
| - typedef GrTAllocator<Clip> ClipAllocator;
|
| -
|
| - GrSTAllocator<kDrawPreallocCnt, Draw> fDraws;
|
| - GrSTAllocator<kStencilPathPreallocCnt, StencilPath> fStencilPaths;
|
| - GrSTAllocator<kDrawPathPreallocCnt, DrawPath> fDrawPath;
|
| - GrSTAllocator<kDrawPathsPreallocCnt, DrawPaths> fDrawPaths;
|
| - GrSTAllocator<kStatePreallocCnt, GrDrawState> fStates;
|
| - GrSTAllocator<kClearPreallocCnt, Clear> fClears;
|
| - GrSTAllocator<kCopySurfacePreallocCnt, CopySurface> fCopySurfaces;
|
| - GrSTAllocator<kClipPreallocCnt, Clip> fClips;
|
| -
|
| - SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers;
|
| - SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds;
|
| - GrDrawTarget* fDstGpu;
|
| - bool fClipSet;
|
| + CmdBuffer fCmdBuffer;
|
| + GrDrawState* fLastState;
|
| + GrClipData* fLastClip;
|
| +
|
| + SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers;
|
| + GrDrawTarget* fDstGpu;
|
| + bool fClipSet;
|
|
|
| enum ClipProxyState {
|
| kUnknown_ClipProxyState,
|
|
|