| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 84 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 void onPrepareDraws(Target* target) const override { | 87 void onPrepareDraws(Target* target) const override { |
| 88 SkAutoTUnref<const GrGeometryProcessor> gp(create_gp(fOverrides.readsCov
erage())); | 88 SkAutoTUnref<const GrGeometryProcessor> gp(create_gp(fOverrides.readsCov
erage())); |
| 89 if (!gp) { | 89 if (!gp) { |
| 90 SkDebugf("Couldn't create GrGeometryProcessor\n"); | 90 SkDebugf("Couldn't create GrGeometryProcessor\n"); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 target->initDraw(gp, this->pipeline()); | 94 target->initDraw(gp, kTriangles_GrPrimitiveType); |
| 95 | 95 |
| 96 size_t vertexStride = gp->getVertexStride(); | 96 size_t vertexStride = gp->getVertexStride(); |
| 97 int instanceCount = fGeoData.count(); | 97 int instanceCount = fGeoData.count(); |
| 98 | 98 |
| 99 SkAutoTUnref<const GrIndexBuffer> indexBuffer( | 99 SkAutoTUnref<const GrIndexBuffer> indexBuffer( |
| 100 target->resourceProvider()->refQuadIndexBuffer()); | 100 target->resourceProvider()->refQuadIndexBuffer()); |
| 101 InstancedHelper helper; | 101 InstancedHelper helper; |
| 102 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS
tride, | 102 void* vertices = helper.init(target, vertexStride, indexBuffer, kVertsPe
rRect, |
| 103 indexBuffer, kVertsPerRect, | |
| 104 kIndicesPerRect, instanceCount * kRectsPerI
nstance); | 103 kIndicesPerRect, instanceCount * kRectsPerI
nstance); |
| 105 if (!vertices || !indexBuffer) { | 104 if (!vertices || !indexBuffer) { |
| 106 SkDebugf("Could not allocate vertices\n"); | 105 SkDebugf("Could not allocate vertices\n"); |
| 107 return; | 106 return; |
| 108 } | 107 } |
| 109 | 108 |
| 110 for (int i = 0; i < instanceCount; i++) { | 109 for (int i = 0; i < instanceCount; i++) { |
| 111 intptr_t verts = reinterpret_cast<intptr_t>(vertices) + | 110 intptr_t verts = reinterpret_cast<intptr_t>(vertices) + |
| 112 i * kRectsPerInstance * kVertsPerRect * vertexStrid
e; | 111 i * kRectsPerInstance * kVertsPerRect * vertexStrid
e; |
| 113 | 112 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 173 |
| 175 typedef GrVertexBatch INHERITED; | 174 typedef GrVertexBatch INHERITED; |
| 176 }; | 175 }; |
| 177 | 176 |
| 178 namespace GrNinePatch { | 177 namespace GrNinePatch { |
| 179 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid
th, int imageHeight, | 178 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid
th, int imageHeight, |
| 180 const SkIRect& center, const SkRect& dst) { | 179 const SkIRect& center, const SkRect& dst) { |
| 181 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight,
center, dst); | 180 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight,
center, dst); |
| 182 } | 181 } |
| 183 }; | 182 }; |
| OLD | NEW |