diff options
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r-- | firmware/target/hosted/android/lcd-android.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c index 15c844bbd6..bb0331db69 100644 --- a/firmware/target/hosted/android/lcd-android.c +++ b/firmware/target/hosted/android/lcd-android.c | |||
@@ -36,6 +36,9 @@ static jmethodID java_lcd_update; | |||
36 | static jmethodID java_lcd_update_rect; | 36 | static jmethodID java_lcd_update_rect; |
37 | static jmethodID java_lcd_init; | 37 | static jmethodID java_lcd_init; |
38 | 38 | ||
39 | static jclass AndroidRect_class; | ||
40 | static jmethodID AndroidRect_constructor; | ||
41 | |||
39 | static int dpi; | 42 | static int dpi; |
40 | static int scroll_threshold; | 43 | static int scroll_threshold; |
41 | static bool display_on; | 44 | static bool display_on; |
@@ -43,7 +46,7 @@ static bool display_on; | |||
43 | /* this might actually be called before lcd_init_device() or even main(), so | 46 | /* this might actually be called before lcd_init_device() or even main(), so |
44 | * be sure to only access static storage initalized at library loading, | 47 | * be sure to only access static storage initalized at library loading, |
45 | * and not more */ | 48 | * and not more */ |
46 | void connect_with_java(JNIEnv* env, jobject fb_instance) | 49 | static void connect_with_java(JNIEnv* env, jobject fb_instance) |
47 | { | 50 | { |
48 | JNIEnv e = *env; | 51 | JNIEnv e = *env; |
49 | static bool have_class; | 52 | static bool have_class; |
@@ -53,11 +56,12 @@ void connect_with_java(JNIEnv* env, jobject fb_instance) | |||
53 | jclass fb_class = e->GetObjectClass(env, fb_instance); | 56 | jclass fb_class = e->GetObjectClass(env, fb_instance); |
54 | /* cache update functions */ | 57 | /* cache update functions */ |
55 | java_lcd_update = e->GetMethodID(env, fb_class, | 58 | java_lcd_update = e->GetMethodID(env, fb_class, |
56 | "java_lcd_update", | 59 | "update", |
57 | "()V"); | 60 | "(Ljava/nio/ByteBuffer;)V"); |
58 | java_lcd_update_rect = e->GetMethodID(env, fb_class, | 61 | java_lcd_update_rect = e->GetMethodID(env, fb_class, |
59 | "java_lcd_update_rect", | 62 | "update", |
60 | "(IIII)V"); | 63 | "(Ljava/nio/ByteBuffer;" |
64 | "Landroid/graphics/Rect;)V"); | ||
61 | jmethodID get_dpi = e->GetMethodID(env, fb_class, | 65 | jmethodID get_dpi = e->GetMethodID(env, fb_class, |
62 | "getDpi", "()I"); | 66 | "getDpi", "()I"); |
63 | jmethodID thresh = e->GetMethodID(env, fb_class, | 67 | jmethodID thresh = e->GetMethodID(env, fb_class, |
@@ -67,19 +71,16 @@ void connect_with_java(JNIEnv* env, jobject fb_instance) | |||
67 | scroll_threshold = e->CallIntMethod(env, fb_instance, thresh); | 71 | scroll_threshold = e->CallIntMethod(env, fb_instance, thresh); |
68 | 72 | ||
69 | java_lcd_init = e->GetMethodID(env, fb_class, | 73 | java_lcd_init = e->GetMethodID(env, fb_class, |
70 | "java_lcd_init", | 74 | "initialize", "(II)V"); |
71 | "(IILjava/nio/ByteBuffer;)V"); | 75 | AndroidRect_class = e->FindClass(env, "android/graphics/Rect"); |
72 | 76 | AndroidRect_constructor = e->GetMethodID(env, AndroidRect_class, | |
77 | "<init>", "(IIII)V"); | ||
73 | have_class = true; | 78 | have_class = true; |
74 | } | 79 | } |
75 | 80 | ||
76 | /* Create native_buffer */ | ||
77 | jobject buffer = (*env)->NewDirectByteBuffer(env, lcd_framebuffer, | ||
78 | (jlong) FRAMEBUFFER_SIZE); | ||
79 | |||
80 | /* we need to setup parts for the java object every time */ | 81 | /* we need to setup parts for the java object every time */ |
81 | (*env)->CallVoidMethod(env, fb_instance, java_lcd_init, | 82 | (*env)->CallVoidMethod(env, fb_instance, java_lcd_init, |
82 | (jint)LCD_WIDTH, (jint)LCD_HEIGHT, buffer); | 83 | (jint)LCD_WIDTH, (jint)LCD_HEIGHT); |
83 | } | 84 | } |
84 | 85 | ||
85 | /* | 86 | /* |
@@ -92,15 +93,32 @@ void lcd_init_device(void) | |||
92 | void lcd_update(void) | 93 | void lcd_update(void) |
93 | { | 94 | { |
94 | if (display_on) | 95 | if (display_on) |
95 | (*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, | 96 | { |
96 | java_lcd_update); | 97 | JNIEnv e = *env_ptr; |
98 | jobject buffer = e->NewDirectByteBuffer(env_ptr, lcd_framebuffer, | ||
99 | (jlong) FRAMEBUFFER_SIZE); | ||
100 | |||
101 | e->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, | ||
102 | java_lcd_update, buffer); | ||
103 | e->DeleteLocalRef(env_ptr, buffer); | ||
104 | } | ||
97 | } | 105 | } |
98 | 106 | ||
99 | void lcd_update_rect(int x, int y, int width, int height) | 107 | void lcd_update_rect(int x, int y, int width, int height) |
100 | { | 108 | { |
101 | if (display_on) | 109 | if (display_on) |
102 | (*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, | 110 | { |
103 | java_lcd_update_rect, x, y, width, height); | 111 | JNIEnv e = *env_ptr; |
112 | jobject buffer = e->NewDirectByteBuffer(env_ptr, lcd_framebuffer, | ||
113 | (jlong) FRAMEBUFFER_SIZE); | ||
114 | jobject rect = e->NewObject(env_ptr, AndroidRect_class, AndroidRect_constructor, | ||
115 | x, y, x + width, y + height); | ||
116 | e->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, | ||
117 | java_lcd_update_rect, buffer, rect); | ||
118 | |||
119 | e->DeleteLocalRef(env_ptr, buffer); | ||
120 | e->DeleteLocalRef(env_ptr, rect); | ||
121 | } | ||
104 | } | 122 | } |
105 | 123 | ||
106 | /* | 124 | /* |