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 GrBufferedDrawTarget_DEFINED | 8 #ifndef GrBufferedDrawTarget_DEFINED |
9 #define GrBufferedDrawTarget_DEFINED | 9 #define GrBufferedDrawTarget_DEFINED |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 SkChunkAlloc::kTh
row_AllocFailType); | 54 SkChunkAlloc::kTh
row_AllocFailType); |
55 SkASSERT(SkIsAlign4((uintptr_t)*xformsLocation)); | 55 SkASSERT(SkIsAlign4((uintptr_t)*xformsLocation)); |
56 memcpy(*xformsLocation, transformValues, count * xformBytes); | 56 memcpy(*xformsLocation, transformValues, count * xformBytes); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 private: | 60 private: |
61 friend class GrInOrderCommandBuilder; | 61 friend class GrInOrderCommandBuilder; |
62 friend class GrTargetCommands; | 62 friend class GrTargetCommands; |
63 | 63 |
64 typedef GrTargetCommands::State State; | 64 typedef GrTargetCommands::StateForPathDraw StateForPathDraw; |
65 | 65 |
66 State* allocState(const GrPrimitiveProcessor* primProc = NULL) { | 66 StateForPathDraw* allocState(const GrPrimitiveProcessor* primProc = NULL) { |
67 void* allocation = fPipelineBuffer.alloc(sizeof(State), SkChunkAlloc::kT
hrow_AllocFailType); | 67 void* allocation = fPipelineBuffer.alloc(sizeof(StateForPathDraw), |
68 return SkNEW_PLACEMENT_ARGS(allocation, State, (primProc)); | 68 SkChunkAlloc::kThrow_AllocFailT
ype); |
| 69 return SkNEW_PLACEMENT_ARGS(allocation, StateForPathDraw, (primProc)); |
69 } | 70 } |
70 | 71 |
71 void unallocState(State* state) { | 72 void unallocState(StateForPathDraw* state) { |
72 state->unref(); | 73 state->unref(); |
73 fPipelineBuffer.unalloc(state); | 74 fPipelineBuffer.unalloc(state); |
74 } | 75 } |
75 | 76 |
76 void onReset() override; | 77 void onReset() override; |
77 void onFlush() override; | 78 void onFlush() override; |
78 | 79 |
79 // overrides from GrDrawTarget | 80 // overrides from GrDrawTarget |
80 void onDrawBatch(GrBatch*, const PipelineInfo&) override; | 81 void onDrawBatch(GrBatch*) override; |
81 void onStencilPath(const GrPipelineBuilder&, | 82 void onStencilPath(const GrPipelineBuilder&, |
82 const GrPathProcessor*, | 83 const GrPathProcessor*, |
83 const GrPath*, | 84 const GrPath*, |
84 const GrScissorState&, | 85 const GrScissorState&, |
85 const GrStencilSettings&) override; | 86 const GrStencilSettings&) override; |
86 void onDrawPath(const GrPathProcessor*, | 87 void onDrawPath(const GrPathProcessor*, |
87 const GrPath*, | 88 const GrPath*, |
88 const GrStencilSettings&, | 89 const GrStencilSettings&, |
89 const PipelineInfo&) override; | 90 const PipelineInfo&) override; |
90 void onDrawPaths(const GrPathProcessor*, | 91 void onDrawPaths(const GrPathProcessor*, |
(...skipping 14 matching lines...) Expand all Loading... |
105 const SkIPoint& dstPoint) override; | 106 const SkIPoint& dstPoint) override; |
106 | 107 |
107 // Records any trace markers for a command | 108 // Records any trace markers for a command |
108 void recordTraceMarkersIfNecessary(GrTargetCommands::Cmd*); | 109 void recordTraceMarkersIfNecessary(GrTargetCommands::Cmd*); |
109 SkString getCmdString(int index) const { | 110 SkString getCmdString(int index) const { |
110 SkASSERT(index < fGpuCmdMarkers.count()); | 111 SkASSERT(index < fGpuCmdMarkers.count()); |
111 return fGpuCmdMarkers[index].toString(); | 112 return fGpuCmdMarkers[index].toString(); |
112 } | 113 } |
113 bool isIssued(uint32_t drawID) override { return drawID != fDrawID; } | 114 bool isIssued(uint32_t drawID) override { return drawID != fDrawID; } |
114 | 115 |
115 State* SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(const GrPrimitivePro
cessor*, | 116 StateForPathDraw* SK_WARN_UNUSED_RESULT createStateForPathDraw( |
116 const GrDrawTarget::
PipelineInfo&, | 117 const GrPrimitiveProcessor*, |
117 GrPipelineOptimizati
ons* opts); | 118 const GrDrawTarget::PipelineInfo&, |
118 State* SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrBatch*, | 119 GrPipelineOptimizations* opts); |
119 const GrDrawTarget::
PipelineInfo&, | |
120 GrPipelineOptimizati
ons* opts); | |
121 | 120 |
122 // TODO: Use a single allocator for commands and records | 121 // TODO: Use a single allocator for commands and records |
123 enum { | 122 enum { |
124 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 123 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
125 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 124 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
126 kPipelineBufferMinReserve = 32 * sizeof(State), | 125 kPipelineBufferMinReserve = 32 * sizeof(StateForPathDraw), |
127 }; | 126 }; |
128 | 127 |
129 // every 100 flushes we should reset our fPipelineBuffer to prevent us from
holding at a | 128 // every 100 flushes we should reset our fPipelineBuffer to prevent us from
holding at a |
130 // highwater mark | 129 // highwater mark |
131 static const int kPipelineBufferHighWaterMark = 100; | 130 static const int kPipelineBufferHighWaterMark = 100; |
132 | 131 |
133 SkAutoTDelete<GrCommandBuilder> fCommands; | 132 SkAutoTDelete<GrCommandBuilder> fCommands; |
134 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 133 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
135 SkChunkAlloc fPathIndexBuffer; | 134 SkChunkAlloc fPathIndexBuffer; |
136 SkChunkAlloc fPathTransformBuffer; | 135 SkChunkAlloc fPathTransformBuffer; |
137 SkChunkAlloc fPipelineBuffer; | 136 SkChunkAlloc fPipelineBuffer; |
138 uint32_t fDrawID; | 137 uint32_t fDrawID; |
139 SkAutoTUnref<State> fPrevState; | 138 SkAutoTUnref<StateForPathDraw> fPrevState; |
140 | 139 |
141 typedef GrClipTarget INHERITED; | 140 typedef GrClipTarget INHERITED; |
142 }; | 141 }; |
143 | 142 |
144 #endif | 143 #endif |
OLD | NEW |