OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2016 Google Inc. | 3 * Copyright 2016 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #ifndef VulkanWindowContext_DEFINED | 8 #ifndef VulkanWindowContext_DEFINED |
9 #define VulkanWindowContext_DEFINED | 9 #define VulkanWindowContext_DEFINED |
10 | 10 |
11 #ifdef SK_VULKAN | 11 #ifdef SK_VULKAN |
12 | 12 |
13 #include "vk/GrVkBackendContext.h" | 13 #include "vk/GrVkBackendContext.h" |
14 #include "WindowContext.h" | 14 #include "WindowContext.h" |
15 | 15 |
16 class SkSurface; | |
17 class GrContext; | |
18 | |
19 namespace sk_app { | 16 namespace sk_app { |
20 | 17 |
21 class VulkanWindowContext : public WindowContext { | 18 class VulkanWindowContext : public WindowContext { |
22 public: | 19 public: |
23 ~VulkanWindowContext() override; | 20 ~VulkanWindowContext() override; |
24 | 21 |
25 // each platform will have to implement these in its CPP file | 22 // each platform will have to implement these in its CPP file |
26 static VkSurfaceKHR createVkSurface(VkInstance, void* platformData); | 23 static VkSurfaceKHR createVkSurface(VkInstance, void* platformData); |
27 static bool canPresent(VkInstance, VkPhysicalDevice, uint32_t queueFamilyInd
ex); | 24 static bool canPresent(VkInstance, VkPhysicalDevice, uint32_t queueFamilyInd
ex); |
28 | 25 |
29 static VulkanWindowContext* Create(void* platformData, const DisplayParams&
params) { | 26 static VulkanWindowContext* Create(void* platformData, const DisplayParams&
params) { |
30 VulkanWindowContext* ctx = new VulkanWindowContext(platformData, params)
; | 27 VulkanWindowContext* ctx = new VulkanWindowContext(platformData, params)
; |
31 if (!ctx->isValid()) { | 28 if (!ctx->isValid()) { |
32 delete ctx; | 29 delete ctx; |
33 return nullptr; | 30 return nullptr; |
34 } | 31 } |
35 return ctx; | 32 return ctx; |
36 } | 33 } |
37 | 34 |
38 SkSurface* getBackbufferSurface() override; | 35 sk_sp<SkSurface> getBackbufferSurface() override; |
39 void swapBuffers() override; | 36 void swapBuffers() override; |
40 | 37 |
41 bool makeCurrent() override { return true; } | |
42 | |
43 bool isValid() override { return SkToBool(fBackendContext.get()); } | 38 bool isValid() override { return SkToBool(fBackendContext.get()); } |
44 | 39 |
45 void resize(uint32_t w, uint32_t h) override { | 40 void resize(uint32_t w, uint32_t h) override { |
46 this->createSwapchain(w, h, fDisplayParams); | 41 this->createSwapchain(w, h, fDisplayParams); |
47 } | 42 } |
48 | 43 |
49 const DisplayParams& getDisplayParams() override { return fDisplayParams; } | 44 const DisplayParams& getDisplayParams() override { return fDisplayParams; } |
50 void setDisplayParams(const DisplayParams& params) override { | 45 void setDisplayParams(const DisplayParams& params) override { |
51 this->createSwapchain(fWidth, fHeight, params); | 46 this->createSwapchain(fWidth, fHeight, params); |
52 } | 47 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 VkPtr<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR> fGetPhysicalDeviceSurfaceFor
matsKHR; | 87 VkPtr<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR> fGetPhysicalDeviceSurfaceFor
matsKHR; |
93 VkPtr<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR> fGetPhysicalDeviceSurfa
cePresentModesKHR; | 88 VkPtr<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR> fGetPhysicalDeviceSurfa
cePresentModesKHR; |
94 | 89 |
95 VkPtr<PFN_vkCreateSwapchainKHR> fCreateSwapchainKHR; | 90 VkPtr<PFN_vkCreateSwapchainKHR> fCreateSwapchainKHR; |
96 VkPtr<PFN_vkDestroySwapchainKHR> fDestroySwapchainKHR; | 91 VkPtr<PFN_vkDestroySwapchainKHR> fDestroySwapchainKHR; |
97 VkPtr<PFN_vkGetSwapchainImagesKHR> fGetSwapchainImagesKHR; | 92 VkPtr<PFN_vkGetSwapchainImagesKHR> fGetSwapchainImagesKHR; |
98 VkPtr<PFN_vkAcquireNextImageKHR> fAcquireNextImageKHR; | 93 VkPtr<PFN_vkAcquireNextImageKHR> fAcquireNextImageKHR; |
99 VkPtr<PFN_vkQueuePresentKHR> fQueuePresentKHR; | 94 VkPtr<PFN_vkQueuePresentKHR> fQueuePresentKHR; |
100 VkPtr<PFN_vkCreateSharedSwapchainsKHR> fCreateSharedSwapchainsKHR; | 95 VkPtr<PFN_vkCreateSharedSwapchainsKHR> fCreateSharedSwapchainsKHR; |
101 | 96 |
102 GrContext* fContext; | |
103 VkSurfaceKHR fSurface; | 97 VkSurfaceKHR fSurface; |
104 VkSwapchainKHR fSwapchain; | 98 VkSwapchainKHR fSwapchain; |
105 uint32_t fPresentQueueIndex; | 99 uint32_t fPresentQueueIndex; |
106 VkQueue fPresentQueue; | 100 VkQueue fPresentQueue; |
107 int fWidth; | 101 int fWidth; |
108 int fHeight; | 102 int fHeight; |
109 DisplayParams fDisplayParams; | |
110 GrPixelConfig fPixelConfig; | |
111 | 103 |
112 uint32_t fImageCount; | 104 uint32_t fImageCount; |
113 VkImage* fImages; // images in the swapchain | 105 VkImage* fImages; // images in the swapchain |
114 VkImageLayout* fImageLayouts; // layouts of these images when not color
attachment | 106 VkImageLayout* fImageLayouts; // layouts of these images when not color
attachment |
115 sk_sp<SkSurface>* fSurfaces; // wrapped surface for those images | 107 sk_sp<SkSurface>* fSurfaces; // wrapped surface for those images |
116 VkCommandPool fCommandPool; | 108 VkCommandPool fCommandPool; |
117 BackbufferInfo* fBackbuffers; | 109 BackbufferInfo* fBackbuffers; |
118 uint32_t fCurrentBackbufferIndex; | 110 uint32_t fCurrentBackbufferIndex; |
119 }; | 111 }; |
120 | 112 |
121 } // namespace sk_app | 113 } // namespace sk_app |
122 | 114 |
123 #endif // SK_VULKAN | 115 #endif // SK_VULKAN |
124 | 116 |
125 #endif | 117 #endif |
OLD | NEW |