diff options
author | Romain Guy <romainguy@google.com> | 2011-12-01 20:08:50 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2011-12-01 20:08:50 -0800 |
commit | cac5fd3e09e9dc918753d4aff624bf29a367ade3 (patch) | |
tree | 6d1db0b5ed0cf9ce616f7e8d969da81f7f606b66 /libs/hwui/OpenGLRenderer.cpp | |
parent | d21b6e1fe337b35f62cf2028e9bd0637fd009a75 (diff) | |
download | frameworks_base-cac5fd3e09e9dc918753d4aff624bf29a367ade3.zip frameworks_base-cac5fd3e09e9dc918753d4aff624bf29a367ade3.tar.gz frameworks_base-cac5fd3e09e9dc918753d4aff624bf29a367ade3.tar.bz2 |
Faster text clipping
Change-Id: I03a00c4261d81a416b1ad7b86ce2d432c71908b4
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 3c838fc..a60ac08 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -2063,7 +2063,7 @@ void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, } void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, - float x, float y, SkPaint* paint) { + float x, float y, SkPaint* paint, float length) { if (text == NULL || count == 0) { return; } @@ -2080,20 +2080,26 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding); #endif - float length = -1.0f; switch (paint->getTextAlign()) { case SkPaint::kCenter_Align: - length = paint->measureText(text, bytesCount); + if (length < 0.0f) length = paint->measureText(text, bytesCount); x -= length / 2.0f; break; case SkPaint::kRight_Align: - length = paint->measureText(text, bytesCount); + if (length < 0.0f) length = paint->measureText(text, bytesCount); x -= length; break; default: break; } + SkPaint::FontMetrics metrics; + paint->getFontMetrics(&metrics, 0.0f); + if (quickReject(x, y + metrics.fTop, + x + (length >= 0.0f ? length : INT_MAX / 2), y + metrics.fBottom)) { + return; + } + const float oldX = x; const float oldY = y; const bool pureTranslate = mSnapshot->transform->isPureTranslate(); |