OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef surface_glue_android_DEFINED |
| 9 #define surface_glue_android_DEFINED |
| 10 |
| 11 #include <pthread.h> |
| 12 |
| 13 #include <android/native_window_jni.h> |
| 14 |
| 15 #include "../Application.h" |
| 16 #include "../Window.h" |
| 17 |
| 18 namespace sk_app { |
| 19 |
| 20 enum MessageType { |
| 21 kUndefined, |
| 22 kSurfaceCreated, |
| 23 kSurfaceChanged, |
| 24 kSurfaceDestroyed, |
| 25 kDestroyApp, |
| 26 kContentInvalidated |
| 27 }; |
| 28 |
| 29 struct Message { |
| 30 MessageType fType = kUndefined; |
| 31 ANativeWindow* fNativeWindow = nullptr; |
| 32 |
| 33 Message() {} |
| 34 Message(MessageType t) : fType(t) {} |
| 35 }; |
| 36 |
| 37 struct SkiaAndroidApp { |
| 38 int fPipes[2]; // 0 is the read message pipe, 1 is the write message pipe |
| 39 Application* fApp; |
| 40 Window* fWindow; |
| 41 ANativeWindow* fNativeWindow; |
| 42 |
| 43 SkiaAndroidApp(); |
| 44 ~SkiaAndroidApp(); |
| 45 void postMessage(const Message& message); |
| 46 void readMessage(Message* message); |
| 47 void paintIfNeeded(); |
| 48 |
| 49 private: |
| 50 pthread_t fThread; |
| 51 }; |
| 52 |
| 53 } // namespace sk_app |
| 54 |
| 55 #endif |
OLD | NEW |