summaryrefslogtreecommitdiff
path: root/android/src/org/rockbox/RockboxFramebuffer.java
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-04 01:03:25 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-04 01:03:25 +0000
commit594110e962831b0d8ae2ded7efc49d48e4a6c3eb (patch)
treeb167636938ed249fb61ccd62e9873ef5481ee8af /android/src/org/rockbox/RockboxFramebuffer.java
parentf66a233bdbbf5c772903a744938d7333da1b53bf (diff)
Implement HAVE_LCD_ENABLE and lcd_update_rect(). When Rockbox runs in the background
this greatly reduces CPU load. lcd_update_rect shoves a bit as well. CPU usage with Rockbox in background is between 3% (with a 200kbps vbr mp3) and 12% (320kbps cbr mp3), so it's low but still dependent on codecs and even particular files. Driving a WPS with peakmeter, e.g. the builtin one, adds about 30% cpu usage. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27689 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android/src/org/rockbox/RockboxFramebuffer.java')
-rw-r--r--android/src/org/rockbox/RockboxFramebuffer.java35
1 files changed, 23 insertions, 12 deletions
diff --git a/android/src/org/rockbox/RockboxFramebuffer.java b/android/src/org/rockbox/RockboxFramebuffer.java
index f947806bb4..ca11de090c 100644
--- a/android/src/org/rockbox/RockboxFramebuffer.java
+++ b/android/src/org/rockbox/RockboxFramebuffer.java
@@ -34,21 +34,11 @@ public class RockboxFramebuffer extends View
{
private Bitmap btm;
private ByteBuffer native_buf;
- private Handler update_handler;
- private Runnable cb;
public RockboxFramebuffer(Context c)
{
super(c);
- update_handler = new Handler();
- cb = new Runnable() {
- public void run()
- {
- btm.copyPixelsFromBuffer(native_buf);
- invalidate();
- }
- };
btm = null;
}
@@ -66,12 +56,21 @@ public class RockboxFramebuffer extends View
public void java_lcd_update()
{
- update_handler.post(cb);
+
+ btm.copyPixelsFromBuffer(native_buf);
+ postInvalidate();
+ }
+
+ public void java_lcd_update_rect(int x, int y, int w, int h)
+ {
+ /* can't copy a partial buffer */
+ btm.copyPixelsFromBuffer(native_buf);
+ postInvalidate(x, y, x+w, y+h);
}
private void LOG(CharSequence text)
{
- Log.d("RockboxBootloader", (String) text);
+ Log.d("RockboxBootloader", (String) text);
}
public boolean onTouchEvent(MotionEvent me)
@@ -93,6 +92,18 @@ public class RockboxFramebuffer extends View
return true;
}
+ /* the two below should only be called from the activity thread */
+ public void suspend()
+ { /* suspend, Rockbox will not make any lcd updates */
+ set_lcd_active(0);
+ }
+ public void resume()
+ { /* make updates again, the underlying function will
+ * send an event */
+ set_lcd_active(1);
+ }
+
+ public native void set_lcd_active(int active);
public native void pixelHandler(int x, int y);
public native void touchHandler(int down);
}