Chromium Code Reviews| 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 #include "../GLWindowContext.h" |
| 10 #include "VulkanWindowContext_android.h" | 10 #include "../VulkanWindowContext.h" |
| 11 | 11 |
| 12 namespace sk_app { | 12 namespace sk_app { |
| 13 | 13 |
| 14 Window* Window::CreateNativeWindow(void* platformData) { | 14 Window* Window::CreateNativeWindow(void* platformData) { |
| 15 Window_android* window = new Window_android(); | 15 Window_android* window = new Window_android(); |
| 16 if (!window->init((SkiaAndroidApp*)platformData)) { | 16 if (!window->init((SkiaAndroidApp*)platformData)) { |
| 17 delete window; | 17 delete window; |
| 18 return nullptr; | 18 return nullptr; |
| 19 } | 19 } |
| 20 return window; | 20 return window; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 39 | 39 |
| 40 void Window_android::setTitle(const char* title) { | 40 void Window_android::setTitle(const char* title) { |
| 41 fSkiaAndroidApp->setTitle(title); | 41 fSkiaAndroidApp->setTitle(title); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void Window_android::setUIState(const Json::Value& state) { | 44 void Window_android::setUIState(const Json::Value& state) { |
| 45 fSkiaAndroidApp->setUIState(state); | 45 fSkiaAndroidApp->setUIState(state); |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool Window_android::attach(BackendType attachType, const DisplayParams& params) { | 48 bool Window_android::attach(BackendType attachType, const DisplayParams& params) { |
| 49 if (kVulkan_BackendType != attachType) { | 49 if (kVulkan_BackendType != attachType && kNativeGL_BackendType != attachType ) { |
|
jvanverth1
2016/06/02 17:17:36
You can probably remove this block -- the conditio
liyuqian
2016/06/02 18:47:13
Done.
| |
| 50 return false; | 50 return false; |
| 51 } | 51 } |
| 52 | 52 |
| 53 fBackendType = attachType; | |
| 53 fDisplayParams = params; | 54 fDisplayParams = params; |
| 54 | 55 |
| 55 // We delay the creation of fTestContext until Android informs us that | 56 if (fNativeWindow) { |
| 57 initDisplay(fNativeWindow); | |
|
scroggo
2016/06/02 18:25:17
nit: Skia code calls member functions using "this"
liyuqian
2016/06/02 18:47:13
Done.
| |
| 58 } | |
| 59 // If fNativeWindow is not set, | |
| 60 // we delay the creation of fWindowContext until Android informs us that | |
|
scroggo
2016/06/02 18:25:16
When/where does that happen? Should we return fals
liyuqian
2016/06/02 18:47:13
It happens in initDisplay, which is initiated by k
| |
| 56 // the native window is ready to use. | 61 // the native window is ready to use. |
| 57 return true; | 62 return true; |
| 58 } | 63 } |
| 59 | 64 |
| 60 void Window_android::initDisplay(ANativeWindow* window) { | 65 void Window_android::initDisplay(ANativeWindow* window) { |
| 61 SkASSERT(window); | 66 SkASSERT(window); |
| 67 fNativeWindow = window; | |
| 62 ContextPlatformData_android platformData; | 68 ContextPlatformData_android platformData; |
| 63 platformData.fNativeWindow = window; | 69 platformData.fNativeWindow = window; |
| 64 fWindowContext = VulkanWindowContext::Create((void*)&platformData, fDisplayP arams); | 70 switch (fBackendType) { |
| 71 case kNativeGL_BackendType: | |
| 72 fWindowContext = GLWindowContext::Create((void*)&platformData, fDisp layParams); | |
| 73 break; | |
| 74 | |
| 75 case kVulkan_BackendType: | |
| 76 default: | |
|
scroggo
2016/06/02 18:25:16
Why does default create a vulkan backend?
liyuqian
2016/06/02 18:47:13
Because that's the first backend in Android viewer
scroggo
2016/06/02 18:58:37
It looks like there are only two enum values. Can
| |
| 77 fWindowContext = VulkanWindowContext::Create((void*)&platformData, f DisplayParams); | |
| 78 break; | |
| 79 } | |
| 65 } | 80 } |
| 66 | 81 |
| 67 void Window_android::onDisplayDestroyed() { | 82 void Window_android::onDisplayDestroyed() { |
| 68 detach(); | 83 detach(); |
| 84 fNativeWindow = nullptr; | |
| 69 } | 85 } |
| 70 | 86 |
| 71 void Window_android::onInval() { | 87 void Window_android::onInval() { |
| 72 fSkiaAndroidApp->postMessage(Message(kContentInvalidated)); | 88 fSkiaAndroidApp->postMessage(Message(kContentInvalidated)); |
| 73 } | 89 } |
| 74 | 90 |
| 75 void Window_android::paintIfNeeded() { | 91 void Window_android::paintIfNeeded() { |
| 76 if (fWindowContext) { // Check if initDisplay has already been called | 92 if (fWindowContext) { // Check if initDisplay has already been called |
| 77 onPaint(); | 93 onPaint(); |
| 78 } else { | 94 } else { |
| 79 markInvalProcessed(); | 95 markInvalProcessed(); |
| 80 } | 96 } |
| 81 } | 97 } |
| 82 | 98 |
| 83 } // namespace sk_app | 99 } // namespace sk_app |
| OLD | NEW |