summaryrefslogtreecommitdiffstats
path: root/libs/hwui
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-03-01 12:08:38 -0800
committerRomain Guy <romainguy@google.com>2012-03-01 12:08:38 -0800
commitdd7c8e4c68205d39109d4317dd0c9b05ed43e8e5 (patch)
tree918bc3b0d69d8be0cf2d978a2b3a6291f6884f2b /libs/hwui
parent9777173eb6c9eb97c7921c8288ebc65e3ab3ce6f (diff)
downloadframeworks_base-dd7c8e4c68205d39109d4317dd0c9b05ed43e8e5.zip
frameworks_base-dd7c8e4c68205d39109d4317dd0c9b05ed43e8e5.tar.gz
frameworks_base-dd7c8e4c68205d39109d4317dd0c9b05ed43e8e5.tar.bz2
Small tweak to Canvas.drawPath() GL implementation
Change-Id: I1d668a912996e1267bcf2127058888e489a2d9b3
Diffstat (limited to 'libs/hwui')
-rw-r--r--libs/hwui/FontRenderer.cpp17
-rw-r--r--libs/hwui/OpenGLRenderer.cpp2
2 files changed, 9 insertions, 10 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index f2bb6ec..92a7573 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -170,16 +170,10 @@ void Font::drawCachedGlyph(CachedGlyphInfo* glyph, float x, float hOffset, float
const float halfWidth = glyph->mBitmapWidth * 0.5f;
const float height = glyph->mBitmapHeight;
- float nPenX = glyph->mBitmapLeft;
vOffset += glyph->mBitmapTop + height;
- const float u1 = glyph->mBitmapMinU;
- const float u2 = glyph->mBitmapMaxU;
- const float v1 = glyph->mBitmapMinV;
- const float v2 = glyph->mBitmapMaxV;
-
SkPoint destination[4];
- measure.getPosTan(x + hOffset + nPenX + halfWidth, position, tangent);
+ measure.getPosTan(x + hOffset + glyph->mBitmapLeft + halfWidth, position, tangent);
// Move along the tangent and offset by the normal
destination[0].set(-tangent->fX * halfWidth - tangent->fY * vOffset,
@@ -191,6 +185,11 @@ void Font::drawCachedGlyph(CachedGlyphInfo* glyph, float x, float hOffset, float
destination[3].set(destination[0].fX + tangent->fY * height,
destination[0].fY - tangent->fX * height);
+ const float u1 = glyph->mBitmapMinU;
+ const float u2 = glyph->mBitmapMaxU;
+ const float v1 = glyph->mBitmapMinV;
+ const float v2 = glyph->mBitmapMaxV;
+
mState->appendRotatedMeshQuad(
position->fX + destination[0].fX,
position->fY + destination[0].fY, u1, v2,
@@ -267,7 +266,7 @@ void Font::render(SkPaint* paint, const char *text, uint32_t start, uint32_t len
penX += pathOffset - textWidth;
}
- while (glyphsCount < numGlyphs && penX <= pathLength) {
+ while (glyphsCount < numGlyphs && penX < pathLength) {
glyph_t glyph = GET_GLYPH(text);
if (IS_END_OF_STRING(glyph)) {
@@ -279,7 +278,7 @@ void Font::render(SkPaint* paint, const char *text, uint32_t start, uint32_t len
prevRsbDelta = cachedGlyph->mRsbDelta;
if (cachedGlyph->mIsValid) {
- drawCachedGlyph(cachedGlyph, roundf(penX), hOffset, vOffset, measure, &position, &tangent);
+ drawCachedGlyph(cachedGlyph, penX, hOffset, vOffset, measure, &position, &tangent);
}
penX += SkFixedToFloat(cachedGlyph->mAdvanceX);
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 73625b7..e3148e8 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -2477,7 +2477,7 @@ void OpenGLRenderer::setupPaintFilter(int clearBits, int setBits) {
}
SkPaint* OpenGLRenderer::filterPaint(SkPaint* paint) {
- if (!mHasDrawFilter || !paint) return paint;
+ if (CC_LIKELY(!mHasDrawFilter || !paint)) return paint;
uint32_t flags = paint->getFlags();