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

Side by Side Diff: tools/viewer/android/Window_android.cpp

Issue 1945103003: Rename VulkanViewer to Viewer, take 2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix android path 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
« no previous file with comments | « tools/viewer/android/Window_android.h ('k') | tools/viewer/android/main_android.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "Window_android.h" 8 #include "Window_android.h"
9 9
10 #include "VulkanTestContext_android.h" 10 #include "VulkanTestContext_android.h"
11 11
12 namespace sk_app {
13
12 Window* Window::CreateNativeWindow(void* platformData) { 14 Window* Window::CreateNativeWindow(void* platformData) {
13 Window_android* window = new Window_android(); 15 Window_android* window = new Window_android();
14 if (!window->init((android_app*)platformData)) { 16 if (!window->init((android_app*)platformData)) {
15 delete window; 17 delete window;
16 return nullptr; 18 return nullptr;
17 } 19 }
18 return window; 20 return window;
19 } 21 }
20 22
21 static void handle_cmd(struct android_app* app, int32_t cmd); 23 static void handle_cmd(struct android_app* app, int32_t cmd);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 fTestContext = VulkanTestContext::Create((void*)&platformData, mSampleCount) ; 56 fTestContext = VulkanTestContext::Create((void*)&platformData, mSampleCount) ;
55 } 57 }
56 58
57 static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) { 59 static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) {
58 if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) { 60 if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) {
59 SkDebugf("Failure writing android_app cmd: %s\n", strerror(errno)); 61 SkDebugf("Failure writing android_app cmd: %s\n", strerror(errno));
60 } 62 }
61 } 63 }
62 64
63 void Window_android::inval() { 65 void Window_android::inval() {
64 » android_app_write_cmd(mApp, APP_CMD_INVAL_WINDOW); 66 android_app_write_cmd(mApp, APP_CMD_INVAL_WINDOW);
65 } 67 }
66 68
67 void Window_android::paintIfNeeded() { 69 void Window_android::paintIfNeeded() {
68 if (mApp->window || !mContentRect.isEmpty()) { 70 if (mApp->window || !mContentRect.isEmpty()) {
69 this->onPaint(); 71 this->onPaint();
70 } 72 }
71 } 73 }
72 74
73 /** 75 /**
74 * Process the next main command. 76 * Process the next main command.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 int32_t fWindowModifier; 144 int32_t fWindowModifier;
143 } gPair[] = { 145 } gPair[] = {
144 { AMETA_SHIFT_ON, Window::kShift_ModifierKey }, 146 { AMETA_SHIFT_ON, Window::kShift_ModifierKey },
145 { AMETA_CTRL_ON, Window::kControl_ModifierKey }, 147 { AMETA_CTRL_ON, Window::kControl_ModifierKey },
146 }; 148 };
147 149
148 int32_t metaState = AKeyEvent_getMetaState(event); 150 int32_t metaState = AKeyEvent_getMetaState(event);
149 int32_t modifiers = 0; 151 int32_t modifiers = 0;
150 152
151 if (AKeyEvent_getRepeatCount(event) == 0) { 153 if (AKeyEvent_getRepeatCount(event) == 0) {
152 » modifiers |= Window::kFirstPress_ModifierKey; 154 modifiers |= Window::kFirstPress_ModifierKey;
153 } 155 }
154 156
155 for (size_t i = 0; i < SK_ARRAY_COUNT(gPair); i++) { 157 for (size_t i = 0; i < SK_ARRAY_COUNT(gPair); i++) {
156 if (gPair[i].fAndroidState == metaState) { 158 if (gPair[i].fAndroidState == metaState) {
157 modifiers |= gPair[i].fWindowModifier; 159 modifiers |= gPair[i].fWindowModifier;
158 } 160 }
159 } 161 }
160 return modifiers; 162 return modifiers;
161 } 163 }
162 164
163 /** 165 /**
164 * Process the next input event. 166 * Process the next input event.
165 */ 167 */
166 static int32_t handle_input(struct android_app* app, AInputEvent* event) { 168 static int32_t handle_input(struct android_app* app, AInputEvent* event) {
167 Window_android* window = (Window_android*)app->userData; 169 Window_android* window = (Window_android*)app->userData;
168 switch(AInputEvent_getType(event)) { 170 switch(AInputEvent_getType(event)) {
169 case AINPUT_EVENT_TYPE_MOTION: 171 case AINPUT_EVENT_TYPE_MOTION:
170 break; 172 break;
171 case AINPUT_EVENT_TYPE_KEY: 173 case AINPUT_EVENT_TYPE_KEY:
172 Window::Key key = get_key(AKeyEvent_getKeyCode(event)); 174 Window::Key key = get_key(AKeyEvent_getKeyCode(event));
173 Window::InputState state = get_action(AKeyEvent_getAction(event)); 175 Window::InputState state = get_action(AKeyEvent_getAction(event));
174 int32_t mod = get_key_modifiers(event); 176 int32_t mod = get_key_modifiers(event);
175 window->onKey(key, state, mod); 177 window->onKey(key, state, mod);
176 return true; // eat all key events 178 return true; // eat all key events
177 } 179 }
178 return 0; 180 return 0;
179 } 181 }
182
183 } // namespace sk_app
OLDNEW
« no previous file with comments | « tools/viewer/android/Window_android.h ('k') | tools/viewer/android/main_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698