Create some layout files for HwAccelerationTest

The goal is use the app to test layout lib, so layout
files are needed, and custom views must be instantiable
(ie public)

Change-Id: I46bb3d8af6e4d7973d041aa618f1c7762efd93d0
This commit is contained in:
Xavier Ducrohet
2010-12-14 14:58:59 -08:00
parent d9c64369cf
commit ec31a7f119
11 changed files with 90 additions and 27 deletions

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin"/>
</classpath>

3
tests/HwAccelerationTest/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
bin
gen
local.properties

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>HwAccelerationTest</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -17,7 +17,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.test.hwui">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="Froyo" />
<application
android:label="HwUi"

View File

@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-Froyo

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<com.android.test.hwui.AdvancedBlendActivity.ShadersView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</com.android.test.hwui.AdvancedBlendActivity.ShadersView>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<com.android.test.hwui.AdvancedGradientsActivity.GradientsView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</com.android.test.hwui.AdvancedGradientsActivity.GradientsView>

View File

@@ -41,7 +41,7 @@ public class AdvancedBlendActivity extends Activity {
setContentView(new ShadersView(this));
}
static class ShadersView extends View {
public static class ShadersView extends View {
private BitmapShader mScaledShader;
private int mTexWidth;
private int mTexHeight;
@@ -57,7 +57,7 @@ public class AdvancedBlendActivity extends Activity {
private ComposeShader mCompose6Shader;
private BitmapShader mScaled2Shader;
ShadersView(Context c) {
public ShadersView(Context c) {
super(c);
Bitmap texture = BitmapFactory.decodeResource(c.getResources(), R.drawable.sunset1);
@@ -71,7 +71,7 @@ public class AdvancedBlendActivity extends Activity {
Matrix m2 = new Matrix();
m2.setScale(0.5f, 0.5f);
mScaledShader.setLocalMatrix(m2);
mScaled2Shader = new BitmapShader(texture, Shader.TileMode.MIRROR,
Shader.TileMode.MIRROR);
Matrix m3 = new Matrix();
@@ -80,7 +80,7 @@ public class AdvancedBlendActivity extends Activity {
mHorGradient = new LinearGradient(0.0f, 0.0f, mDrawWidth, 0.0f,
Color.BLACK, Color.WHITE, Shader.TileMode.CLAMP);
mComposeShader = new ComposeShader(mScaledShader, mHorGradient,
PorterDuff.Mode.DARKEN);
mCompose2Shader = new ComposeShader(mScaledShader, mHorGradient,
@@ -107,7 +107,7 @@ public class AdvancedBlendActivity extends Activity {
mPaint.setShader(mComposeShader);
canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint);
canvas.translate(0.0f, 40.0f + mDrawHeight);
mPaint.setShader(mCompose2Shader);
canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint);
@@ -117,10 +117,10 @@ public class AdvancedBlendActivity extends Activity {
canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint);
canvas.restore();
canvas.save();
canvas.translate(40.0f + mDrawWidth + 40.0f, 40.0f);
mPaint.setShader(mCompose4Shader);
canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint);
@@ -131,7 +131,7 @@ public class AdvancedBlendActivity extends Activity {
canvas.translate(0.0f, 40.0f + mDrawHeight);
mPaint.setShader(mCompose6Shader);
canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint);
canvas.restore();
}
}

View File

@@ -36,7 +36,7 @@ public class AdvancedGradientsActivity extends Activity {
setContentView(new GradientsView(this));
}
static class GradientsView extends View {
public static class GradientsView extends View {
private final Paint mPaint;
private final SweepGradient mSweepGradient;
private final RadialGradient mRadialGradient;
@@ -44,7 +44,7 @@ public class AdvancedGradientsActivity extends Activity {
private final Matrix mMatrix2;
private final Matrix mMatrix3;
GradientsView(Context c) {
public GradientsView(Context c) {
super(c);
mSweepGradient = new SweepGradient(0.0f, 0.0f, 0xff000000, 0xffffffff);

View File

@@ -51,15 +51,12 @@ public class GradientsActivity extends Activity {
final SeekBar rotateView = new SeekBar(this);
rotateView.setMax(360);
rotateView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
gradientView.setRotationY((float) progress);
radialGradientView.setRotationX((float) progress);
@@ -67,7 +64,7 @@ public class GradientsActivity extends Activity {
bitmapView.setRotationX((float) progress);
}
});
layout.addView(shadersView);
layout.addView(gradientView, new FrameLayout.LayoutParams(
200, 200, Gravity.CENTER));
@@ -90,7 +87,7 @@ public class GradientsActivity extends Activity {
setContentView(layout);
}
static class BitmapView extends View {
private final Paint mPaint;
@@ -116,7 +113,7 @@ public class GradientsActivity extends Activity {
canvas.drawRect(0.0f, 0.0f, getWidth(), getHeight(), mPaint);
}
}
static class GradientView extends View {
private final Paint mPaint;
@@ -166,14 +163,14 @@ public class GradientsActivity extends Activity {
canvas.drawRect(0.0f, 0.0f, getWidth(), getHeight(), mPaint);
}
}
static class SweepGradientView extends View {
private final Paint mPaint;
SweepGradientView(Context c) {
super(c);
SweepGradient gradient = new SweepGradient(100.0f, 100.0f, 0xff000000, 0xffffffff);
SweepGradient gradient = new SweepGradient(100.0f, 100.0f, 0xff000000, 0xffffffff);
mPaint = new Paint();
mPaint.setShader(gradient);
}
@@ -190,7 +187,7 @@ public class GradientsActivity extends Activity {
canvas.drawRect(0.0f, 0.0f, getWidth(), getHeight(), mPaint);
}
}
static class ShadersView extends View {
private final Paint mPaint;
private final float mDrawWidth;
@@ -232,12 +229,12 @@ public class GradientsActivity extends Activity {
top += 40.0f + mDrawHeight;
bottom += 40.0f + mDrawHeight;
mMatrix.setScale(1, mDrawHeight);
mMatrix.postTranslate(left, top);
mGradient.setLocalMatrix(mMatrix);
canvas.drawRect(left, top, right, top + mDrawHeight, mPaint);
left += 40.0f + mDrawWidth;
right += 40.0f + mDrawWidth;
top -= 40.0f + mDrawHeight;
@@ -251,13 +248,13 @@ public class GradientsActivity extends Activity {
top += 40.0f + mDrawHeight;
bottom += 40.0f + mDrawHeight;
mMatrix.setScale(1, mDrawWidth);
mMatrix.postRotate(-90);
mMatrix.postTranslate(left, top);
mGradient.setLocalMatrix(mMatrix);
canvas.drawRect(left, top, left + mDrawWidth, bottom, mPaint);
canvas.restore();
}
}

View File

@@ -43,9 +43,8 @@ public class TextGammaActivity extends Activity {
));
setContentView(layout);
layout.post(new Runnable() {
@Override
public void run() {
Bitmap b = Bitmap.createBitmap(gamma.getWidth(), gamma.getHeight(),
Bitmap.Config.ARGB_8888);
@@ -88,7 +87,7 @@ public class TextGammaActivity extends Activity {
final LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
final GammaTextView gamma = new GammaTextView(this);
final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT