summaryrefslogtreecommitdiffstats
path: root/tests/HwAccelerationTest
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2013-02-26 19:10:14 -0800
committerRomain Guy <romainguy@google.com>2013-02-27 15:49:57 -0800
commitc74f45a334f0e3725c23cdd270cbcb0efac4ea75 (patch)
tree1b198e8b6b7d6d4a69237116a580236836744294 /tests/HwAccelerationTest
parentd80806b305ce337283c24f14522cc58fea090b8c (diff)
downloadframeworks_base-c74f45a334f0e3725c23cdd270cbcb0efac4ea75.zip
frameworks_base-c74f45a334f0e3725c23cdd270cbcb0efac4ea75.tar.gz
frameworks_base-c74f45a334f0e3725c23cdd270cbcb0efac4ea75.tar.bz2
Properly scale text
This change does not apply to drawPosText() and drawTextOnPath() yet. Prior to this change, glyphs were always rasterized based on the font size specified in the paint. All transforms were then applied on the resulting texture. This creates rather ugly results when text is scaled and/or rotated. With this change, the font renderer will apply the current transform matrix to the glyph before they are rasterized. This generates much better looking results. Change-Id: I0141b6ff18db35e1213e7a3ab9db1ecaf03d7a9c
Diffstat (limited to 'tests/HwAccelerationTest')
-rw-r--r--tests/HwAccelerationTest/AndroidManifest.xml3
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java22
2 files changed, 22 insertions, 3 deletions
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 2a9016b..7c7d10e 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -34,7 +34,8 @@
<activity
android:name="ScaledTextActivity"
- android:label="_ScaledText">
+ android:label="_ScaledText"
+ android:theme="@android:style/Theme.Holo.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java
index e1bf3ea..a4e9b52 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java
@@ -54,6 +54,7 @@ public class ScaledTextActivity extends Activity {
public ScaledTextView(Context c) {
super(c);
+ setLayerType(LAYER_TYPE_HARDWARE, null);
mPath = makePath();
@@ -92,11 +93,28 @@ public class ScaledTextActivity extends Activity {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
- canvas.drawARGB(255, 255, 255, 255);
canvas.drawText(TEXT, 30.0f, 30.0f, mPaint);
+ mPaint.setTextAlign(Paint.Align.CENTER);
+ canvas.drawText(TEXT, 30.0f, 50.0f, mPaint);
+ mPaint.setTextAlign(Paint.Align.RIGHT);
+ canvas.drawText(TEXT, 30.0f, 70.0f, mPaint);
- canvas.translate(0.0f, 50.0f);
+ canvas.save();
+ canvas.translate(400.0f, 0.0f);
+ canvas.scale(3.0f, 3.0f);
+ mPaint.setTextAlign(Paint.Align.LEFT);
+ mPaint.setStrikeThruText(true);
+ canvas.drawText(TEXT, 30.0f, 30.0f, mPaint);
+ mPaint.setStrikeThruText(false);
+ mPaint.setTextAlign(Paint.Align.CENTER);
+ canvas.drawText(TEXT, 30.0f, 50.0f, mPaint);
+ mPaint.setTextAlign(Paint.Align.RIGHT);
+ canvas.drawText(TEXT, 30.0f, 70.0f, mPaint);
+ canvas.restore();
+
+ mPaint.setTextAlign(Paint.Align.LEFT);
+ canvas.translate(0.0f, 100.0f);
canvas.save();
canvas.scale(mScale, mScale);