Chromium Code Reviews| Index: src/gpu/GrInOrderDrawBuffer.h |
| diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h |
| index ed62a93247bb2c63bf0a5b79c233515fe02a26e0..ebde2429653fb45ae1b7a9ef0819618807ff3a9a 100644 |
| --- a/src/gpu/GrInOrderDrawBuffer.h |
| +++ b/src/gpu/GrInOrderDrawBuffer.h |
| @@ -55,6 +55,10 @@ public: |
| virtual ~GrInOrderDrawBuffer(); |
| + GrGpu* dstGpu() const { return fDstGpu; } |
| + const uint32_t* pathIndexBuffer() const { return fPathIndexBuffer; } |
| + const float* pathTransformBuffer() const { return fPathTransformBuffer; } |
| + |
| /** |
| * Empties the draw buffer of any queued up draws. This must not be called while inside an |
| * unbalanced pushGeometrySource(). The current draw state and clip are preserved. |
| @@ -110,7 +114,7 @@ private: |
| Cmd(uint8_t type) : fType(type) {} |
| virtual ~Cmd() {} |
| - virtual void execute(GrGpu*) = 0; |
| + virtual void execute(GrInOrderDrawBuffer*) = 0; |
| uint8_t fType; |
| }; |
| @@ -129,7 +133,7 @@ private: |
| const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); } |
| const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); } |
| - virtual void execute(GrGpu*); |
| + virtual void execute(GrInOrderDrawBuffer*); |
| DrawInfo fInfo; |
| ScissorState fScissorState; |
| @@ -144,7 +148,7 @@ private: |
| const GrPath* path() const { return fPath.get(); } |
| - virtual void execute(GrGpu*); |
| + virtual void execute(GrInOrderDrawBuffer*); |
| ScissorState fScissorState; |
| GrStencilSettings fStencilSettings; |
| @@ -158,7 +162,7 @@ private: |
| const GrPath* path() const { return fPath.get(); } |
| - virtual void execute(GrGpu*); |
| + virtual void execute(GrInOrderDrawBuffer*); |
| GrDeviceCoordTexture fDstCopy; |
| ScissorState fScissorState; |
| @@ -172,12 +176,12 @@ private: |
| DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRange(pathRange) {} |
| const GrPathRange* pathRange() const { return fPathRange.get(); } |
| - uint32_t* indices() { return reinterpret_cast<uint32_t*>(CmdBuffer::GetDataForItem(this)); } |
| - float* transforms() { return reinterpret_cast<float*>(&this->indices()[fCount]); } |
| - virtual void execute(GrGpu*); |
| + virtual void execute(GrInOrderDrawBuffer*); |
| + int fIndicesLocation; |
| size_t fCount; |
| + int fTransformsLocation; |
| PathTransformType fTransformsType; |
| GrDeviceCoordTexture fDstCopy; |
| ScissorState fScissorState; |
| @@ -193,7 +197,7 @@ private: |
| GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } |
| - virtual void execute(GrGpu*); |
| + virtual void execute(GrInOrderDrawBuffer*); |
| SkIRect fRect; |
| GrColor fColor; |
| @@ -209,7 +213,7 @@ private: |
| GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } |
| - virtual void execute(GrGpu*); |
| + virtual void execute(GrInOrderDrawBuffer*); |
| SkIRect fRect; |
| bool fInsideClip; |
| @@ -224,7 +228,7 @@ private: |
| GrSurface* dst() const { return fDst.get(); } |
| GrSurface* src() const { return fSrc.get(); } |
| - virtual void execute(GrGpu*); |
| + virtual void execute(GrInOrderDrawBuffer*); |
| SkIPoint fDstPoint; |
| SkIRect fSrcRect; |
| @@ -237,7 +241,7 @@ private: |
| struct SetState : public Cmd { |
| SetState(const GrDrawState& state) : Cmd(kSetState_Cmd), fState(state) {} |
| - virtual void execute(GrGpu*); |
| + virtual void execute(GrInOrderDrawBuffer*); |
| GrDrawState fState; |
| }; |
| @@ -299,6 +303,8 @@ private: |
| // TODO: Use a single allocator for commands and records |
| enum { |
| kCmdBufferInitialSizeInBytes = 8 * 1024, |
| + kPathIdxBufferMinAllocCnt = 64, |
| + kPathXformBufferMinAllocCnt = 2 * kPathIdxBufferMinAllocCnt, |
| kGeoPoolStatePreAllocCnt = 4, |
| }; |
| @@ -309,6 +315,22 @@ private: |
| GrVertexBufferAllocPool& fVertexPool; |
| GrIndexBufferAllocPool& fIndexPool; |
| + template<typename T> class DataBuffer : SkNoncopyable { |
|
bsalomon
2014/11/11 14:41:25
Could you use SkTDArray here instead of a new type
Chris Dalton
2014/11/11 17:49:07
I did look into this.
* SkTDArray doesn't grow ex
|
| + public: |
| + DataBuffer(int minAllocCnt) : fMinAllocCnt(minAllocCnt), fAllocCnt(0), fCount(0) {} |
| + operator const T*() const { return fBuffer; } |
| + int append(const T* array, int count); |
| + void reset(); |
| + private: |
| + SkAutoTMalloc<T> fBuffer; |
| + const int fMinAllocCnt; |
| + int fAllocCnt; |
| + int fCount; |
| + }; |
| + |
| + DataBuffer<uint32_t> fPathIndexBuffer; |
| + DataBuffer<float> fPathTransformBuffer; |
| + |
| struct GeometryPoolState { |
| const GrVertexBuffer* fPoolVertexBuffer; |
| int fPoolStartVertex; |