summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2011-08-02 17:32:41 -0700
committerRomain Guy <romainguy@google.com>2011-08-02 17:32:41 -0700
commitbd496bc3d481f9cfc39007d22372d3a1a8809f96 (patch)
tree1c69e8c136dd81e68459c8b9870e0fac4bd6ae10
parent6805545649f2b194859033df94602492b9ec086e (diff)
downloadframeworks_base-bd496bc3d481f9cfc39007d22372d3a1a8809f96.zip
frameworks_base-bd496bc3d481f9cfc39007d22372d3a1a8809f96.tar.gz
frameworks_base-bd496bc3d481f9cfc39007d22372d3a1a8809f96.tar.bz2
Paint style and stroke width affect text rendering.
Bug #5112207 Change-Id: Ic34037ace21a5058ba23dd15e51aae58c998454d
-rw-r--r--libs/hwui/FontRenderer.cpp21
-rw-r--r--libs/hwui/FontRenderer.h7
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/TextActivity.java10
3 files changed, 30 insertions, 8 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 9bf3de8..9acf99b 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -44,9 +44,11 @@ namespace uirenderer {
///////////////////////////////////////////////////////////////////////////////
Font::Font(FontRenderer* state, uint32_t fontId, float fontSize,
- int flags, uint32_t italicStyle, uint32_t scaleX) :
+ int flags, uint32_t italicStyle, uint32_t scaleX,
+ SkPaint::Style style, uint32_t strokeWidth) :
mState(state), mFontId(fontId), mFontSize(fontSize),
- mFlags(flags), mItalicStyle(italicStyle), mScaleX(scaleX) {
+ mFlags(flags), mItalicStyle(italicStyle), mScaleX(scaleX),
+ mStyle(style), mStrokeWidth(mStrokeWidth) {
}
@@ -283,19 +285,22 @@ Font::CachedGlyphInfo* Font::cacheGlyph(SkPaint* paint, glyph_t glyph) {
}
Font* Font::create(FontRenderer* state, uint32_t fontId, float fontSize,
- int flags, uint32_t italicStyle, uint32_t scaleX) {
+ int flags, uint32_t italicStyle, uint32_t scaleX,
+ SkPaint::Style style, uint32_t strokeWidth) {
Vector<Font*> &activeFonts = state->mActiveFonts;
for (uint32_t i = 0; i < activeFonts.size(); i++) {
Font* font = activeFonts[i];
if (font->mFontId == fontId && font->mFontSize == fontSize &&
font->mFlags == flags && font->mItalicStyle == italicStyle &&
- font->mScaleX == scaleX) {
+ font->mScaleX == scaleX && font->mStyle == style &&
+ (style == SkPaint::kFill_Style || font->mStrokeWidth == strokeWidth)) {
return font;
}
}
- Font* newFont = new Font(state, fontId, fontSize, flags, italicStyle, scaleX);
+ Font* newFont = new Font(state, fontId, fontSize, flags, italicStyle,
+ scaleX, style, strokeWidth);
activeFonts.push(newFont);
return newFont;
}
@@ -690,7 +695,11 @@ void FontRenderer::setFont(SkPaint* paint, uint32_t fontId, float fontSize) {
uint32_t italicStyle = *(uint32_t*) &skewX;
const float scaleXFloat = paint->getTextScaleX();
uint32_t scaleX = *(uint32_t*) &scaleXFloat;
- mCurrentFont = Font::create(this, fontId, fontSize, flags, italicStyle, scaleX);
+ SkPaint::Style style = paint->getStyle();
+ const float strokeWidthFloat = paint->getStrokeWidth();
+ uint32_t strokeWidth = *(uint32_t*) &strokeWidthFloat;
+ mCurrentFont = Font::create(this, fontId, fontSize, flags, italicStyle,
+ scaleX, style, strokeWidth);
const float maxPrecacheFontSize = 40.0f;
bool isNewFont = currentNumFonts != mActiveFonts.size();
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index 24ed6fa..1922812 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -82,7 +82,8 @@ public:
* Creates a new font associated with the specified font state.
*/
static Font* create(FontRenderer* state, uint32_t fontId, float fontSize,
- int flags, uint32_t italicStyle, uint32_t scaleX);
+ int flags, uint32_t italicStyle, uint32_t scaleX, SkPaint::Style style,
+ uint32_t strokeWidth);
protected:
friend class FontRenderer;
@@ -128,7 +129,7 @@ protected:
};
Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags, uint32_t italicStyle,
- uint32_t scaleX);
+ uint32_t scaleX, SkPaint::Style style, uint32_t strokeWidth);
// Cache of glyphs
DefaultKeyedVector<glyph_t, CachedGlyphInfo*> mCachedGlyphs;
@@ -157,6 +158,8 @@ protected:
int mFlags;
uint32_t mItalicStyle;
uint32_t mScaleX;
+ SkPaint::Style mStyle;
+ uint32_t mStrokeWidth;
};
///////////////////////////////////////////////////////////////////////////////
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextActivity.java
index 7bf25cf..4037a69 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextActivity.java
@@ -77,13 +77,23 @@ public class TextActivity extends Activity {
super.onDraw(canvas);
canvas.drawRGB(255, 255, 255);
+ mMediumPaint.setStyle(Paint.Style.FILL_AND_STROKE);
+ mMediumPaint.setStrokeWidth(2.0f);
canvas.drawText("Hello OpenGL renderer!", 100, 20, mMediumPaint);
+
+ mMediumPaint.setStyle(Paint.Style.FILL);
mMediumPaint.setTextAlign(Paint.Align.CENTER);
canvas.drawText("Hello OpenGL renderer!", 100, 40, mMediumPaint);
+
+ mMediumPaint.setStyle(Paint.Style.STROKE);
+ mMediumPaint.setStrokeWidth(2.0f);
mMediumPaint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText("Hello OpenGL renderer!", 100, 60, mMediumPaint);
+
+ mMediumPaint.setStyle(Paint.Style.FILL);
mMediumPaint.setTextAlign(Paint.Align.LEFT);
canvas.drawText("Hello OpenGL renderer!", 100, 100, mMediumPaint);
+
mMediumPaint.setShadowLayer(2.5f, 0.0f, 0.0f, 0xff000000);
canvas.drawText("Hello OpenGL renderer!", 100, 150, mMediumPaint);
mMediumPaint.clearShadowLayer();