summaryrefslogtreecommitdiff
path: root/libs/hwui/FontRenderer.cpp
diff options
context:
space:
mode:
author Chris Craik <ccraik@google.com> 2013-02-22 10:41:36 -0800
committer Chris Craik <ccraik@google.com> 2013-02-22 16:16:16 -0800
commitdd8697c095272f19ddad214834a490b00f11a477 (patch)
tree95c51da6955eca5a40fd692103fba7bee8711219 /libs/hwui/FontRenderer.cpp
parent786525e8ea49c32b54eda5c260e125f5f2cf80e7 (diff)
Avoid double blur
bug:8204062 Avoids incorrectly blurring with RenderScript after a C++ blur Additionally, avoids draw/blurring if the input text has empty bounds Change-Id: Ibbaf74800fff7a6e4cda3aa24286b90e7aef589d
Diffstat (limited to 'libs/hwui/FontRenderer.cpp')
-rw-r--r--libs/hwui/FontRenderer.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 8eb2aeb142bf..db65b8875982 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -563,9 +563,15 @@ FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const ch
int penX = radius - bounds.left;
int penY = radius - bounds.bottom;
- mCurrentFont->render(paint, text, startIndex, len, numGlyphs, penX, penY,
- Font::BITMAP, dataBuffer, paddedWidth, paddedHeight, NULL, positions);
- blurImage(&dataBuffer, paddedWidth, paddedHeight, radius);
+ if ((bounds.right > bounds.left) && (bounds.top > bounds.bottom)) {
+ // text has non-whitespace, so draw and blur to create the shadow
+ // NOTE: bounds.isEmpty() can't be used here, since vertical coordinates are inverted
+ // TODO: don't draw pure whitespace in the first place, and avoid needing this check
+ mCurrentFont->render(paint, text, startIndex, len, numGlyphs, penX, penY,
+ Font::BITMAP, dataBuffer, paddedWidth, paddedHeight, NULL, positions);
+
+ blurImage(&dataBuffer, paddedWidth, paddedHeight, radius);
+ }
DropShadow image;
image.width = paddedWidth;
@@ -774,6 +780,7 @@ void FontRenderer::blurImage(uint8_t** image, int32_t width, int32_t height, int
delete[] gaussian;
delete[] scratch;
+ return;
}
uint8_t* outImage = (uint8_t*)memalign(RS_CPU_ALLOCATION_ALIGNMENT, width * height);