summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2013-03-04 11:14:26 -0800
committerRomain Guy <romainguy@google.com>2013-03-04 13:48:43 -0800
commit19d4dd8599cb870923ab349d2ab96cacffd9c6f5 (patch)
tree86b0575167b2c27642a1e7a7296be2de2877474a /libs
parentcdac497289fd2c39a352f6167dae3f77cc608cb8 (diff)
downloadframeworks_base-19d4dd8599cb870923ab349d2ab96cacffd9c6f5.zip
frameworks_base-19d4dd8599cb870923ab349d2ab96cacffd9c6f5.tar.gz
frameworks_base-19d4dd8599cb870923ab349d2ab96cacffd9c6f5.tar.bz2
Take text scale/skew into account only when rendering into a layer
3D rotations can undo scale/skew transforms; since FreeType only accepts 2x2 matrices we can end up generating very large glyphs that are drawn at a 1:1 scale on screen. For instance, if the current transform has a scale of 2000 set on both X and Y axis and a perspective Z factor set to Z, the actual scale factor on screen ends up being 1. We would however generate glyphs with a scale factor of 2000 causing the font renderer to blow up. Change-Id: Ia5c3618d36644e817825cb9c89e2f53aece2074e
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/OpenGLRenderer.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index ff6f332..c81bf7a 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -2673,7 +2673,26 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
alpha, mode, oldX, oldY);
}
- fontRenderer.setFont(paint, pureTranslate ? mat4::identity() : *mSnapshot->transform);
+ const bool hasActiveLayer = hasLayer();
+
+ const mat4* fontTransform;
+ if (CC_LIKELY(pureTranslate)) {
+ fontTransform = &mat4::identity();
+ } else {
+ if (CC_UNLIKELY(isPerspective)) {
+ // When the below condition is true, we are rendering text with a
+ // perspective transform inside a layer (either an inline layer
+ // created by Canvas.saveLayer() or a hardware layer.)
+ if (hasActiveLayer || getTargetFbo() != 0) {
+ fontTransform = mSnapshot->transform;
+ } else {
+ fontTransform = &mat4::identity();
+ }
+ } else {
+ fontTransform = mSnapshot->transform;
+ }
+ }
+ fontRenderer.setFont(paint, *fontTransform);
// Pick the appropriate texture filtering
bool linearFilter = !pureTranslate || fabs(y - (int) y) > 0.0f || fabs(x - (int) x) > 0.0f;
@@ -2701,8 +2720,6 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
const Rect* clip = isPerspective ? NULL : mSnapshot->clipRect;
Rect bounds(FLT_MAX / 2.0f, FLT_MAX / 2.0f, FLT_MIN / 2.0f, FLT_MIN / 2.0f);
- const bool hasActiveLayer = hasLayer();
-
bool status;
if (CC_UNLIKELY(paint->getTextAlign() != SkPaint::kLeft_Align)) {
SkPaint paintCopy(*paint);