OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef surface_glue_android_DEFINED | 8 #ifndef surface_glue_android_DEFINED |
9 #define surface_glue_android_DEFINED | 9 #define surface_glue_android_DEFINED |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 struct Message { | 30 struct Message { |
31 MessageType fType = kUndefined; | 31 MessageType fType = kUndefined; |
32 ANativeWindow* fNativeWindow = nullptr; | 32 ANativeWindow* fNativeWindow = nullptr; |
33 int keycode = 0; | 33 int keycode = 0; |
34 | 34 |
35 Message() {} | 35 Message() {} |
36 Message(MessageType t) : fType(t) {} | 36 Message(MessageType t) : fType(t) {} |
37 }; | 37 }; |
38 | 38 |
39 struct SkiaAndroidApp { | 39 struct SkiaAndroidApp { |
40 int fPipes[2]; // 0 is the read message pipe, 1 is the write message pipe | |
41 Application* fApp; | 40 Application* fApp; |
42 Window* fWindow; | 41 Window* fWindow; |
43 ANativeWindow* fNativeWindow; | 42 jobject fAndroidApp; |
44 | 43 |
45 SkiaAndroidApp(); | 44 SkiaAndroidApp(JNIEnv* env, jobject androidApp); |
46 ~SkiaAndroidApp(); | 45 |
47 void postMessage(const Message& message); | 46 void postMessage(const Message& message) const; |
48 void readMessage(Message* message); | 47 void readMessage(Message* message) const; |
49 void paintIfNeeded(); | 48 void paintIfNeeded(); |
50 | 49 |
| 50 // This must be called in SkiaAndroidApp's own pthread because the JNIEnv is
thread sensitive |
| 51 void setTitle(const char* title) const; |
51 private: | 52 private: |
52 pthread_t fThread; | 53 pthread_t fThread; |
| 54 ANativeWindow* fNativeWindow; |
| 55 int fPipes[2]; // 0 is the read message pipe, 1 is the write message pipe |
| 56 JavaVM* fJavaVM; |
| 57 JNIEnv* fPThreadEnv; |
| 58 jmethodID fSetTitleMethodID; |
| 59 |
| 60 // This must be called in SkiaAndroidApp's own pthread because the JNIEnv is
thread sensitive |
| 61 ~SkiaAndroidApp(); |
| 62 |
| 63 static int message_callback(int fd, int events, void* data); |
| 64 static void* pthread_main(void*); |
53 }; | 65 }; |
54 | 66 |
55 } // namespace sk_app | 67 } // namespace sk_app |
56 | 68 |
57 #endif | 69 #endif |
OLD | NEW |