Merge \\\"Performance Optimization: Align texture dirty rect\\\" am: 4e6a73c16a am: ec45adde70

am: 89132e094f

Change-Id: I198fc7403ad5e42dbb0caaac33185c8169b3aebc
This commit is contained in:
ywen
2016-06-16 21:59:21 +00:00
committed by android-build-merger

View File

@@ -188,15 +188,21 @@ void CacheTexture::allocatePixelBuffer() {
bool CacheTexture::upload() { bool CacheTexture::upload() {
const Rect& dirtyRect = mDirtyRect; const Rect& dirtyRect = mDirtyRect;
uint32_t x = mHasUnpackRowLength ? dirtyRect.left : 0; // align the x direction to 32 and y direction to 4 for better performance
uint32_t y = dirtyRect.top; uint32_t x = (((uint32_t)dirtyRect.left) & (~0x1F));
uint32_t width = mHasUnpackRowLength ? dirtyRect.getWidth() : getWidth(); uint32_t y = (((uint32_t)dirtyRect.top) & (~0x3));
uint32_t height = dirtyRect.getHeight(); uint32_t r = ((((uint32_t)dirtyRect.right) + 0x1F) & (~0x1F)) - x;
uint32_t b = ((((uint32_t)dirtyRect.bottom) + 0x3) & (~0x3)) - y;
uint32_t width = (r > getWidth() ? getWidth() : r);
uint32_t height = (b > getHeight() ? getHeight() : b);
// The unpack row length only needs to be specified when a new // The unpack row length only needs to be specified when a new
// texture is bound // texture is bound
if (mHasUnpackRowLength) { if (mHasUnpackRowLength) {
glPixelStorei(GL_UNPACK_ROW_LENGTH, getWidth()); glPixelStorei(GL_UNPACK_ROW_LENGTH, getWidth());
} else {
x = 0;
width = getWidth();
} }
mPixelBuffer->upload(x, y, width, height); mPixelBuffer->upload(x, y, width, height);