diff options
| author | 2013-06-24 14:33:37 -0700 | |
|---|---|---|
| committer | 2013-06-24 16:45:41 -0700 | |
| commit | f296dca95f09be9832b5dcc79717986525d2b6cb (patch) | |
| tree | 7fda09c7b293823c59d63c08370369c45690a95d /libs/hwui/Patch.cpp | |
| parent | 066bdcfe83e49ad4bfb97670521c1b7e7297ba53 (diff) | |
(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/Patch.cpp')
| -rw-r--r-- | libs/hwui/Patch.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp index 9e3e7013e7a2..7656f85e62a7 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; } |