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