diff options
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r-- | firmware/target/hosted/android/lcd-android.c | 60 |
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 | ||
32 | static jobject Framebuffer_instance; | 32 | static jobject Framebuffer_instance; |
33 | static jmethodID java_lcd_update; | 33 | static jmethodID java_lcd_update; |
34 | static jmethodID java_lcd_update_rect; | ||
35 | |||
36 | static bool display_on; | ||
34 | 37 | ||
35 | void lcd_init_device(void) | 38 | void 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 | ||
75 | void lcd_update() | 83 | void 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 | ||
81 | void lcd_update_rect(int x, int y, int height, int width) | 90 | void 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 | |||
99 | bool 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 | **/ | ||
113 | JNIEXPORT void JNICALL | ||
114 | Java_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 | /** |