Chromium Code Reviews| Index: tools/viewer/sk_app/android/Window_android.cpp |
| diff --git a/tools/viewer/sk_app/android/Window_android.cpp b/tools/viewer/sk_app/android/Window_android.cpp |
| index 4f33870c1ae225e122215e579b0295d0fa4493ec..1c46d98178ad5808e22a7893053363b259d5f276 100644 |
| --- a/tools/viewer/sk_app/android/Window_android.cpp |
| +++ b/tools/viewer/sk_app/android/Window_android.cpp |
| @@ -6,8 +6,8 @@ |
| */ |
| #include "Window_android.h" |
| - |
| -#include "VulkanWindowContext_android.h" |
| +#include "../GLWindowContext.h" |
| +#include "../VulkanWindowContext.h" |
| namespace sk_app { |
| @@ -46,26 +46,42 @@ void Window_android::setUIState(const Json::Value& state) { |
| } |
| bool Window_android::attach(BackendType attachType, const DisplayParams& params) { |
| - if (kVulkan_BackendType != attachType) { |
| + 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.
|
| return false; |
| } |
| + fBackendType = attachType; |
| fDisplayParams = params; |
| - // We delay the creation of fTestContext until Android informs us that |
| + if (fNativeWindow) { |
| + 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.
|
| + } |
| + // If fNativeWindow is not set, |
| + // 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
|
| // the native window is ready to use. |
| return true; |
| } |
| void Window_android::initDisplay(ANativeWindow* window) { |
| SkASSERT(window); |
| + fNativeWindow = window; |
| ContextPlatformData_android platformData; |
| platformData.fNativeWindow = window; |
| - fWindowContext = VulkanWindowContext::Create((void*)&platformData, fDisplayParams); |
| + switch (fBackendType) { |
| + case kNativeGL_BackendType: |
| + fWindowContext = GLWindowContext::Create((void*)&platformData, fDisplayParams); |
| + break; |
| + |
| + case kVulkan_BackendType: |
| + 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
|
| + fWindowContext = VulkanWindowContext::Create((void*)&platformData, fDisplayParams); |
| + break; |
| + } |
| } |
| void Window_android::onDisplayDestroyed() { |
| detach(); |
| + fNativeWindow = nullptr; |
| } |
| void Window_android::onInval() { |