Optimize glyph cache texture uploads
Only upload the changed area of the glyph cache, not the entire
bitmap. Note that we can't do the full-on optimization here of copying a sub-rect
of the bitmap because of GL ES 2 limitations, but we can at least copy the
horizontal stripe containing the dirty rect, which can still be a big
savings over uploading the entire bitmap.
Issue #7158326 Bad framerates on MR1 (Mako, Manta, Prime)
Change-Id: Iab38d53202650f757ead4658cf4287bdad2b3cb9
diff --git a/libs/hwui/font/CacheTexture.h b/libs/hwui/font/CacheTexture.h
index bf1f4a9..800bfc4 100644
--- a/libs/hwui/font/CacheTexture.h
+++ b/libs/hwui/font/CacheTexture.h
@@ -24,6 +24,7 @@
#include <utils/Log.h>
#include "FontUtil.h"
+#include "Rect.h"
namespace android {
namespace uirenderer {
@@ -149,6 +150,10 @@
return mHeight;
}
+ inline const Rect* getDirtyRect() const {
+ return &mDirtyRect;
+ }
+
inline uint8_t* getTexture() const {
return mTexture;
}
@@ -163,6 +168,9 @@
inline void setDirty(bool dirty) {
mDirty = dirty;
+ if (!dirty) {
+ mDirtyRect.setEmpty();
+ }
}
inline bool getLinearFiltering() const {
@@ -196,6 +204,7 @@
bool mDirty;
uint16_t mNumGlyphs;
CacheBlock* mCacheBlocks;
+ Rect mDirtyRect;
};
}; // namespace uirenderer