| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrInOrderDrawBuffer_DEFINED | 8 #ifndef GrInOrderDrawBuffer_DEFINED |
| 9 #define GrInOrderDrawBuffer_DEFINED | 9 #define GrInOrderDrawBuffer_DEFINED |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 * @param gpu the gpu object that this draw buffer flushes to. | 31 * @param gpu the gpu object that this draw buffer flushes to. |
| 32 * @param vertexPool pool where vertices for queued draws will be saved when | 32 * @param vertexPool pool where vertices for queued draws will be saved when |
| 33 * the vertex source is either reserved or array. | 33 * the vertex source is either reserved or array. |
| 34 * @param indexPool pool where indices for queued draws will be saved when | 34 * @param indexPool pool where indices for queued draws will be saved when |
| 35 * the index source is either reserved or array. | 35 * the index source is either reserved or array. |
| 36 */ | 36 */ |
| 37 GrInOrderDrawBuffer(GrGpu* gpu, | 37 GrInOrderDrawBuffer(GrGpu* gpu, |
| 38 GrVertexBufferAllocPool* vertexPool, | 38 GrVertexBufferAllocPool* vertexPool, |
| 39 GrIndexBufferAllocPool* indexPool); | 39 GrIndexBufferAllocPool* indexPool); |
| 40 | 40 |
| 41 ~GrInOrderDrawBuffer() SK_OVERRIDE; | 41 ~GrInOrderDrawBuffer() override; |
| 42 | 42 |
| 43 // tracking for draws | 43 // tracking for draws |
| 44 DrawToken getCurrentDrawToken() SK_OVERRIDE { return DrawToken(this, fDrawID
); } | 44 DrawToken getCurrentDrawToken() override { return DrawToken(this, fDrawID);
} |
| 45 | 45 |
| 46 void clearStencilClip(const SkIRect& rect, | 46 void clearStencilClip(const SkIRect& rect, |
| 47 bool insideClip, | 47 bool insideClip, |
| 48 GrRenderTarget* renderTarget) SK_OVERRIDE; | 48 GrRenderTarget* renderTarget) override; |
| 49 | 49 |
| 50 void discard(GrRenderTarget*) SK_OVERRIDE; | 50 void discard(GrRenderTarget*) override; |
| 51 | 51 |
| 52 protected: | 52 protected: |
| 53 void willReserveVertexAndIndexSpace(int vertexCount, | 53 void willReserveVertexAndIndexSpace(int vertexCount, |
| 54 size_t vertexStride, | 54 size_t vertexStride, |
| 55 int indexCount) SK_OVERRIDE; | 55 int indexCount) override; |
| 56 | 56 |
| 57 void appendIndicesAndTransforms(const void* indexValues, PathIndexType index
Type, | 57 void appendIndicesAndTransforms(const void* indexValues, PathIndexType index
Type, |
| 58 const float* transformValues, PathTransformT
ype transformType, | 58 const float* transformValues, PathTransformT
ype transformType, |
| 59 int count, char** indicesLocation, float** x
formsLocation) { | 59 int count, char** indicesLocation, float** x
formsLocation) { |
| 60 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); | 60 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); |
| 61 *indicesLocation = (char*) fPathIndexBuffer.alloc(count * indexBytes, | 61 *indicesLocation = (char*) fPathIndexBuffer.alloc(count * indexBytes, |
| 62 SkChunkAlloc::kThrow_A
llocFailType); | 62 SkChunkAlloc::kThrow_A
llocFailType); |
| 63 SkASSERT(SkIsAlign4((uintptr_t)*indicesLocation)); | 63 SkASSERT(SkIsAlign4((uintptr_t)*indicesLocation)); |
| 64 memcpy(*indicesLocation, reinterpret_cast<const char*>(indexValues), cou
nt * indexBytes); | 64 memcpy(*indicesLocation, reinterpret_cast<const char*>(indexValues), cou
nt * indexBytes); |
| 65 | 65 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 85 return false; | 85 return false; |
| 86 } | 86 } |
| 87 | 87 |
| 88 *ib = geomSrc.fIndexBuffer; | 88 *ib = geomSrc.fIndexBuffer; |
| 89 return true; | 89 return true; |
| 90 } | 90 } |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 friend class GrTargetCommands; | 93 friend class GrTargetCommands; |
| 94 | 94 |
| 95 void onReset() SK_OVERRIDE; | 95 void onReset() override; |
| 96 void onFlush() SK_OVERRIDE; | 96 void onFlush() override; |
| 97 | 97 |
| 98 // overrides from GrDrawTarget | 98 // overrides from GrDrawTarget |
| 99 void onDraw(const GrGeometryProcessor*, const DrawInfo&, const PipelineInfo&
) SK_OVERRIDE; | 99 void onDraw(const GrGeometryProcessor*, const DrawInfo&, const PipelineInfo&
) override; |
| 100 void onDrawBatch(GrBatch*, const PipelineInfo&) SK_OVERRIDE; | 100 void onDrawBatch(GrBatch*, const PipelineInfo&) override; |
| 101 void onDrawRect(GrPipelineBuilder*, | 101 void onDrawRect(GrPipelineBuilder*, |
| 102 GrColor, | 102 GrColor, |
| 103 const SkMatrix& viewMatrix, | 103 const SkMatrix& viewMatrix, |
| 104 const SkRect& rect, | 104 const SkRect& rect, |
| 105 const SkRect* localRect, | 105 const SkRect* localRect, |
| 106 const SkMatrix* localMatrix) SK_OVERRIDE; | 106 const SkMatrix* localMatrix) override; |
| 107 | 107 |
| 108 void onStencilPath(const GrPipelineBuilder&, | 108 void onStencilPath(const GrPipelineBuilder&, |
| 109 const GrPathProcessor*, | 109 const GrPathProcessor*, |
| 110 const GrPath*, | 110 const GrPath*, |
| 111 const GrScissorState&, | 111 const GrScissorState&, |
| 112 const GrStencilSettings&) SK_OVERRIDE; | 112 const GrStencilSettings&) override; |
| 113 void onDrawPath(const GrPathProcessor*, | 113 void onDrawPath(const GrPathProcessor*, |
| 114 const GrPath*, | 114 const GrPath*, |
| 115 const GrStencilSettings&, | 115 const GrStencilSettings&, |
| 116 const PipelineInfo&) SK_OVERRIDE; | 116 const PipelineInfo&) override; |
| 117 void onDrawPaths(const GrPathProcessor*, | 117 void onDrawPaths(const GrPathProcessor*, |
| 118 const GrPathRange*, | 118 const GrPathRange*, |
| 119 const void* indices, | 119 const void* indices, |
| 120 PathIndexType, | 120 PathIndexType, |
| 121 const float transformValues[], | 121 const float transformValues[], |
| 122 PathTransformType, | 122 PathTransformType, |
| 123 int count, | 123 int count, |
| 124 const GrStencilSettings&, | 124 const GrStencilSettings&, |
| 125 const PipelineInfo&) SK_OVERRIDE; | 125 const PipelineInfo&) override; |
| 126 void onClear(const SkIRect* rect, | 126 void onClear(const SkIRect* rect, |
| 127 GrColor color, | 127 GrColor color, |
| 128 bool canIgnoreRect, | 128 bool canIgnoreRect, |
| 129 GrRenderTarget* renderTarget) SK_OVERRIDE; | 129 GrRenderTarget* renderTarget) override; |
| 130 bool onCopySurface(GrSurface* dst, | 130 bool onCopySurface(GrSurface* dst, |
| 131 GrSurface* src, | 131 GrSurface* src, |
| 132 const SkIRect& srcRect, | 132 const SkIRect& srcRect, |
| 133 const SkIPoint& dstPoint) SK_OVERRIDE; | 133 const SkIPoint& dstPoint) override; |
| 134 | 134 |
| 135 // Attempts to concat instances from info onto the previous draw. info must
represent an | 135 // Attempts to concat instances from info onto the previous draw. info must
represent an |
| 136 // instanced draw. The caller must have already recorded a new draw state an
d clip if necessary. | 136 // instanced draw. The caller must have already recorded a new draw state an
d clip if necessary. |
| 137 int concatInstancedDraw(const DrawInfo&); | 137 int concatInstancedDraw(const DrawInfo&); |
| 138 | 138 |
| 139 // We lazily record clip changes in order to skip clips that have no effect. | 139 // We lazily record clip changes in order to skip clips that have no effect. |
| 140 void recordClipIfNecessary(); | 140 void recordClipIfNecessary(); |
| 141 // Records any trace markers for a command | 141 // Records any trace markers for a command |
| 142 void recordTraceMarkersIfNecessary(GrTargetCommands::Cmd*); | 142 void recordTraceMarkersIfNecessary(GrTargetCommands::Cmd*); |
| 143 SkString getCmdString(int index) const { | 143 SkString getCmdString(int index) const { |
| 144 SkASSERT(index < fGpuCmdMarkers.count()); | 144 SkASSERT(index < fGpuCmdMarkers.count()); |
| 145 return fGpuCmdMarkers[index].toString(); | 145 return fGpuCmdMarkers[index].toString(); |
| 146 } | 146 } |
| 147 bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; } | 147 bool isIssued(uint32_t drawID) override { return drawID != fDrawID; } |
| 148 | 148 |
| 149 // TODO: Use a single allocator for commands and records | 149 // TODO: Use a single allocator for commands and records |
| 150 enum { | 150 enum { |
| 151 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 151 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
| 152 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 152 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 GrTargetCommands fCommands; | 155 GrTargetCommands fCommands; |
| 156 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 156 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
| 157 SkChunkAlloc fPathIndexBuffer; | 157 SkChunkAlloc fPathIndexBuffer; |
| 158 SkChunkAlloc fPathTransformBuffer; | 158 SkChunkAlloc fPathTransformBuffer; |
| 159 uint32_t fDrawID; | 159 uint32_t fDrawID; |
| 160 | 160 |
| 161 typedef GrFlushToGpuDrawTarget INHERITED; | 161 typedef GrFlushToGpuDrawTarget INHERITED; |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 #endif | 164 #endif |
| OLD | NEW |