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 #include "../GLWindowContext.h" | 9 #include "../GLWindowContext.h" |
| 10 #ifdef SK_VULKAN |
10 #include "../VulkanWindowContext.h" | 11 #include "../VulkanWindowContext.h" |
| 12 #endif |
11 #include "../RasterWindowContext.h" | 13 #include "../RasterWindowContext.h" |
12 | 14 |
13 namespace sk_app { | 15 namespace sk_app { |
14 | 16 |
15 Window* Window::CreateNativeWindow(void* platformData) { | 17 Window* Window::CreateNativeWindow(void* platformData) { |
16 Window_android* window = new Window_android(); | 18 Window_android* window = new Window_android(); |
17 if (!window->init((SkiaAndroidApp*)platformData)) { | 19 if (!window->init((SkiaAndroidApp*)platformData)) { |
18 delete window; | 20 delete window; |
19 return nullptr; | 21 return nullptr; |
20 } | 22 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // The creation will be done in initDisplay, which is initiated by kSurfaceC
reated event. | 57 // The creation will be done in initDisplay, which is initiated by kSurfaceC
reated event. |
56 return true; | 58 return true; |
57 } | 59 } |
58 | 60 |
59 void Window_android::initDisplay(ANativeWindow* window) { | 61 void Window_android::initDisplay(ANativeWindow* window) { |
60 SkASSERT(window); | 62 SkASSERT(window); |
61 ContextPlatformData_android platformData; | 63 ContextPlatformData_android platformData; |
62 platformData.fNativeWindow = window; | 64 platformData.fNativeWindow = window; |
63 switch (fBackendType) { | 65 switch (fBackendType) { |
64 case kNativeGL_BackendType: | 66 case kNativeGL_BackendType: |
| 67 default: |
65 fWindowContext = GLWindowContext::Create((void*)&platformData, fDisp
layParams); | 68 fWindowContext = GLWindowContext::Create((void*)&platformData, fDisp
layParams); |
66 break; | 69 break; |
67 case kRaster_BackendType: | 70 case kRaster_BackendType: |
68 fWindowContext = RasterWindowContext::Create((void*)&platformData, f
DisplayParams); | 71 fWindowContext = RasterWindowContext::Create((void*)&platformData, f
DisplayParams); |
69 break; | 72 break; |
| 73 #ifdef SK_VULKAN |
70 case kVulkan_BackendType: | 74 case kVulkan_BackendType: |
71 default: | |
72 fWindowContext = VulkanWindowContext::Create((void*)&platformData, f
DisplayParams); | 75 fWindowContext = VulkanWindowContext::Create((void*)&platformData, f
DisplayParams); |
73 break; | 76 break; |
| 77 #endif |
74 } | 78 } |
75 } | 79 } |
76 | 80 |
77 void Window_android::onDisplayDestroyed() { | 81 void Window_android::onDisplayDestroyed() { |
78 detach(); | 82 detach(); |
79 } | 83 } |
80 | 84 |
81 void Window_android::onInval() { | 85 void Window_android::onInval() { |
82 fSkiaAndroidApp->postMessage(Message(kContentInvalidated)); | 86 fSkiaAndroidApp->postMessage(Message(kContentInvalidated)); |
83 } | 87 } |
84 | 88 |
85 void Window_android::paintIfNeeded() { | 89 void Window_android::paintIfNeeded() { |
86 if (fWindowContext) { // Check if initDisplay has already been called | 90 if (fWindowContext) { // Check if initDisplay has already been called |
87 onPaint(); | 91 onPaint(); |
88 } else { | 92 } else { |
89 markInvalProcessed(); | 93 markInvalProcessed(); |
90 } | 94 } |
91 } | 95 } |
92 | 96 |
93 } // namespace sk_app | 97 } // namespace sk_app |
OLD | NEW |