Chromium Code Reviews| 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); |
| 45 | |
| 46 // This must be called in SkiaAndroidApp's own pthread because the JNIEnv is thread sensitive | |
|
djsollen
2016/05/13 14:56:27
do we have some way to enforce this behavior?
liyuqian
2016/05/13 15:18:41
One way that I can think of is to check the curren
| |
| 46 ~SkiaAndroidApp(); | 47 ~SkiaAndroidApp(); |
| 47 void postMessage(const Message& message); | 48 |
| 48 void readMessage(Message* message); | 49 void postMessage(const Message& message) const; |
| 50 void readMessage(Message* message) const; | |
| 49 void paintIfNeeded(); | 51 void paintIfNeeded(); |
| 50 | 52 |
| 53 // This must be called in SkiaAndroidApp's own pthread because the JNIEnv is thread sensitive | |
| 54 void setAndroidTitle(const char* title) const; | |
|
djsollen
2016/05/13 14:56:27
shorten to setTitle
liyuqian
2016/05/13 15:18:42
Done.
| |
| 55 | |
| 56 static int message_callback(int fd, int events, void* data); | |
| 57 static void* pthread_main(void*); | |
|
djsollen
2016/05/13 14:56:27
I think you should be able to make these functions
liyuqian
2016/05/13 15:18:42
Done.
| |
| 58 | |
| 51 private: | 59 private: |
| 52 pthread_t fThread; | 60 pthread_t fThread; |
| 61 ANativeWindow* fNativeWindow; | |
| 62 int fPipes[2]; // 0 is the read message pipe, 1 is the write message pipe | |
| 63 JavaVM* fJavaVM; | |
| 64 JNIEnv* fPThreadEnv; | |
| 53 }; | 65 }; |
| 54 | 66 |
| 55 } // namespace sk_app | 67 } // namespace sk_app |
| 56 | 68 |
| 57 #endif | 69 #endif |
| OLD | NEW |