Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: tools/viewer/sk_app/android/surface_glue_android.h

Issue 2004633002: Add drawer with state information (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Format_old Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "../Application.h" 15 #include "../Application.h"
16 #include "../Window.h" 16 #include "../Window.h"
17 17
18 namespace sk_app { 18 namespace sk_app {
19 19
20 enum MessageType { 20 enum MessageType {
21 kUndefined, 21 kUndefined,
22 kSurfaceCreated, 22 kSurfaceCreated,
23 kSurfaceChanged, 23 kSurfaceChanged,
24 kSurfaceDestroyed, 24 kSurfaceDestroyed,
25 kDestroyApp, 25 kDestroyApp,
26 kContentInvalidated, 26 kContentInvalidated,
27 kKeyPressed, 27 kKeyPressed,
28 kTouched 28 kTouched,
29 kSetState
29 }; 30 };
30 31
31 struct Message { 32 struct Message {
32 MessageType fType = kUndefined; 33 MessageType fType = kUndefined;
33 ANativeWindow* fNativeWindow = nullptr; 34 ANativeWindow* fNativeWindow = nullptr;
34 int fKeycode = 0; 35 int fKeycode = 0;
35 int fTouchOwner, fTouchState; 36 int fTouchOwner, fTouchState;
36 float fTouchX, fTouchY; 37 float fTouchX, fTouchY;
37 38
39 // Make sure to delete following SkStrings after consumption
40 SkString* stateName;
djsollen 2016/05/24 17:32:40 don't store pointers just store an SkString
liyuqian 2016/05/24 20:18:05 We'll preserve the pointers because of the message
41 SkString* stateValue;
42
38 Message() {} 43 Message() {}
39 Message(MessageType t) : fType(t) {} 44 Message(MessageType t) : fType(t) {}
40 }; 45 };
41 46
42 struct SkiaAndroidApp { 47 struct SkiaAndroidApp {
43 Application* fApp; 48 Application* fApp;
44 Window* fWindow; 49 Window* fWindow;
45 jobject fAndroidApp; 50 jobject fAndroidApp;
46 51
47 SkiaAndroidApp(JNIEnv* env, jobject androidApp); 52 SkiaAndroidApp(JNIEnv* env, jobject androidApp);
48 53
49 void postMessage(const Message& message) const; 54 void postMessage(const Message& message) const;
50 void readMessage(Message* message) const; 55 void readMessage(Message* message) const;
51 56
52 // This must be called in SkiaAndroidApp's own pthread because the JNIEnv is thread sensitive 57 // These must be called in SkiaAndroidApp's own pthread because the JNIEnv i s thread sensitive
53 void setTitle(const char* title) const; 58 void setTitle(const char* title) const;
59 void updateState(const char* stateJsonStr) const;
54 60
55 private: 61 private:
56 pthread_t fThread; 62 pthread_t fThread;
57 ANativeWindow* fNativeWindow; 63 ANativeWindow* fNativeWindow;
58 int fPipes[2]; // 0 is the read message pipe, 1 is the write message pipe 64 int fPipes[2]; // 0 is the read message pipe, 1 is the write message pipe
59 JavaVM* fJavaVM; 65 JavaVM* fJavaVM;
60 JNIEnv* fPThreadEnv; 66 JNIEnv* fPThreadEnv;
61 jmethodID fSetTitleMethodID; 67 jmethodID fSetTitleMethodID, fUpdateStateMethodID;
62 68
63 // This must be called in SkiaAndroidApp's own pthread because the JNIEnv is thread sensitive 69 // This must be called in SkiaAndroidApp's own pthread because the JNIEnv is thread sensitive
64 ~SkiaAndroidApp(); 70 ~SkiaAndroidApp();
65 71
66 static int message_callback(int fd, int events, void* data); 72 static int message_callback(int fd, int events, void* data);
67 static void* pthread_main(void*); 73 static void* pthread_main(void*);
68 }; 74 };
69 75
70 } // namespace sk_app 76 } // namespace sk_app
71 77
72 #endif 78 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698