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->overrid
es(), |
21 this->viewMat
rix())); | 21 this->viewMat
rix())); |
22 state->gpu()->buildProgramDesc(&desc, *pathProc, *this->pipeline()); | 22 state->gpu()->buildProgramDesc(&desc, *pathProc, *this->pipeline()); |
23 GrPathRendering::DrawPathArgs args(pathProc, this->pipeline(), | 23 GrPathRendering::DrawPathArgs args(pathProc, this->pipeline(), |
24 &desc, &this->stencilSettings()); | 24 &desc, &this->stencilSettings()); |
25 state->gpu()->pathRendering()->drawPath(args, fPath.get()); | 25 state->gpu()->pathRendering()->drawPath(args, fPath.get()); |
26 } | 26 } |
27 | 27 |
28 GrDrawPathRangeBatch::~GrDrawPathRangeBatch() { | 28 GrDrawPathRangeBatch::~GrDrawPathRangeBatch() { |
29 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { | 29 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { |
30 (*iter.get())->unref(); | 30 (*iter.get())->unref(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 88 } |
89 // TODO: Check some other things here. (winding, opaque, pathProc color, vm,
...) | 89 // TODO: Check some other things here. (winding, opaque, pathProc color, vm,
...) |
90 // Try to combine this call with the previous DrawPaths. We do this by stenc
iling all the | 90 // Try to combine this call with the previous DrawPaths. We do this by stenc
iling all the |
91 // paths together and then covering them in a single pass. This is not equiv
alent to two | 91 // paths together and then covering them in a single pass. This is not equiv
alent to two |
92 // separate draw calls, so we can only do it if there is no blending (no ove
rlap would also | 92 // separate draw calls, so we can only do it if there is no blending (no ove
rlap would also |
93 // work). Note that it's also possible for overlapping paths to cancel each
other's winding | 93 // work). Note that it's also possible for overlapping paths to cancel each
other's winding |
94 // numbers, and we only partially account for this by not allowing even/odd
paths to be | 94 // numbers, and we only partially account for this by not allowing even/odd
paths to be |
95 // combined. (Glyphs in the same font tend to wind the same direction so it
works out OK.) | 95 // combined. (Glyphs in the same font tend to wind the same direction so it
works out OK.) |
96 if (!this->isWinding() || | 96 if (!this->isWinding() || |
97 this->stencilSettings() != that->stencilSettings() || | 97 this->stencilSettings() != that->stencilSettings() || |
98 this->opts().willColorBlendWithDst()) { | 98 this->overrides().willColorBlendWithDst()) { |
99 return false; | 99 return false; |
100 } | 100 } |
101 SkASSERT(!that->opts().willColorBlendWithDst()); | 101 SkASSERT(!that->overrides().willColorBlendWithDst()); |
102 fTotalPathCount += that->fTotalPathCount; | 102 fTotalPathCount += that->fTotalPathCount; |
103 while (GrPathRangeDraw** head = that->fDraws.head()) { | 103 while (GrPathRangeDraw** head = that->fDraws.head()) { |
104 fDraws.addToTail(*head); | 104 fDraws.addToTail(*head); |
105 // We're stealing that's refs, so pop without unreffing. | 105 // We're stealing that's refs, so pop without unreffing. |
106 that->fDraws.popHead(); | 106 that->fDraws.popHead(); |
107 } | 107 } |
108 return true; | 108 return true; |
109 } | 109 } |
110 | 110 |
111 void GrDrawPathRangeBatch::onDraw(GrBatchFlushState* state) { | 111 void GrDrawPathRangeBatch::onDraw(GrBatchFlushState* state) { |
112 GrProgramDesc desc; | 112 GrProgramDesc desc; |
113 SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color()
, | 113 SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color()
, |
114 this->opts(), | 114 this->overrid
es(), |
115 this->viewMat
rix(), | 115 this->viewMat
rix(), |
116 fLocalMatrix)
); | 116 fLocalMatrix)
); |
117 state->gpu()->buildProgramDesc(&desc, *pathProc, *this->pipeline()); | 117 state->gpu()->buildProgramDesc(&desc, *pathProc, *this->pipeline()); |
118 GrPathRendering::DrawPathArgs args(pathProc, this->pipeline(), | 118 GrPathRendering::DrawPathArgs args(pathProc, this->pipeline(), |
119 &desc, &this->stencilSettings()); | 119 &desc, &this->stencilSettings()); |
120 if (fDraws.count() == 1) { | 120 if (fDraws.count() == 1) { |
121 const GrPathRangeDraw& draw = **fDraws.head(); | 121 const GrPathRangeDraw& draw = **fDraws.head(); |
122 state->gpu()->pathRendering()->drawPaths(args, fPathRange.get(), draw.in
dices(), | 122 state->gpu()->pathRendering()->drawPaths(args, fPathRange.get(), draw.in
dices(), |
123 GrPathRange::kU16_PathIndexType, draw.transforms(), draw.transformTy
pe(), | 123 GrPathRange::kU16_PathIndexType, draw.transforms(), draw.transformTy
pe(), |
124 draw.count()); | 124 draw.count()); |
(...skipping 12 matching lines...) Expand all Loading... |
137 memcpy(indices, (*iter.get())->indices(), cnt * sizeof(uint16_t)); | 137 memcpy(indices, (*iter.get())->indices(), cnt * sizeof(uint16_t)); |
138 indices += cnt; | 138 indices += cnt; |
139 memcpy(transforms, (*iter.get())->transforms(), cnt * floatsPerTransform
* sizeof(float)); | 139 memcpy(transforms, (*iter.get())->transforms(), cnt * floatsPerTransform
* sizeof(float)); |
140 transforms += cnt * floatsPerTransform; | 140 transforms += cnt * floatsPerTransform; |
141 } | 141 } |
142 SkASSERT(indices - indexStorage.get() == fTotalPathCount); | 142 SkASSERT(indices - indexStorage.get() == fTotalPathCount); |
143 state->gpu()->pathRendering()->drawPaths(args, fPathRange.get(), indexStorag
e.get(), | 143 state->gpu()->pathRendering()->drawPaths(args, fPathRange.get(), indexStorag
e.get(), |
144 GrPathRange::kU16_PathIndexType, transformStorage.get(), transformType, | 144 GrPathRange::kU16_PathIndexType, transformStorage.get(), transformType, |
145 fTotalPathCount); | 145 fTotalPathCount); |
146 } | 146 } |
OLD | NEW |