OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "GrDrawPathBatch.h" | 8 #include "GrDrawPathBatch.h" |
9 | 9 |
10 SkString GrDrawPathBatch::dumpInfo() const { | 10 SkString GrDrawPathBatch::dumpInfo() const { |
11 SkString string; | 11 SkString string; |
12 string.printf("PATH: 0x%p", fPath.get()); | 12 string.printf("PATH: 0x%p", fPath.get()); |
13 return string; | 13 return string; |
14 } | 14 } |
15 | 15 |
16 void GrDrawPathBatch::onDraw(GrBatchFlushState* state) { | 16 void GrDrawPathBatch::onDraw(GrBatchFlushState* state) { |
17 GrProgramDesc desc; | 17 GrProgramDesc desc; |
18 | 18 |
19 SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color()
, | 19 SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color()
, |
20 this->opts(), | 20 this->opts(), |
21 this->viewMat
rix())); | 21 this->viewMat
rix())); |
22 state->gpu()->buildProgramDesc(&desc, *pathProc, | 22 state->gpu()->buildProgramDesc(&desc, *pathProc, *this->pipeline()); |
23 *this->pipeline(), *this->tracker()); | |
24 GrPathRendering::DrawPathArgs args(pathProc, this->pipeline(), | 23 GrPathRendering::DrawPathArgs args(pathProc, this->pipeline(), |
25 &desc, this->tracker(), &this->stencilSe
ttings()); | 24 &desc, &this->stencilSettings()); |
26 state->gpu()->pathRendering()->drawPath(args, fPath.get()); | 25 state->gpu()->pathRendering()->drawPath(args, fPath.get()); |
27 } | 26 } |
28 | 27 |
29 GrDrawPathRangeBatch::~GrDrawPathRangeBatch() { | 28 GrDrawPathRangeBatch::~GrDrawPathRangeBatch() { |
30 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { | 29 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { |
31 (*iter.get())->unref(); | 30 (*iter.get())->unref(); |
32 } | 31 } |
33 } | 32 } |
34 | 33 |
35 SkString GrDrawPathRangeBatch::dumpInfo() const { | 34 SkString GrDrawPathRangeBatch::dumpInfo() const { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 105 } |
107 return true; | 106 return true; |
108 } | 107 } |
109 | 108 |
110 void GrDrawPathRangeBatch::onDraw(GrBatchFlushState* state) { | 109 void GrDrawPathRangeBatch::onDraw(GrBatchFlushState* state) { |
111 GrProgramDesc desc; | 110 GrProgramDesc desc; |
112 SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color()
, | 111 SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color()
, |
113 this->opts(), | 112 this->opts(), |
114 this->viewMat
rix(), | 113 this->viewMat
rix(), |
115 fLocalMatrix)
); | 114 fLocalMatrix)
); |
116 state->gpu()->buildProgramDesc(&desc, *pathProc, *this->pipeline(), | 115 state->gpu()->buildProgramDesc(&desc, *pathProc, *this->pipeline()); |
117 *this->tracker()); | |
118 GrPathRendering::DrawPathArgs args(pathProc, this->pipeline(), | 116 GrPathRendering::DrawPathArgs args(pathProc, this->pipeline(), |
119 &desc, this->tracker(), &this->stencilSe
ttings()); | 117 &desc, &this->stencilSettings()); |
120 if (fDraws.count() == 1) { | 118 if (fDraws.count() == 1) { |
121 const GrPathRangeDraw& draw = **fDraws.head(); | 119 const GrPathRangeDraw& draw = **fDraws.head(); |
122 state->gpu()->pathRendering()->drawPaths(args, draw.range(), draw.indice
s(), | 120 state->gpu()->pathRendering()->drawPaths(args, draw.range(), draw.indice
s(), |
123 GrPathRange::kU16_PathIndexType, draw.transforms(), draw.transformTy
pe(), | 121 GrPathRange::kU16_PathIndexType, draw.transforms(), draw.transformTy
pe(), |
124 draw.count()); | 122 draw.count()); |
125 return; | 123 return; |
126 } | 124 } |
127 | 125 |
128 const GrPathRange* range = (*fDraws.head())->range(); | 126 const GrPathRange* range = (*fDraws.head())->range(); |
129 GrPathRendering::PathTransformType transformType = (*fDraws.head())->transfo
rmType(); | 127 GrPathRendering::PathTransformType transformType = (*fDraws.head())->transfo
rmType(); |
130 int floatsPerTransform = GrPathRendering::PathTransformSize(transformType); | 128 int floatsPerTransform = GrPathRendering::PathTransformSize(transformType); |
131 SkAutoSTMalloc<512, float> transformStorage(floatsPerTransform * fTotalPathC
ount); | 129 SkAutoSTMalloc<512, float> transformStorage(floatsPerTransform * fTotalPathC
ount); |
132 SkAutoSTMalloc<256, uint16_t> indexStorage(fTotalPathCount); | 130 SkAutoSTMalloc<256, uint16_t> indexStorage(fTotalPathCount); |
133 uint16_t* indices = indexStorage.get(); | 131 uint16_t* indices = indexStorage.get(); |
134 float* transforms = transformStorage.get(); | 132 float* transforms = transformStorage.get(); |
135 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { | 133 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { |
136 SkASSERT((*iter.get())->transformType() == transformType); | 134 SkASSERT((*iter.get())->transformType() == transformType); |
137 SkASSERT((*iter.get())->range() == range); | 135 SkASSERT((*iter.get())->range() == range); |
138 int cnt = (*iter.get())->count(); | 136 int cnt = (*iter.get())->count(); |
139 memcpy(indices, (*iter.get())->indices(), cnt * sizeof(uint16_t)); | 137 memcpy(indices, (*iter.get())->indices(), cnt * sizeof(uint16_t)); |
140 indices += cnt; | 138 indices += cnt; |
141 memcpy(transforms, (*iter.get())->transforms(), cnt * floatsPerTransform
* sizeof(float)); | 139 memcpy(transforms, (*iter.get())->transforms(), cnt * floatsPerTransform
* sizeof(float)); |
142 transforms += cnt * floatsPerTransform; | 140 transforms += cnt * floatsPerTransform; |
143 } | 141 } |
144 SkASSERT(indices - indexStorage.get() == fTotalPathCount); | 142 SkASSERT(indices - indexStorage.get() == fTotalPathCount); |
145 state->gpu()->pathRendering()->drawPaths(args, range, indexStorage.get(), | 143 state->gpu()->pathRendering()->drawPaths(args, range, indexStorage.get(), |
146 GrPathRange::kU16_PathIndexType, transformStorage.get(), transformType, | 144 GrPathRange::kU16_PathIndexType, transformStorage.get(), transformType, |
147 fTotalPathCount); | 145 fTotalPathCount); |
148 } | 146 } |
OLD | NEW |