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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 if (0 != xformBytes) { | 65 if (0 != xformBytes) { |
66 *xformsLocation = (float*) fPathTransformBuffer.alloc(count * xformB
ytes, | 66 *xformsLocation = (float*) fPathTransformBuffer.alloc(count * xformB
ytes, |
67 SkChunkAlloc::kTh
row_AllocFailType); | 67 SkChunkAlloc::kTh
row_AllocFailType); |
68 SkASSERT(SkIsAlign4((uintptr_t)*xformsLocation)); | 68 SkASSERT(SkIsAlign4((uintptr_t)*xformsLocation)); |
69 memcpy(*xformsLocation, transformValues, count * xformBytes); | 69 memcpy(*xformsLocation, transformValues, count * xformBytes); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 private: | 73 private: |
74 friend class GrTargetCommands; | 74 friend class GrTargetCommands; |
| 75 typedef GrTargetCommands::State State; |
| 76 |
| 77 State* allocState(const GrPrimitiveProcessor* primProc = NULL) { |
| 78 void* allocation = fPipelineBuffer.alloc(sizeof(State), SkChunkAlloc::kT
hrow_AllocFailType); |
| 79 return SkNEW_PLACEMENT_ARGS(allocation, State, (primProc)); |
| 80 } |
| 81 |
| 82 void unallocState(State* state) { |
| 83 state->unref(); |
| 84 fPipelineBuffer.unalloc(state); |
| 85 } |
75 | 86 |
76 void onReset() override; | 87 void onReset() override; |
77 void onFlush() override; | 88 void onFlush() override; |
78 | 89 |
79 // overrides from GrDrawTarget | 90 // overrides from GrDrawTarget |
80 void onDrawBatch(GrBatch*, const PipelineInfo&) override; | 91 void onDrawBatch(GrBatch*, const PipelineInfo&) override; |
81 void onDrawRect(GrPipelineBuilder*, | 92 void onDrawRect(GrPipelineBuilder*, |
82 GrColor, | 93 GrColor, |
83 const SkMatrix& viewMatrix, | 94 const SkMatrix& viewMatrix, |
84 const SkRect& rect, | 95 const SkRect& rect, |
85 const SkRect* localRect, | 96 const SkRect* localRect, |
86 const SkMatrix* localMatrix) override; | 97 const SkMatrix* localMatrix) override; |
87 | |
88 void onStencilPath(const GrPipelineBuilder&, | 98 void onStencilPath(const GrPipelineBuilder&, |
89 const GrPathProcessor*, | 99 const GrPathProcessor*, |
90 const GrPath*, | 100 const GrPath*, |
91 const GrScissorState&, | 101 const GrScissorState&, |
92 const GrStencilSettings&) override; | 102 const GrStencilSettings&) override; |
93 void onDrawPath(const GrPathProcessor*, | 103 void onDrawPath(const GrPathProcessor*, |
94 const GrPath*, | 104 const GrPath*, |
95 const GrStencilSettings&, | 105 const GrStencilSettings&, |
96 const PipelineInfo&) override; | 106 const PipelineInfo&) override; |
97 void onDrawPaths(const GrPathProcessor*, | 107 void onDrawPaths(const GrPathProcessor*, |
(...skipping 17 matching lines...) Expand all Loading... |
115 // We lazily record clip changes in order to skip clips that have no effect. | 125 // We lazily record clip changes in order to skip clips that have no effect. |
116 void recordClipIfNecessary(); | 126 void recordClipIfNecessary(); |
117 // Records any trace markers for a command | 127 // Records any trace markers for a command |
118 void recordTraceMarkersIfNecessary(GrTargetCommands::Cmd*); | 128 void recordTraceMarkersIfNecessary(GrTargetCommands::Cmd*); |
119 SkString getCmdString(int index) const { | 129 SkString getCmdString(int index) const { |
120 SkASSERT(index < fGpuCmdMarkers.count()); | 130 SkASSERT(index < fGpuCmdMarkers.count()); |
121 return fGpuCmdMarkers[index].toString(); | 131 return fGpuCmdMarkers[index].toString(); |
122 } | 132 } |
123 bool isIssued(uint32_t drawID) override { return drawID != fDrawID; } | 133 bool isIssued(uint32_t drawID) override { return drawID != fDrawID; } |
124 | 134 |
| 135 State* SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(const GrPrimitivePro
cessor*, |
| 136 const GrDrawTarget::
PipelineInfo&); |
| 137 State* SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrBatch*, |
| 138 const GrDrawTarget::
PipelineInfo&); |
| 139 |
125 // TODO: Use a single allocator for commands and records | 140 // TODO: Use a single allocator for commands and records |
126 enum { | 141 enum { |
127 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 142 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
128 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 143 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
| 144 kPipelineBufferMinReserve = 32 * sizeof(State), |
129 }; | 145 }; |
130 | 146 |
| 147 // every 100 flushes we should reset our fPipelineBuffer to prevent us from
holding at a |
| 148 // highwater mark |
| 149 static const int kPipelineBufferHighWaterMark = 100; |
| 150 |
131 GrTargetCommands fCommands; | 151 GrTargetCommands fCommands; |
132 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 152 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
133 SkChunkAlloc fPathIndexBuffer; | 153 SkChunkAlloc fPathIndexBuffer; |
134 SkChunkAlloc fPathTransformBuffer; | 154 SkChunkAlloc fPathTransformBuffer; |
| 155 SkChunkAlloc fPipelineBuffer; |
135 uint32_t fDrawID; | 156 uint32_t fDrawID; |
| 157 SkAutoTUnref<State> fPrevState; |
136 | 158 |
137 typedef GrClipTarget INHERITED; | 159 typedef GrClipTarget INHERITED; |
138 }; | 160 }; |
139 | 161 |
140 #endif | 162 #endif |
OLD | NEW |