Fix rendering for the closing line of line loops.

Trac #19035
Signed-off-by: Nicolas Capens

Line loops via DrawArrays were incorrect because the vertex buffer already
has the vertex offset factored in.
Line loops via DrawElements were incorrect because the vertex buffer was
offset by the minIndex. We need to use the same minIndex when rendering
the closing loop.

git-svn-id: https://angleproject.googlecode.com/svn/trunk@892 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index cdc5b1a..0de524a 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -2797,7 +2797,7 @@
 
         if (mode == GL_LINE_LOOP)   // Draw the last segment separately
         {
-            drawClosingLine(first, first + count - 1);
+            drawClosingLine(0, count - 1, 0);
         }
     }
 }
@@ -2862,7 +2862,7 @@
 
         if (mode == GL_LINE_LOOP)   // Draw the last segment separately
         {
-            drawClosingLine(count, type, indices);
+            drawClosingLine(count, type, indices, indexInfo.minIndex);
         }
     }
 }
@@ -2914,7 +2914,7 @@
     }
 }
 
-void Context::drawClosingLine(unsigned int first, unsigned int last)
+void Context::drawClosingLine(unsigned int first, unsigned int last, int minIndex)
 {
     IDirect3DIndexBuffer9 *indexBuffer = NULL;
     bool succeeded = false;
@@ -2968,7 +2968,7 @@
         mDevice->SetIndices(mClosingIB->getBuffer());
         mAppliedIBSerial = mClosingIB->getSerial();
 
-        mDevice->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, last, offset, 1);
+        mDevice->DrawIndexedPrimitive(D3DPT_LINELIST, -minIndex, minIndex, last, offset, 1);
     }
     else
     {
@@ -2977,7 +2977,7 @@
     }
 }
 
-void Context::drawClosingLine(GLsizei count, GLenum type, const void *indices)
+void Context::drawClosingLine(GLsizei count, GLenum type, const void *indices, int minIndex)
 {
     unsigned int first = 0;
     unsigned int last = 0;
@@ -3006,7 +3006,7 @@
       default: UNREACHABLE();
     }
 
-    drawClosingLine(first, last);
+    drawClosingLine(first, last, minIndex);
 }
 
 void Context::recordInvalidEnum()