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 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // Double check that it is in fact winding. | 49 // Double check that it is in fact winding. |
50 SkASSERT(kIncClamp_StencilOp == this->stencilSettings().passOp(pathFace)
); | 50 SkASSERT(kIncClamp_StencilOp == this->stencilSettings().passOp(pathFace)
); |
51 SkASSERT(kIncClamp_StencilOp == this->stencilSettings().failOp(pathFace)
); | 51 SkASSERT(kIncClamp_StencilOp == this->stencilSettings().failOp(pathFace)
); |
52 SkASSERT(0x1 != this->stencilSettings().writeMask(pathFace)); | 52 SkASSERT(0x1 != this->stencilSettings().writeMask(pathFace)); |
53 SkASSERT(!this->stencilSettings().isTwoSided()); | 53 SkASSERT(!this->stencilSettings().isTwoSided()); |
54 } | 54 } |
55 return isWinding; | 55 return isWinding; |
56 } | 56 } |
57 | 57 |
58 GrDrawPathRangeBatch::GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkM
atrix& localMatrix, | 58 GrDrawPathRangeBatch::GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkM
atrix& localMatrix, |
59 GrColor color, GrPathRangeDraw* pathR
angeDraw) | 59 GrColor color, GrPathRange* range, Gr
PathRangeDraw* draw) |
60 : INHERITED(ClassID(), viewMatrix, color) | 60 : INHERITED(ClassID(), viewMatrix, color) |
| 61 , fPathRange(range) |
61 , fDraws(4) | 62 , fDraws(4) |
62 , fLocalMatrix(localMatrix) { | 63 , fLocalMatrix(localMatrix) { |
63 SkDEBUGCODE(pathRangeDraw->fUsedInBatch = true;) | 64 SkDEBUGCODE(draw->fUsedInBatch = true;) |
64 fDraws.addToHead(SkRef(pathRangeDraw)); | 65 fDraws.addToHead(SkRef(draw)); |
65 fTotalPathCount = pathRangeDraw->count(); | 66 fTotalPathCount = draw->count(); |
66 // Don't compute a bounding box. For dst copy texture, we'll opt instead for
it to just copy | 67 // Don't compute a bounding box. For dst copy texture, we'll opt instead for
it to just copy |
67 // the entire dst. Realistically this is a moot point, because any context t
hat supports | 68 // the entire dst. Realistically this is a moot point, because any context t
hat supports |
68 // NV_path_rendering will also support NV_blend_equation_advanced. | 69 // NV_path_rendering will also support NV_blend_equation_advanced. |
69 // For clipping we'll just skip any optimizations based on the bounds. | 70 // For clipping we'll just skip any optimizations based on the bounds. |
70 fBounds.setLargest(); | 71 fBounds.setLargest(); |
71 } | 72 } |
72 | 73 |
73 bool GrDrawPathRangeBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { | 74 bool GrDrawPathRangeBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { |
74 GrDrawPathRangeBatch* that = t->cast<GrDrawPathRangeBatch>(); | 75 GrDrawPathRangeBatch* that = t->cast<GrDrawPathRangeBatch>(); |
| 76 if (this->fPathRange.get() != that->fPathRange.get()) { |
| 77 return false; |
| 78 } |
75 if (!GrPathRangeDraw::CanMerge(**this->fDraws.head(), **that->fDraws.head())
) { | 79 if (!GrPathRangeDraw::CanMerge(**this->fDraws.head(), **that->fDraws.head())
) { |
76 return false; | 80 return false; |
77 } | 81 } |
78 if (!GrPipeline::AreEqual(*this->pipeline(), *that->pipeline(), false)) { | 82 if (!GrPipeline::AreEqual(*this->pipeline(), *that->pipeline(), false)) { |
79 return false; | 83 return false; |
80 } | 84 } |
81 if (this->color() != that->color() || | 85 if (this->color() != that->color() || |
82 !this->viewMatrix().cheapEqualTo(that->viewMatrix()) || | 86 !this->viewMatrix().cheapEqualTo(that->viewMatrix()) || |
83 !fLocalMatrix.cheapEqualTo(that->fLocalMatrix)) { | 87 !fLocalMatrix.cheapEqualTo(that->fLocalMatrix)) { |
84 return false; | 88 return false; |
(...skipping 24 matching lines...) Expand all Loading... |
109 GrProgramDesc desc; | 113 GrProgramDesc desc; |
110 SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color()
, | 114 SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color()
, |
111 this->opts(), | 115 this->opts(), |
112 this->viewMat
rix(), | 116 this->viewMat
rix(), |
113 fLocalMatrix)
); | 117 fLocalMatrix)
); |
114 state->gpu()->buildProgramDesc(&desc, *pathProc, *this->pipeline()); | 118 state->gpu()->buildProgramDesc(&desc, *pathProc, *this->pipeline()); |
115 GrPathRendering::DrawPathArgs args(pathProc, this->pipeline(), | 119 GrPathRendering::DrawPathArgs args(pathProc, this->pipeline(), |
116 &desc, &this->stencilSettings()); | 120 &desc, &this->stencilSettings()); |
117 if (fDraws.count() == 1) { | 121 if (fDraws.count() == 1) { |
118 const GrPathRangeDraw& draw = **fDraws.head(); | 122 const GrPathRangeDraw& draw = **fDraws.head(); |
119 state->gpu()->pathRendering()->drawPaths(args, draw.range(), draw.indice
s(), | 123 state->gpu()->pathRendering()->drawPaths(args, fPathRange.get(), draw.in
dices(), |
120 GrPathRange::kU16_PathIndexType, draw.transforms(), draw.transformTy
pe(), | 124 GrPathRange::kU16_PathIndexType, draw.transforms(), draw.transformTy
pe(), |
121 draw.count()); | 125 draw.count()); |
122 return; | 126 return; |
123 } | 127 } |
124 | 128 |
125 const GrPathRange* range = (*fDraws.head())->range(); | |
126 GrPathRendering::PathTransformType transformType = (*fDraws.head())->transfo
rmType(); | 129 GrPathRendering::PathTransformType transformType = (*fDraws.head())->transfo
rmType(); |
127 int floatsPerTransform = GrPathRendering::PathTransformSize(transformType); | 130 int floatsPerTransform = GrPathRendering::PathTransformSize(transformType); |
128 SkAutoSTMalloc<512, float> transformStorage(floatsPerTransform * fTotalPathC
ount); | 131 SkAutoSTMalloc<512, float> transformStorage(floatsPerTransform * fTotalPathC
ount); |
129 SkAutoSTMalloc<256, uint16_t> indexStorage(fTotalPathCount); | 132 SkAutoSTMalloc<256, uint16_t> indexStorage(fTotalPathCount); |
130 uint16_t* indices = indexStorage.get(); | 133 uint16_t* indices = indexStorage.get(); |
131 float* transforms = transformStorage.get(); | 134 float* transforms = transformStorage.get(); |
132 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { | 135 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { |
133 SkASSERT((*iter.get())->transformType() == transformType); | 136 SkASSERT((*iter.get())->transformType() == transformType); |
134 SkASSERT((*iter.get())->range() == range); | |
135 int cnt = (*iter.get())->count(); | 137 int cnt = (*iter.get())->count(); |
136 memcpy(indices, (*iter.get())->indices(), cnt * sizeof(uint16_t)); | 138 memcpy(indices, (*iter.get())->indices(), cnt * sizeof(uint16_t)); |
137 indices += cnt; | 139 indices += cnt; |
138 memcpy(transforms, (*iter.get())->transforms(), cnt * floatsPerTransform
* sizeof(float)); | 140 memcpy(transforms, (*iter.get())->transforms(), cnt * floatsPerTransform
* sizeof(float)); |
139 transforms += cnt * floatsPerTransform; | 141 transforms += cnt * floatsPerTransform; |
140 } | 142 } |
141 SkASSERT(indices - indexStorage.get() == fTotalPathCount); | 143 SkASSERT(indices - indexStorage.get() == fTotalPathCount); |
142 state->gpu()->pathRendering()->drawPaths(args, range, indexStorage.get(), | 144 state->gpu()->pathRendering()->drawPaths(args, fPathRange.get(), indexStorag
e.get(), |
143 GrPathRange::kU16_PathIndexType, transformStorage.get(), transformType, | 145 GrPathRange::kU16_PathIndexType, transformStorage.get(), transformType, |
144 fTotalPathCount); | 146 fTotalPathCount); |
145 } | 147 } |
OLD | NEW |