summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Chang (bizkit) <bizkit@0xlab.org>2010-09-02 15:17:40 +0800
committerJoseph Chang (bizkit) <bizkit@0xlab.org>2010-09-02 15:17:40 +0800
commit2e522a12d8c96e81e2689e7a547c0b94c633d951 (patch)
treef9779cd5c2e70a487778d5e9845a15aeef474e89
parentcfd27eeab5fc2e892e4397ed7e3938d780344182 (diff)
download0xbench-2e522a12d8c96e81e2689e7a547c0b94c633d951.tar.gz
Make 2D benches harder to avoid reaching 60fps vsync barrier on highend phone
-rw-r--r--src/org/zeroxlab/graphics/DrawArcView.java23
-rw-r--r--src/org/zeroxlab/graphics/DrawCircle2View.java20
-rw-r--r--src/org/zeroxlab/graphics/DrawImageView.java26
-rw-r--r--src/org/zeroxlab/graphics/DrawTextView.java58
4 files changed, 83 insertions, 44 deletions
diff --git a/src/org/zeroxlab/graphics/DrawArcView.java b/src/org/zeroxlab/graphics/DrawArcView.java
index d05cfa9..4566e1f 100644
--- a/src/org/zeroxlab/graphics/DrawArcView.java
+++ b/src/org/zeroxlab/graphics/DrawArcView.java
@@ -55,18 +55,29 @@ class DrawArcView extends SurfaceView {
}
private void drawArc(Canvas canvas) {
- int color = (0x00252525 | new Random().nextInt() ) | Color.BLACK;
+ if (angle > 360) angle = 0;
+
+ int color = (0x00252525 | new Random().nextInt() ) | Color.BLACK;
Paint p = new Paint();
p.setAntiAlias(false);
p.setStyle(Paint.Style.FILL);
p.setColor(color);
- canvas.drawArc(new RectF(0,0, getWidth(), getHeight()), 0, angle, center, p);
- center = !center;
- angle += step;
- if (angle >= 360) {
- angle = 0;
+ canvas.drawArc(new RectF(0,0, getWidth(), getHeight()), 0, angle, true, p);
+
+ for(int j=0; j<3; j++) for(int x=0; x<4; x++) for(int y=0; y<4; y++) {
+ color = (0x88252525 | new Random().nextInt() );
+ p = new Paint();
+ p.setAntiAlias(false);
+ p.setStyle(Paint.Style.FILL);
+ p.setColor(color);
+
+ if(x%2==0)
+ canvas.drawArc(new RectF( x*getWidth()/4, y*getHeight()/4, (1+x)*getWidth()/4, (1+y)*getHeight()/4), 0, angle, (x+y)%2 == 0, p);
+ else
+ canvas.drawArc(new RectF( x*getWidth()/4, y*getHeight()/4, (1+x)*getWidth()/4, (1+y)*getHeight()/4), 0, -angle, (x+y)%2 == 0, p);
}
+ angle += step;
}
public DrawArcView(Context context, AttributeSet attrs) {
diff --git a/src/org/zeroxlab/graphics/DrawCircle2View.java b/src/org/zeroxlab/graphics/DrawCircle2View.java
index 62f8074..ee30b14 100644
--- a/src/org/zeroxlab/graphics/DrawCircle2View.java
+++ b/src/org/zeroxlab/graphics/DrawCircle2View.java
@@ -52,22 +52,26 @@ class DrawCircle2View extends SurfaceView {
}
private void drawCircle(Canvas canvas) {
- Random mRandom = new Random();
- int color = (0x00252525 | mRandom.nextInt() ) | Color.BLACK;
- Paint p = new Paint();
- p.setAntiAlias(false);
- p.setStyle(Paint.Style.FILL);
- p.setColor(color);
+ Random mRandom = new Random();
int height = getHeight();
int width = getWidth();
int cx = (int)((mRandom.nextInt() % (width*0.8) ) + (width*0.1));
int cy = (int)((mRandom.nextInt() % (height*0.8) ) + (height*0.1));
- int r = (int)((mRandom.nextInt() % (width*0.4) ) + (width*0.1));
+ int r = (int)((mRandom.nextInt() % (width*0.3) ) + (width*0.2));
- canvas.drawCircle(cx, cy, r, p);
+ int color;
+ Paint p;
+ for(int i=6; i>=0; i--) {
+ color = (0x33252525 | mRandom.nextInt());
+ p = new Paint();
+ p.setAntiAlias(true);
+ p.setStyle(Paint.Style.FILL);
+ p.setColor(color);
+ canvas.drawCircle(cx, cy, (int)(r*(1 + i/10.0)), p);
+ }
}
public DrawCircle2View(Context context, AttributeSet attrs) {
diff --git a/src/org/zeroxlab/graphics/DrawImageView.java b/src/org/zeroxlab/graphics/DrawImageView.java
index f8bf15d..ac144ea 100644
--- a/src/org/zeroxlab/graphics/DrawImageView.java
+++ b/src/org/zeroxlab/graphics/DrawImageView.java
@@ -47,12 +47,16 @@ import java.util.Random;
class DrawImageView extends SurfaceView {
+ private final int COL = 5;
+ private final int ROW = 9;
+
private SurfaceHolder mSurfaceHolder;
- private int position[] = {0,0,0,0,0};
- private boolean direction[] = {true,true,true,true,true};
+ private float position[] = new float[ROW];
+ private boolean direction[] = new boolean[ROW];
private Bitmap mBitmap;
private Paint bgPaint;
+
protected void setImage(Bitmap bmp) {
mBitmap = bmp;
}
@@ -64,15 +68,18 @@ class DrawImageView extends SurfaceView {
}
private void drawImage(Canvas canvas) {
- canvas.drawRect(0,0,getWidth(),getHeight(),bgPaint);
+ int w = getWidth();
+ int h = getHeight();
+ canvas.drawRect(0,0,w,h,bgPaint);
- for(int x=0; x<5; x++) {
+ for(int x=0; x<ROW; x++) {
int speed = (x+1) * 2;
-
- canvas.drawBitmap(mBitmap, (getWidth() - mBitmap.getWidth())/2, position[x], null);
+
+ for(int j=0; j<COL; j++)
+ canvas.drawBitmap(mBitmap, null, new RectF((w/(float)COL)*j, position[x], (w/(float)COL)*(j+1), position[x]+(w/(float)COL)), null);
if(direction[x]) {
position[x] += speed;
- if (position[x] + mBitmap.getHeight() >= getHeight())
+ if (position[x] + (w/(float)COL) >= getHeight())
direction[x] = !direction[x];
} else {
position[x] -= speed;
@@ -89,6 +96,11 @@ class DrawImageView extends SurfaceView {
bgPaint = new Paint();
bgPaint.setColor(Color.BLACK);
bgPaint.setStyle(Paint.Style.FILL);
+
+ for(int i=0; i<ROW; i++) {
+ position[i] = 0;
+ direction[i] = true;
+ }
}
}
diff --git a/src/org/zeroxlab/graphics/DrawTextView.java b/src/org/zeroxlab/graphics/DrawTextView.java
index 7238fcd..d125e77 100644
--- a/src/org/zeroxlab/graphics/DrawTextView.java
+++ b/src/org/zeroxlab/graphics/DrawTextView.java
@@ -45,6 +45,9 @@ class DrawTextView extends SurfaceView {
public final String TEXT1 = "0xbench";
public final String TEXT2 = "0xlab";
+ public final int TIMES = 10;
+
+ private Paint bgPaint;
class PaintText {
public int x;
@@ -72,34 +75,43 @@ class DrawTextView extends SurfaceView {
Random mRandom = new Random();
int height = getHeight();
int width = getWidth();
-
- int cx = (int)((mRandom.nextInt() % (width*0.8) ) + (width*0.1));
- int cy = (int)((mRandom.nextInt() % (height*0.8) ) + (height*0.1));
-
- int color = (0x00353535 | mRandom.nextInt() ) | Color.BLACK;
- Paint p = new Paint();
- p.setAntiAlias(false);
- p.setStyle(Paint.Style.FILL);
- p.setTextAlign(Paint.Align.CENTER);
-
- if(mRandom.nextInt()%2 == 0)
- p.setFakeBoldText(true);
-
- if(mRandom.nextInt()%2 == 0)
- p.setTextSkewX((float)-0.35);
-
- p.setColor(color);
- p.setTextSize(32 + (mRandom.nextInt()%24));
-
- if(mRandom.nextInt()%2 == 0)
- canvas.drawText(TEXT1, cx, cy, p);
- else
- canvas.drawText(TEXT2, cx, cy, p);
+ canvas.drawRect(0,0,width,height,bgPaint);
+
+ int cx;
+ int cy;
+ int color;
+ for(int i=0; i<TIMES; i++) {
+ cx = (int)((mRandom.nextInt() % (width*0.8) ) + (width*0.1));
+ cy = (int)((mRandom.nextInt() % (height*0.8) ) + (height*0.1));
+
+ color = (0x00555555 | mRandom.nextInt() ) | Color.BLACK;
+ Paint p = new Paint();
+ p.setAntiAlias(true);
+ p.setStyle(Paint.Style.FILL);
+ p.setTextAlign(Paint.Align.CENTER);
+
+ if(mRandom.nextInt()%2 == 0)
+ p.setFakeBoldText(true);
+
+ if(mRandom.nextInt()%2 == 0)
+ p.setTextSkewX((float)-0.45);
+
+ p.setColor(color);
+ p.setTextSize(42 + (mRandom.nextInt()%28));
+
+ if(mRandom.nextInt()%2 == 0)
+ canvas.drawText(TEXT1, cx, cy, p);
+ else
+ canvas.drawText(TEXT2, cx, cy, p);
+ }
}
public DrawTextView(Context context, AttributeSet attrs) {
super(context, attrs);
mSurfaceHolder = getHolder();
+ bgPaint = new Paint();
+ bgPaint.setColor(Color.BLACK);
+ bgPaint.setStyle(Paint.Style.FILL);
}
}