summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/android
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 /firmware/target/hosted/android
parentf66a233bdbbf5c772903a744938d7333da1b53bf (diff)
downloadrockbox-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 'firmware/target/hosted/android')
-rw-r--r--firmware/target/hosted/android/lcd-android.c60
1 files changed, 48 insertions, 12 deletions
diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c
index efe68cdd71..1043dfa35c 100644
--- a/firmware/target/hosted/android/lcd-android.c
+++ b/firmware/target/hosted/android/lcd-android.c
@@ -31,6 +31,9 @@ extern jobject RockboxService_instance;
31 31
32static jobject Framebuffer_instance; 32static jobject Framebuffer_instance;
33static jmethodID java_lcd_update; 33static jmethodID java_lcd_update;
34static jmethodID java_lcd_update_rect;
35
36static bool display_on;
34 37
35void lcd_init_device(void) 38void lcd_init_device(void)
36{ 39{
@@ -52,13 +55,17 @@ void lcd_init_device(void)
52 * our framebuffer */ 55 * our framebuffer */
53 56
54 jmethodID java_init_lcd = (*env_ptr)->GetMethodID(env_ptr, 57 jmethodID java_init_lcd = (*env_ptr)->GetMethodID(env_ptr,
55 Framebuffer_class, 58 Framebuffer_class,
56 "java_lcd_init", 59 "java_lcd_init",
57 "(IILjava/nio/ByteBuffer;)V"); 60 "(IILjava/nio/ByteBuffer;)V");
58 java_lcd_update = (*env_ptr)->GetMethodID(env_ptr, 61 java_lcd_update = (*env_ptr)->GetMethodID(env_ptr,
59 Framebuffer_class, 62 Framebuffer_class,
60 "java_lcd_update", 63 "java_lcd_update",
61 "()V"); 64 "()V");
65 java_lcd_update_rect = (*env_ptr)->GetMethodID(env_ptr,
66 Framebuffer_class,
67 "java_lcd_update_rect",
68 "(IIII)V");
62 69
63 /* map the framebuffer to a ByteBuffer, this way lcd updates will 70 /* map the framebuffer to a ByteBuffer, this way lcd updates will
64 * be directly feched from the framebuffer */ 71 * be directly feched from the framebuffer */
@@ -70,21 +77,50 @@ void lcd_init_device(void)
70 Framebuffer_instance, 77 Framebuffer_instance,
71 java_init_lcd, 78 java_init_lcd,
72 LCD_WIDTH, LCD_HEIGHT, buf); 79 LCD_WIDTH, LCD_HEIGHT, buf);
80 display_on = true;
73} 81}
74 82
75void lcd_update() 83void lcd_update(void)
76{ 84{
77 /* tell the system we're ready for drawing */ 85 /* tell the system we're ready for drawing */
78 (*env_ptr)->CallVoidMethod(env_ptr, Framebuffer_instance, java_lcd_update); 86 if (display_on)
87 (*env_ptr)->CallVoidMethod(env_ptr, Framebuffer_instance, java_lcd_update);
79} 88}
80 89
81void lcd_update_rect(int x, int y, int height, int width) 90void lcd_update_rect(int x, int y, int height, int width)
82{ 91{
83 /* can't do partial updates yet */ 92 if (display_on)
84 (void)x; (void)y; (void)height; (void)width; 93 {
85 lcd_update(); 94 (*env_ptr)->CallVoidMethod(env_ptr, Framebuffer_instance, java_lcd_update_rect,
95 x, y, height, width);
96 }
97}
98
99bool lcd_active(void)
100{
101 return display_on;
86} 102}
87 103
104/*
105 * (un)block lcd updates.
106 *
107 * Notice: This is called from the activity thread, so take it
108 * as interrupt context and take care what the event callback does
109 * (it shouldn't block in particular
110 *
111 * the 1s are needed due to strange naming conventions...
112 **/
113JNIEXPORT void JNICALL
114Java_org_rockbox_RockboxFramebuffer_set_1lcd_1active(JNIEnv *e,
115 jobject this,
116 jint active)
117{
118 (void)e;
119 (void)this;
120 display_on = active != 0;
121 if (active)
122 send_event(LCD_EVENT_ACTIVATION, NULL);
123}
88/* below is a plain copy from lcd-sdl.c */ 124/* below is a plain copy from lcd-sdl.c */
89 125
90/** 126/**