diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-08-04 01:03:25 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-08-04 01:03:25 +0000 |
commit | 594110e962831b0d8ae2ded7efc49d48e4a6c3eb (patch) | |
tree | b167636938ed249fb61ccd62e9873ef5481ee8af /android | |
parent | f66a233bdbbf5c772903a744938d7333da1b53bf (diff) | |
download | rockbox-594110e962831b0d8ae2ded7efc49d48e4a6c3eb.tar.gz rockbox-594110e962831b0d8ae2ded7efc49d48e4a6c3eb.zip |
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')
-rw-r--r-- | android/src/org/rockbox/RockboxActivity.java | 23 | ||||
-rw-r--r-- | android/src/org/rockbox/RockboxFramebuffer.java | 35 |
2 files changed, 46 insertions, 12 deletions
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java index 38bfec16ef..2bafb6688d 100644 --- a/android/src/org/rockbox/RockboxActivity.java +++ b/android/src/org/rockbox/RockboxActivity.java | |||
@@ -78,6 +78,7 @@ public class RockboxActivity extends Activity { | |||
78 | public void onResume() | 78 | public void onResume() |
79 | { | 79 | { |
80 | super.onResume(); | 80 | super.onResume(); |
81 | |||
81 | if (RockboxService.fb != null) | 82 | if (RockboxService.fb != null) |
82 | { | 83 | { |
83 | try { | 84 | try { |
@@ -91,8 +92,30 @@ public class RockboxActivity extends Activity { | |||
91 | } catch (Exception e) { | 92 | } catch (Exception e) { |
92 | LOG(e.toString()); | 93 | LOG(e.toString()); |
93 | } | 94 | } |
95 | RockboxService.fb.resume(); | ||
94 | } | 96 | } |
95 | } | 97 | } |
98 | |||
99 | /* this is also called when the backlight goes off, | ||
100 | * which is nice | ||
101 | */ | ||
102 | @Override | ||
103 | protected void onPause() { | ||
104 | super.onPause(); | ||
105 | RockboxService.fb.suspend(); | ||
106 | } | ||
107 | |||
108 | @Override | ||
109 | protected void onStop() { | ||
110 | super.onStop(); | ||
111 | RockboxService.fb.suspend(); | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | protected void onDestroy() { | ||
116 | super.onDestroy(); | ||
117 | RockboxService.fb.suspend(); | ||
118 | } | ||
96 | 119 | ||
97 | private void LOG(CharSequence text) | 120 | private void LOG(CharSequence text) |
98 | { | 121 | { |
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 | |||
34 | { | 34 | { |
35 | private Bitmap btm; | 35 | private Bitmap btm; |
36 | private ByteBuffer native_buf; | 36 | private ByteBuffer native_buf; |
37 | private Handler update_handler; | ||
38 | private Runnable cb; | ||
39 | 37 | ||
40 | 38 | ||
41 | public RockboxFramebuffer(Context c) | 39 | public RockboxFramebuffer(Context c) |
42 | { | 40 | { |
43 | super(c); | 41 | super(c); |
44 | update_handler = new Handler(); | ||
45 | cb = new Runnable() { | ||
46 | public void run() | ||
47 | { | ||
48 | btm.copyPixelsFromBuffer(native_buf); | ||
49 | invalidate(); | ||
50 | } | ||
51 | }; | ||
52 | btm = null; | 42 | btm = null; |
53 | } | 43 | } |
54 | 44 | ||
@@ -66,12 +56,21 @@ public class RockboxFramebuffer extends View | |||
66 | 56 | ||
67 | public void java_lcd_update() | 57 | public void java_lcd_update() |
68 | { | 58 | { |
69 | update_handler.post(cb); | 59 | |
60 | btm.copyPixelsFromBuffer(native_buf); | ||
61 | postInvalidate(); | ||
62 | } | ||
63 | |||
64 | public void java_lcd_update_rect(int x, int y, int w, int h) | ||
65 | { | ||
66 | /* can't copy a partial buffer */ | ||
67 | btm.copyPixelsFromBuffer(native_buf); | ||
68 | postInvalidate(x, y, x+w, y+h); | ||
70 | } | 69 | } |
71 | 70 | ||
72 | private void LOG(CharSequence text) | 71 | private void LOG(CharSequence text) |
73 | { | 72 | { |
74 | Log.d("RockboxBootloader", (String) text); | 73 | Log.d("RockboxBootloader", (String) text); |
75 | } | 74 | } |
76 | 75 | ||
77 | public boolean onTouchEvent(MotionEvent me) | 76 | public boolean onTouchEvent(MotionEvent me) |
@@ -93,6 +92,18 @@ public class RockboxFramebuffer extends View | |||
93 | return true; | 92 | return true; |
94 | } | 93 | } |
95 | 94 | ||
95 | /* the two below should only be called from the activity thread */ | ||
96 | public void suspend() | ||
97 | { /* suspend, Rockbox will not make any lcd updates */ | ||
98 | set_lcd_active(0); | ||
99 | } | ||
100 | public void resume() | ||
101 | { /* make updates again, the underlying function will | ||
102 | * send an event */ | ||
103 | set_lcd_active(1); | ||
104 | } | ||
105 | |||
106 | public native void set_lcd_active(int active); | ||
96 | public native void pixelHandler(int x, int y); | 107 | public native void pixelHandler(int x, int y); |
97 | public native void touchHandler(int down); | 108 | public native void touchHandler(int down); |
98 | } | 109 | } |