summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorywen <ywen@codeaurora.org>2016-02-15 16:09:40 +0800
committerSteve Kondik <steve@cyngn.com>2016-02-24 04:21:40 +0100
commit93e2a44e7fdb51e87e1593ed11a34688cf19af3a (patch)
tree02af40b6ccc4b17c39b5da67142c318d269127d0 /libs
parentd347973ab6d395ae6665a733a55846f37c593c17 (diff)
downloadframeworks_base-93e2a44e7fdb51e87e1593ed11a34688cf19af3a.zip
frameworks_base-93e2a44e7fdb51e87e1593ed11a34688cf19af3a.tar.gz
frameworks_base-93e2a44e7fdb51e87e1593ed11a34688cf19af3a.tar.bz2
Performance Optimization: Align texture dirty rect
Align x offset and width to 32, y offset and height to 4. It improves the font texture upload performance. Change-Id: I967eeed90658f2ce1eb08cb2740d5dc34c72f40b
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/font/CacheTexture.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/libs/hwui/font/CacheTexture.cpp b/libs/hwui/font/CacheTexture.cpp
index d2685da..a767a4e 100644
--- a/libs/hwui/font/CacheTexture.cpp
+++ b/libs/hwui/font/CacheTexture.cpp
@@ -204,15 +204,21 @@ void CacheTexture::allocatePixelBuffer() {
bool CacheTexture::upload() {
const Rect& dirtyRect = mDirtyRect;
- uint32_t x = mHasUnpackRowLength ? dirtyRect.left : 0;
- uint32_t y = dirtyRect.top;
- uint32_t width = mHasUnpackRowLength ? dirtyRect.getWidth() : getWidth();
- uint32_t height = dirtyRect.getHeight();
+ // align the x direction to 32 and y direction to 4 for better performance
+ uint32_t x = (((uint32_t)dirtyRect.left) & (~0x1F));
+ uint32_t y = (((uint32_t)dirtyRect.top) & (~0x3));
+ uint32_t r = ((((uint32_t)dirtyRect.right) + 0x1F) & (~0x1F));
+ uint32_t b = ((((uint32_t)dirtyRect.bottom) + 0x3) & (~0x3));
+ uint32_t width = (r > getWidth() ? getWidth() : r) - x;
+ uint32_t height = (b > getHeight() ? getHeight() : b) - y;
// The unpack row length only needs to be specified when a new
// texture is bound
if (mHasUnpackRowLength) {
glPixelStorei(GL_UNPACK_ROW_LENGTH, getWidth());
+ } else {
+ x = 0;
+ width = getWidth();
}
mPixelBuffer->upload(x, y, width, height);