Add GrDrawTarget::drawIndexedInstance, use in default text context.
Review URL: http://codereview.appspot.com/5848064/
git-svn-id: http://skia.googlecode.com/svn/trunk@3444 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index e9b7e49..6d52c2a 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -1011,6 +1011,34 @@
this->getBlendOpts());
}
+////////////////////////////////////////////////////////////////////////////////
+
+void GrDrawTarget::drawIndexedInstances(GrPrimitiveType type,
+ int instanceCount,
+ int verticesPerInstance,
+ int indicesPerInstance) {
+ if (!verticesPerInstance || !indicesPerInstance) {
+ return;
+ }
+
+ int instancesPerDraw = this->indexCountInCurrentSource() /
+ indicesPerInstance;
+ if (!instancesPerDraw) {
+ return;
+ }
+
+ instancesPerDraw = GrMin(instanceCount, instancesPerDraw);
+ int startVertex = 0;
+ while (instanceCount) {
+ this->drawIndexed(type,
+ startVertex,
+ 0,
+ verticesPerInstance * instancesPerDraw,
+ indicesPerInstance * instancesPerDraw);
+ startVertex += verticesPerInstance;
+ instanceCount -= instancesPerDraw;
+ }
+}
////////////////////////////////////////////////////////////////////////////////