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 "GrNinePatch.h" | 8 #include "GrNinePatch.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 sk_sp<GrGeometryProcessor> gp(create_gp(fOverrides.readsCoverage())); | 75 sk_sp<GrGeometryProcessor> gp(create_gp(fOverrides.readsCoverage())); |
76 if (!gp) { | 76 if (!gp) { |
77 SkDebugf("Couldn't create GrGeometryProcessor\n"); | 77 SkDebugf("Couldn't create GrGeometryProcessor\n"); |
78 return; | 78 return; |
79 } | 79 } |
80 | 80 |
81 size_t vertexStride = gp->getVertexStride(); | 81 size_t vertexStride = gp->getVertexStride(); |
82 int patchCnt = fPatches.count(); | 82 int patchCnt = fPatches.count(); |
83 int numRects = 0; | 83 int numRects = 0; |
84 for (int i = 0; i < patchCnt; i++) { | 84 for (int i = 0; i < patchCnt; i++) { |
85 numRects += fPatches[i].fIter->numRects(); | 85 numRects += fPatches[i].fIter->numRectsToDraw(); |
86 } | 86 } |
87 | 87 |
88 SkAutoTUnref<const GrBuffer> indexBuffer( | 88 SkAutoTUnref<const GrBuffer> indexBuffer( |
89 target->resourceProvider()->refQuadIndexBuffer()); | 89 target->resourceProvider()->refQuadIndexBuffer()); |
90 InstancedHelper helper; | 90 InstancedHelper helper; |
91 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS
tride, | 91 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS
tride, |
92 indexBuffer, kVertsPerRect, | 92 indexBuffer, kVertsPerRect, |
93 kIndicesPerRect, numRects); | 93 kIndicesPerRect, numRects); |
94 if (!vertices || !indexBuffer) { | 94 if (!vertices || !indexBuffer) { |
95 SkDebugf("Could not allocate vertices\n"); | 95 SkDebugf("Could not allocate vertices\n"); |
(...skipping 29 matching lines...) Expand all Loading... |
125 *vertColor = patch.fColor; | 125 *vertColor = patch.fColor; |
126 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride)
; | 126 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride)
; |
127 } | 127 } |
128 verts += kVertsPerRect * vertexStride; | 128 verts += kVertsPerRect * vertexStride; |
129 } | 129 } |
130 | 130 |
131 // If we didn't handle it above, apply the matrix here. | 131 // If we didn't handle it above, apply the matrix here. |
132 if (!isScaleTranslate) { | 132 if (!isScaleTranslate) { |
133 SkPoint* positions = reinterpret_cast<SkPoint*>(patchVerts); | 133 SkPoint* positions = reinterpret_cast<SkPoint*>(patchVerts); |
134 patch.fViewMatrix.mapPointsWithStride(positions, vertexStride, | 134 patch.fViewMatrix.mapPointsWithStride(positions, vertexStride, |
135 kVertsPerRect * patch.fIte
r->numRects()); | 135 kVertsPerRect * patch.fIter->numRectsToDraw()); |
136 } | 136 } |
137 } | 137 } |
138 helper.recordDraw(target, gp.get()); | 138 helper.recordDraw(target, gp.get()); |
139 } | 139 } |
140 | 140 |
141 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 141 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
142 overrides.getOverrideColorIfSet(&fPatches[0].fColor); | 142 overrides.getOverrideColorIfSet(&fPatches[0].fColor); |
143 fOverrides = overrides; | 143 fOverrides = overrides; |
144 } | 144 } |
145 | 145 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 typedef GrVertexBatch INHERITED; | 179 typedef GrVertexBatch INHERITED; |
180 }; | 180 }; |
181 | 181 |
182 namespace GrNinePatch { | 182 namespace GrNinePatch { |
183 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid
th, int imageHeight, | 183 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid
th, int imageHeight, |
184 std::unique_ptr<SkLatticeIter> iter, const SkRect& dst)
{ | 184 std::unique_ptr<SkLatticeIter> iter, const SkRect& dst)
{ |
185 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight,
std::move(iter), | 185 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight,
std::move(iter), |
186 dst); | 186 dst); |
187 } | 187 } |
188 }; | 188 }; |
OLD | NEW |