| 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 #include "Window_android.h" | 8 #include "Window_android.h" |
| 9 | 9 |
| 10 #include "VulkanWindowContext_android.h" | 10 #include "VulkanWindowContext_android.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 mApp->onAppCmd = handle_cmd; | 30 mApp->onAppCmd = handle_cmd; |
| 31 mApp->onInputEvent = handle_input; | 31 mApp->onInputEvent = handle_input; |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 | 34 |
| 35 void Window_android::setTitle(const char* title) { | 35 void Window_android::setTitle(const char* title) { |
| 36 //todo | 36 //todo |
| 37 SkDebugf("Title: %s", title); | 37 SkDebugf("Title: %s", title); |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool Window_android::attach(BackEndType attachType, int msaaSampleCount) { | 40 bool Window_android::attach(BackEndType attachType, int msaaSampleCount, bool sr
gb) { |
| 41 if (kVulkan_BackendType != attachType) { | 41 if (kVulkan_BackendType != attachType) { |
| 42 return false; | 42 return false; |
| 43 } | 43 } |
| 44 | 44 |
| 45 mSampleCount = msaaSampleCount; | 45 mSampleCount = msaaSampleCount; |
| 46 mSRGB = srgb; |
| 46 | 47 |
| 47 // We delay the creation of fTestContext until Android informs us that | 48 // We delay the creation of fTestContext until Android informs us that |
| 48 // the native window is ready to use. | 49 // the native window is ready to use. |
| 49 return true; | 50 return true; |
| 50 } | 51 } |
| 51 | 52 |
| 52 void Window_android::initDisplay(ANativeWindow* window) { | 53 void Window_android::initDisplay(ANativeWindow* window) { |
| 53 SkASSERT(window); | 54 SkASSERT(window); |
| 54 ContextPlatformData_android platformData; | 55 ContextPlatformData_android platformData; |
| 55 platformData.fNativeWindow = window; | 56 platformData.fNativeWindow = window; |
| 56 fWindowContext = VulkanWindowContext::Create((void*)&platformData, mSampleCo
unt); | 57 fWindowContext = VulkanWindowContext::Create((void*)&platformData, mSampleCo
unt, mSRGB); |
| 57 } | 58 } |
| 58 | 59 |
| 59 static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) { | 60 static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) { |
| 60 if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) { | 61 if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) { |
| 61 SkDebugf("Failure writing android_app cmd: %s\n", strerror(errno)); | 62 SkDebugf("Failure writing android_app cmd: %s\n", strerror(errno)); |
| 62 } | 63 } |
| 63 } | 64 } |
| 64 | 65 |
| 65 void Window_android::inval() { | 66 void Window_android::inval() { |
| 66 android_app_write_cmd(mApp, APP_CMD_INVAL_WINDOW); | 67 android_app_write_cmd(mApp, APP_CMD_INVAL_WINDOW); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 Window::Key key = get_key(AKeyEvent_getKeyCode(event)); | 175 Window::Key key = get_key(AKeyEvent_getKeyCode(event)); |
| 175 Window::InputState state = get_action(AKeyEvent_getAction(event)); | 176 Window::InputState state = get_action(AKeyEvent_getAction(event)); |
| 176 int32_t mod = get_key_modifiers(event); | 177 int32_t mod = get_key_modifiers(event); |
| 177 window->onKey(key, state, mod); | 178 window->onKey(key, state, mod); |
| 178 return true; // eat all key events | 179 return true; // eat all key events |
| 179 } | 180 } |
| 180 return 0; | 181 return 0; |
| 181 } | 182 } |
| 182 | 183 |
| 183 } // namespace sk_app | 184 } // namespace sk_app |
| OLD | NEW |