| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // tracking for draws | 43 // tracking for draws |
| 44 DrawToken getCurrentDrawToken() 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) override; | 48 GrRenderTarget* renderTarget) override; |
| 49 | 49 |
| 50 void discard(GrRenderTarget*) override; | 50 void discard(GrRenderTarget*) override; |
| 51 | 51 |
| 52 protected: | 52 protected: |
| 53 void willReserveVertexAndIndexSpace(int vertexCount, | |
| 54 size_t vertexStride, | |
| 55 int indexCount) override; | |
| 56 | |
| 57 void appendIndicesAndTransforms(const void* indexValues, PathIndexType index
Type, | 53 void appendIndicesAndTransforms(const void* indexValues, PathIndexType index
Type, |
| 58 const float* transformValues, PathTransformT
ype transformType, | 54 const float* transformValues, PathTransformT
ype transformType, |
| 59 int count, char** indicesLocation, float** x
formsLocation) { | 55 int count, char** indicesLocation, float** x
formsLocation) { |
| 60 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); | 56 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); |
| 61 *indicesLocation = (char*) fPathIndexBuffer.alloc(count * indexBytes, | 57 *indicesLocation = (char*) fPathIndexBuffer.alloc(count * indexBytes, |
| 62 SkChunkAlloc::kThrow_A
llocFailType); | 58 SkChunkAlloc::kThrow_A
llocFailType); |
| 63 SkASSERT(SkIsAlign4((uintptr_t)*indicesLocation)); | 59 SkASSERT(SkIsAlign4((uintptr_t)*indicesLocation)); |
| 64 memcpy(*indicesLocation, reinterpret_cast<const char*>(indexValues), cou
nt * indexBytes); | 60 memcpy(*indicesLocation, reinterpret_cast<const char*>(indexValues), cou
nt * indexBytes); |
| 65 | 61 |
| 66 const int xformBytes = GrPathRendering::PathTransformSize(transformType)
* sizeof(float); | 62 const int xformBytes = GrPathRendering::PathTransformSize(transformType)
* sizeof(float); |
| 67 *xformsLocation = NULL; | 63 *xformsLocation = NULL; |
| 68 | 64 |
| 69 if (0 != xformBytes) { | 65 if (0 != xformBytes) { |
| 70 *xformsLocation = (float*) fPathTransformBuffer.alloc(count * xformB
ytes, | 66 *xformsLocation = (float*) fPathTransformBuffer.alloc(count * xformB
ytes, |
| 71 SkChunkAlloc::kTh
row_AllocFailType); | 67 SkChunkAlloc::kTh
row_AllocFailType); |
| 72 SkASSERT(SkIsAlign4((uintptr_t)*xformsLocation)); | 68 SkASSERT(SkIsAlign4((uintptr_t)*xformsLocation)); |
| 73 memcpy(*xformsLocation, transformValues, count * xformBytes); | 69 memcpy(*xformsLocation, transformValues, count * xformBytes); |
| 74 } | 70 } |
| 75 } | 71 } |
| 76 | 72 |
| 77 bool canConcatToIndexBuffer(const GrIndexBuffer** ib) { | |
| 78 const GrDrawTarget::GeometrySrcState& geomSrc = this->getGeomSrc(); | |
| 79 | |
| 80 // we only attempt to concat when reserved verts are used with a client-
specified | |
| 81 // index buffer. To make this work with client-specified VBs we'd need t
o know if the VB | |
| 82 // was updated between draws. | |
| 83 if (kReserved_GeometrySrcType != geomSrc.fVertexSrc || | |
| 84 kBuffer_GeometrySrcType != geomSrc.fIndexSrc) { | |
| 85 return false; | |
| 86 } | |
| 87 | |
| 88 *ib = geomSrc.fIndexBuffer; | |
| 89 return true; | |
| 90 } | |
| 91 | |
| 92 private: | 73 private: |
| 93 friend class GrTargetCommands; | 74 friend class GrTargetCommands; |
| 94 | 75 |
| 95 void onReset() override; | 76 void onReset() override; |
| 96 void onFlush() override; | 77 void onFlush() override; |
| 97 | 78 |
| 98 // overrides from GrDrawTarget | 79 // overrides from GrDrawTarget |
| 99 void onDraw(const GrGeometryProcessor*, const DrawInfo&, const PipelineInfo&
) override; | |
| 100 void onDrawBatch(GrBatch*, const PipelineInfo&) override; | 80 void onDrawBatch(GrBatch*, const PipelineInfo&) override; |
| 101 void onDrawRect(GrPipelineBuilder*, | 81 void onDrawRect(GrPipelineBuilder*, |
| 102 GrColor, | 82 GrColor, |
| 103 const SkMatrix& viewMatrix, | 83 const SkMatrix& viewMatrix, |
| 104 const SkRect& rect, | 84 const SkRect& rect, |
| 105 const SkRect* localRect, | 85 const SkRect* localRect, |
| 106 const SkMatrix* localMatrix) override; | 86 const SkMatrix* localMatrix) override; |
| 107 | 87 |
| 108 void onStencilPath(const GrPipelineBuilder&, | 88 void onStencilPath(const GrPipelineBuilder&, |
| 109 const GrPathProcessor*, | 89 const GrPathProcessor*, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 125 const PipelineInfo&) override; | 105 const PipelineInfo&) override; |
| 126 void onClear(const SkIRect* rect, | 106 void onClear(const SkIRect* rect, |
| 127 GrColor color, | 107 GrColor color, |
| 128 bool canIgnoreRect, | 108 bool canIgnoreRect, |
| 129 GrRenderTarget* renderTarget) override; | 109 GrRenderTarget* renderTarget) override; |
| 130 bool onCopySurface(GrSurface* dst, | 110 bool onCopySurface(GrSurface* dst, |
| 131 GrSurface* src, | 111 GrSurface* src, |
| 132 const SkIRect& srcRect, | 112 const SkIRect& srcRect, |
| 133 const SkIPoint& dstPoint) override; | 113 const SkIPoint& dstPoint) override; |
| 134 | 114 |
| 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. | |
| 137 int concatInstancedDraw(const DrawInfo&); | |
| 138 | |
| 139 // We lazily record clip changes in order to skip clips that have no effect. | 115 // We lazily record clip changes in order to skip clips that have no effect. |
| 140 void recordClipIfNecessary(); | 116 void recordClipIfNecessary(); |
| 141 // Records any trace markers for a command | 117 // Records any trace markers for a command |
| 142 void recordTraceMarkersIfNecessary(GrTargetCommands::Cmd*); | 118 void recordTraceMarkersIfNecessary(GrTargetCommands::Cmd*); |
| 143 SkString getCmdString(int index) const { | 119 SkString getCmdString(int index) const { |
| 144 SkASSERT(index < fGpuCmdMarkers.count()); | 120 SkASSERT(index < fGpuCmdMarkers.count()); |
| 145 return fGpuCmdMarkers[index].toString(); | 121 return fGpuCmdMarkers[index].toString(); |
| 146 } | 122 } |
| 147 bool isIssued(uint32_t drawID) override { return drawID != fDrawID; } | 123 bool isIssued(uint32_t drawID) override { return drawID != fDrawID; } |
| 148 | 124 |
| 149 // TODO: Use a single allocator for commands and records | 125 // TODO: Use a single allocator for commands and records |
| 150 enum { | 126 enum { |
| 151 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 127 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
| 152 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 128 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
| 153 }; | 129 }; |
| 154 | 130 |
| 155 GrTargetCommands fCommands; | 131 GrTargetCommands fCommands; |
| 156 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 132 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
| 157 SkChunkAlloc fPathIndexBuffer; | 133 SkChunkAlloc fPathIndexBuffer; |
| 158 SkChunkAlloc fPathTransformBuffer; | 134 SkChunkAlloc fPathTransformBuffer; |
| 159 uint32_t fDrawID; | 135 uint32_t fDrawID; |
| 160 | 136 |
| 161 typedef GrFlushToGpuDrawTarget INHERITED; | 137 typedef GrFlushToGpuDrawTarget INHERITED; |
| 162 }; | 138 }; |
| 163 | 139 |
| 164 #endif | 140 #endif |
| OLD | NEW |