Apply bilinear filtering on text only when necessary.
Change-Id: Ic903f4b5d30e9c92528c6291941896efe4729ee3
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index 4fb8f8d..f10efad 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -156,8 +156,16 @@
DropShadow renderDropShadow(SkPaint* paint, const char *text, uint32_t startIndex,
uint32_t len, int numGlyphs, uint32_t radius);
- GLuint getTexture() {
+ GLuint getTexture(bool linearFiltering = false) {
checkInit();
+ if (linearFiltering != mLinearFiltering) {
+ mLinearFiltering = linearFiltering;
+ const GLenum filtering = linearFiltering ? GL_LINEAR : GL_NEAREST;
+
+ glBindTexture(GL_TEXTURE_2D, mTextureId);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
+ }
return mTextureId;
}
@@ -252,6 +260,8 @@
bool mInitialized;
+ bool mLinearFiltering;
+
void computeGaussianWeights(float* weights, int32_t radius);
void horizontalBlur(float* weights, int32_t radius, const uint8_t *source, uint8_t *dest,
int32_t width, int32_t height);