summaryrefslogtreecommitdiffstats
path: root/libs/hwui
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2013-06-24 14:33:37 -0700
committerRomain Guy <romainguy@google.com>2013-06-24 16:45:41 -0700
commitf296dca95f09be9832b5dcc79717986525d2b6cb (patch)
tree7fda09c7b293823c59d63c08370369c45690a95d /libs/hwui
parent066bdcfe83e49ad4bfb97670521c1b7e7297ba53 (diff)
downloadframeworks_base-f296dca95f09be9832b5dcc79717986525d2b6cb.zip
frameworks_base-f296dca95f09be9832b5dcc79717986525d2b6cb.tar.gz
frameworks_base-f296dca95f09be9832b5dcc79717986525d2b6cb.tar.bz2
(Small) 9patch drawing improvements
Save a bit of memory in meshs generated from native code Avoid an extra if/else when drawing with hardware accelration on Change-Id: I31a4550bde4d2c27961710ebcc92b66cd71153cc
Diffstat (limited to 'libs/hwui')
-rw-r--r--libs/hwui/Patch.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp
index 9e3e701..7656f85 100644
--- a/libs/hwui/Patch.cpp
+++ b/libs/hwui/Patch.cpp
@@ -79,8 +79,8 @@ TextureVertex* Patch::createMesh(const float bitmapWidth, const float bitmapHeig
uint32_t maxVertices = ((xCount + 1) * (yCount + 1) - emptyQuads) * 4;
if (maxVertices == 0) return NULL;
- vertices = new TextureVertex[maxVertices];
- TextureVertex* vertex = vertices;
+ TextureVertex* tempVertices = new TextureVertex[maxVertices];
+ TextureVertex* vertex = tempVertices;
const int32_t* xDivs = patch->xDivs;
const int32_t* yDivs = patch->yDivs;
@@ -159,6 +159,14 @@ TextureVertex* Patch::createMesh(const float bitmapWidth, const float bitmapHeig
width, bitmapWidth, quadCount);
}
+ if (verticesCount == maxVertices) {
+ vertices = tempVertices;
+ } else {
+ vertices = new TextureVertex[verticesCount];
+ memcpy(vertices, tempVertices, verticesCount * sizeof(TextureVertex));
+ delete[] tempVertices;
+ }
+
return vertices;
}