| 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 |
| 11 #include <pthread.h> | 11 #include <pthread.h> |
| 12 | 12 |
| 13 #include <android/native_window_jni.h> | 13 #include <android/native_window_jni.h> |
| 14 | 14 |
| 15 #include "../private/SkMutex.h" | |
| 16 #include "../Application.h" | 15 #include "../Application.h" |
| 17 #include "../Window.h" | 16 #include "../Window.h" |
| 18 | 17 |
| 19 namespace sk_app { | 18 namespace sk_app { |
| 20 | 19 |
| 21 enum MessageType { | 20 enum MessageType { |
| 22 kUndefined, | 21 kUndefined, |
| 23 kSurfaceCreated, | 22 kSurfaceCreated, |
| 24 kSurfaceChanged, | 23 kSurfaceChanged, |
| 25 kSurfaceDestroyed, | 24 kSurfaceDestroyed, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 47 | 46 |
| 48 SkiaAndroidApp(JNIEnv* env, jobject androidApp); | 47 SkiaAndroidApp(JNIEnv* env, jobject androidApp); |
| 49 | 48 |
| 50 void postMessage(const Message& message) const; | 49 void postMessage(const Message& message) const; |
| 51 void readMessage(Message* message) const; | 50 void readMessage(Message* message) const; |
| 52 void paintIfNeeded(); | 51 void paintIfNeeded(); |
| 53 | 52 |
| 54 // This must be called in SkiaAndroidApp's own pthread because the JNIEnv is
thread sensitive | 53 // This must be called in SkiaAndroidApp's own pthread because the JNIEnv is
thread sensitive |
| 55 void setTitle(const char* title) const; | 54 void setTitle(const char* title) const; |
| 56 | 55 |
| 57 // This posts a kContentInvalidated message if there's no such message curre
ntly in the queue | |
| 58 void inval(); | |
| 59 | |
| 60 private: | 56 private: |
| 61 pthread_t fThread; | 57 pthread_t fThread; |
| 62 ANativeWindow* fNativeWindow; | 58 ANativeWindow* fNativeWindow; |
| 63 int fPipes[2]; // 0 is the read message pipe, 1 is the write message pipe | 59 int fPipes[2]; // 0 is the read message pipe, 1 is the write message pipe |
| 64 JavaVM* fJavaVM; | 60 JavaVM* fJavaVM; |
| 65 JNIEnv* fPThreadEnv; | 61 JNIEnv* fPThreadEnv; |
| 66 jmethodID fSetTitleMethodID; | 62 jmethodID fSetTitleMethodID; |
| 67 | 63 |
| 68 bool fIsContentInvalidated = false; // use this to avoid duplicate invalida
te events | |
| 69 SkMutex fMutex; | |
| 70 | |
| 71 // This must be called in SkiaAndroidApp's own pthread because the JNIEnv is
thread sensitive | 64 // This must be called in SkiaAndroidApp's own pthread because the JNIEnv is
thread sensitive |
| 72 ~SkiaAndroidApp(); | 65 ~SkiaAndroidApp(); |
| 73 | 66 |
| 74 static int message_callback(int fd, int events, void* data); | 67 static int message_callback(int fd, int events, void* data); |
| 75 static void* pthread_main(void*); | 68 static void* pthread_main(void*); |
| 76 }; | 69 }; |
| 77 | 70 |
| 78 } // namespace sk_app | 71 } // namespace sk_app |
| 79 | 72 |
| 80 #endif | 73 #endif |
| OLD | NEW |