OSDN Git Service

Canvas.drawVertices: correct color range-check
authorErik Faye-Lund <kusmabite@googlemail.com>
Wed, 2 Jun 2010 21:47:01 +0000 (23:47 +0200)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 5 Aug 2011 08:05:30 +0000 (16:05 +0800)
The range-check in drawVertices previously checked that the color
count was equal to the vertex count. However, the vertex count is
specified in array elements, and there's two array elements per
vertex for the positions, but only one array element per vertex
for the colors.

Correct the code so the check is consistent with the element count.

Change-Id: Id043f1003f9245f18adc91bac49dc33727ca765e

graphics/java/android/graphics/Canvas.java

index 8ac2aa0..a587d0d 100644 (file)
@@ -1221,7 +1221,7 @@ public class Canvas {
             checkRange(texs.length, texOffset, vertexCount);
         }
         if (colors != null) {
-            checkRange(colors.length, colorOffset, vertexCount);
+            checkRange(colors.length, colorOffset, vertexCount / 2);
         }
         if (indices != null) {
             checkRange(indices.length, indexOffset, indexCount);