summaryrefslogtreecommitdiffstats
path: root/tests/HwAccelerationTest
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2013-01-08 11:15:30 -0800
committerRomain Guy <romainguy@google.com>2013-01-08 15:21:42 -0800
commite3a9b24b5e3f9b2058486814a6d27729e51ad466 (patch)
tree17830a6fd61c286854cebb07638d3c2dea6277cd /tests/HwAccelerationTest
parent5b4628aeeaa0462cd99256d28b636c06b1845930 (diff)
downloadframeworks_base-e3a9b24b5e3f9b2058486814a6d27729e51ad466.zip
frameworks_base-e3a9b24b5e3f9b2058486814a6d27729e51ad466.tar.gz
frameworks_base-e3a9b24b5e3f9b2058486814a6d27729e51ad466.tar.bz2
Add plumbing for better text scaling
Fonts are now described by a transform matrix. This lead to switching from a vector to a hashmap. This change therefore adds new comparators and hash computations to Font. Change-Id: I2daffa7d6287c18554c606b8bfa06640d28b4530
Diffstat (limited to 'tests/HwAccelerationTest')
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java47
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java8
2 files changed, 49 insertions, 6 deletions
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java
index 2e1487d..e1bf3ea 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java
@@ -21,6 +21,7 @@ import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
+import android.graphics.Path;
import android.os.Bundle;
import android.view.View;
@@ -43,15 +44,27 @@ public class ScaledTextActivity extends Activity {
}
public static class ScaledTextView extends View {
+ private static final String TEXT = "Hello libhwui! ";
+
private final Paint mPaint;
+ private final Paint mShadowPaint;
+ private final Path mPath;
+
private float mScale = 1.0f;
public ScaledTextView(Context c) {
super(c);
+ mPath = makePath();
+
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setTextSize(20.0f);
+
+ mShadowPaint = new Paint();
+ mShadowPaint.setAntiAlias(true);
+ mShadowPaint.setShadowLayer(3.0f, 0.0f, 3.0f, 0xff000000);
+ mShadowPaint.setTextSize(20.0f);
}
public float getTextScale() {
@@ -63,17 +76,47 @@ public class ScaledTextActivity extends Activity {
invalidate();
}
+ private static Path makePath() {
+ Path path = new Path();
+ buildPath(path);
+ return path;
+ }
+
+ private static void buildPath(Path path) {
+ path.moveTo(0.0f, 0.0f);
+ path.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f);
+ path.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f);
+ path.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f);
+ }
+
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawARGB(255, 255, 255, 255);
- canvas.drawText("Hello libhwui!", 30.0f, 30.0f, mPaint);
+ canvas.drawText(TEXT, 30.0f, 30.0f, mPaint);
+
canvas.translate(0.0f, 50.0f);
+
canvas.save();
canvas.scale(mScale, mScale);
- canvas.drawText("Hello libhwui!", 30.0f, 30.0f, mPaint);
+ canvas.drawText(TEXT, 30.0f, 30.0f, mPaint);
canvas.restore();
+
+ canvas.translate(0.0f, 250.0f);
+ canvas.save();
+ canvas.scale(3.0f, 3.0f);
+ canvas.drawText(TEXT, 30.0f, 30.0f, mShadowPaint);
+ canvas.translate(100.0f, 0.0f);
+// canvas.drawTextOnPath(TEXT + TEXT + TEXT, mPath, 0.0f, 0.0f, mPaint);
+ canvas.restore();
+
+ float width = mPaint.measureText(TEXT);
+
+ canvas.translate(500.0f, 0.0f);
+ canvas.rotate(45.0f, width * 3.0f / 2.0f, 0.0f);
+ canvas.scale(3.0f, 3.0f);
+ canvas.drawText(TEXT, 30.0f, 30.0f, mPaint);
}
}
}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java
index 9849e3c..ceccfaa 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java
@@ -41,26 +41,26 @@ public class TextOnPathActivity extends Activity {
setContentView(view);
}
- private Path makePath() {
+ private static Path makePath() {
Path path = new Path();
buildPath(path);
return path;
}
- private void buildPath(Path path) {
+ private static void buildPath(Path path) {
path.moveTo(0.0f, 0.0f);
path.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f);
path.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f);
path.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f);
}
- private Path makeStraightPath() {
+ private static Path makeStraightPath() {
Path path = new Path();
buildStraightPath(path);
return path;
}
- private void buildStraightPath(Path path) {
+ private static void buildStraightPath(Path path) {
path.moveTo(0.0f, 0.0f);
path.lineTo(400.0f, 0.0f);
}