OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 5, 6, 10, 5, 10, 9 | 1204 5, 6, 10, 5, 10, 9 |
1205 }; | 1205 }; |
1206 | 1206 |
1207 static const int kIndicesPerStrokeRRect = SK_ARRAY_COUNT(gRRectIndices) - 6; | 1207 static const int kIndicesPerStrokeRRect = SK_ARRAY_COUNT(gRRectIndices) - 6; |
1208 static const int kIndicesPerRRect = SK_ARRAY_COUNT(gRRectIndices); | 1208 static const int kIndicesPerRRect = SK_ARRAY_COUNT(gRRectIndices); |
1209 static const int kVertsPerRRect = 16; | 1209 static const int kVertsPerRRect = 16; |
1210 static const int kNumRRectsInIndexBuffer = 256; | 1210 static const int kNumRRectsInIndexBuffer = 256; |
1211 | 1211 |
1212 GR_DECLARE_STATIC_UNIQUE_KEY(gStrokeRRectOnlyIndexBufferKey); | 1212 GR_DECLARE_STATIC_UNIQUE_KEY(gStrokeRRectOnlyIndexBufferKey); |
1213 GR_DECLARE_STATIC_UNIQUE_KEY(gRRectOnlyIndexBufferKey); | 1213 GR_DECLARE_STATIC_UNIQUE_KEY(gRRectOnlyIndexBufferKey); |
1214 static const GrIndexBuffer* ref_rrect_index_buffer(bool strokeOnly, | 1214 static const GrBuffer* ref_rrect_index_buffer(bool strokeOnly, |
1215 GrResourceProvider* resourceP
rovider) { | 1215 GrResourceProvider* resourceProvid
er) { |
1216 GR_DEFINE_STATIC_UNIQUE_KEY(gStrokeRRectOnlyIndexBufferKey); | 1216 GR_DEFINE_STATIC_UNIQUE_KEY(gStrokeRRectOnlyIndexBufferKey); |
1217 GR_DEFINE_STATIC_UNIQUE_KEY(gRRectOnlyIndexBufferKey); | 1217 GR_DEFINE_STATIC_UNIQUE_KEY(gRRectOnlyIndexBufferKey); |
1218 if (strokeOnly) { | 1218 if (strokeOnly) { |
1219 return resourceProvider->findOrCreateInstancedIndexBuffer( | 1219 return resourceProvider->findOrCreateInstancedIndexBuffer( |
1220 gRRectIndices, kIndicesPerStrokeRRect, kNumRRectsInIndexBuffer, kVer
tsPerRRect, | 1220 gRRectIndices, kIndicesPerStrokeRRect, kNumRRectsInIndexBuffer, kVer
tsPerRRect, |
1221 gStrokeRRectOnlyIndexBufferKey); | 1221 gStrokeRRectOnlyIndexBufferKey); |
1222 } else { | 1222 } else { |
1223 return resourceProvider->findOrCreateInstancedIndexBuffer( | 1223 return resourceProvider->findOrCreateInstancedIndexBuffer( |
1224 gRRectIndices, kIndicesPerRRect, kNumRRectsInIndexBuffer, kVertsPerR
Rect, | 1224 gRRectIndices, kIndicesPerRRect, kNumRRectsInIndexBuffer, kVertsPerR
Rect, |
1225 gRRectOnlyIndexBufferKey); | 1225 gRRectOnlyIndexBufferKey); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 SkAutoTUnref<GrGeometryProcessor> gp(new CircleGeometryProcessor(fStroke
d, localMatrix)); | 1279 SkAutoTUnref<GrGeometryProcessor> gp(new CircleGeometryProcessor(fStroke
d, localMatrix)); |
1280 | 1280 |
1281 target->initDraw(gp); | 1281 target->initDraw(gp); |
1282 | 1282 |
1283 int instanceCount = fGeoData.count(); | 1283 int instanceCount = fGeoData.count(); |
1284 size_t vertexStride = gp->getVertexStride(); | 1284 size_t vertexStride = gp->getVertexStride(); |
1285 SkASSERT(vertexStride == sizeof(CircleVertex)); | 1285 SkASSERT(vertexStride == sizeof(CircleVertex)); |
1286 | 1286 |
1287 // drop out the middle quad if we're stroked | 1287 // drop out the middle quad if we're stroked |
1288 int indicesPerInstance = fStroked ? kIndicesPerStrokeRRect : kIndicesPer
RRect; | 1288 int indicesPerInstance = fStroked ? kIndicesPerStrokeRRect : kIndicesPer
RRect; |
1289 SkAutoTUnref<const GrIndexBuffer> indexBuffer( | 1289 SkAutoTUnref<const GrBuffer> indexBuffer( |
1290 ref_rrect_index_buffer(fStroked, target->resourceProvider())); | 1290 ref_rrect_index_buffer(fStroked, target->resourceProvider())); |
1291 | 1291 |
1292 InstancedHelper helper; | 1292 InstancedHelper helper; |
1293 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target
, | 1293 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target
, |
1294 kTriangles_GrPrimitiveType, vertexStride, indexBuffer, kVertsPerRRec
t, | 1294 kTriangles_GrPrimitiveType, vertexStride, indexBuffer, kVertsPerRRec
t, |
1295 indicesPerInstance, instanceCount)); | 1295 indicesPerInstance, instanceCount)); |
1296 if (!verts || !indexBuffer) { | 1296 if (!verts || !indexBuffer) { |
1297 SkDebugf("Could not allocate vertices\n"); | 1297 SkDebugf("Could not allocate vertices\n"); |
1298 return; | 1298 return; |
1299 } | 1299 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 SkAutoTUnref<GrGeometryProcessor> gp(new EllipseGeometryProcessor(fStrok
ed, localMatrix)); | 1427 SkAutoTUnref<GrGeometryProcessor> gp(new EllipseGeometryProcessor(fStrok
ed, localMatrix)); |
1428 | 1428 |
1429 target->initDraw(gp); | 1429 target->initDraw(gp); |
1430 | 1430 |
1431 int instanceCount = fGeoData.count(); | 1431 int instanceCount = fGeoData.count(); |
1432 size_t vertexStride = gp->getVertexStride(); | 1432 size_t vertexStride = gp->getVertexStride(); |
1433 SkASSERT(vertexStride == sizeof(EllipseVertex)); | 1433 SkASSERT(vertexStride == sizeof(EllipseVertex)); |
1434 | 1434 |
1435 // drop out the middle quad if we're stroked | 1435 // drop out the middle quad if we're stroked |
1436 int indicesPerInstance = fStroked ? kIndicesPerStrokeRRect : kIndicesPer
RRect; | 1436 int indicesPerInstance = fStroked ? kIndicesPerStrokeRRect : kIndicesPer
RRect; |
1437 SkAutoTUnref<const GrIndexBuffer> indexBuffer( | 1437 SkAutoTUnref<const GrBuffer> indexBuffer( |
1438 ref_rrect_index_buffer(fStroked, target->resourceProvider())); | 1438 ref_rrect_index_buffer(fStroked, target->resourceProvider())); |
1439 | 1439 |
1440 InstancedHelper helper; | 1440 InstancedHelper helper; |
1441 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( | 1441 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( |
1442 helper.init(target, kTriangles_GrPrimitiveType, vertexStride, indexB
uffer, | 1442 helper.init(target, kTriangles_GrPrimitiveType, vertexStride, indexB
uffer, |
1443 kVertsPerRRect, indicesPerInstance, instanceCount)); | 1443 kVertsPerRRect, indicesPerInstance, instanceCount)); |
1444 if (!verts || !indexBuffer) { | 1444 if (!verts || !indexBuffer) { |
1445 SkDebugf("Could not allocate vertices\n"); | 1445 SkDebugf("Could not allocate vertices\n"); |
1446 return; | 1446 return; |
1447 } | 1447 } |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 } | 1724 } |
1725 | 1725 |
1726 DRAW_BATCH_TEST_DEFINE(RRectBatch) { | 1726 DRAW_BATCH_TEST_DEFINE(RRectBatch) { |
1727 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 1727 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
1728 GrColor color = GrRandomColor(random); | 1728 GrColor color = GrRandomColor(random); |
1729 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 1729 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
1730 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 1730 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
1731 } | 1731 } |
1732 | 1732 |
1733 #endif | 1733 #endif |
OLD | NEW |