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 GrRenderTarget; | 16 class SkSurface; |
| 17 class GrContext; |
17 | 18 |
18 namespace sk_app { | 19 namespace sk_app { |
19 | 20 |
20 class VulkanWindowContext : public WindowContext { | 21 class VulkanWindowContext : public WindowContext { |
21 public: | 22 public: |
22 ~VulkanWindowContext() override; | 23 ~VulkanWindowContext() override; |
23 | 24 |
24 // each platform will have to implement these in its CPP file | 25 // each platform will have to implement these in its CPP file |
25 static VkSurfaceKHR createVkSurface(VkInstance, void* platformData); | 26 static VkSurfaceKHR createVkSurface(VkInstance, void* platformData); |
26 static bool canPresent(VkInstance, VkPhysicalDevice, uint32_t queueFamilyInd
ex); | 27 static bool canPresent(VkInstance, VkPhysicalDevice, uint32_t queueFamilyInd
ex); |
27 | 28 |
28 static VulkanWindowContext* Create(void* platformData, const DisplayParams&
params) { | 29 static VulkanWindowContext* Create(void* platformData, const DisplayParams&
params) { |
29 VulkanWindowContext* ctx = new VulkanWindowContext(platformData, params)
; | 30 VulkanWindowContext* ctx = new VulkanWindowContext(platformData, params)
; |
30 if (!ctx->isValid()) { | 31 if (!ctx->isValid()) { |
31 delete ctx; | 32 delete ctx; |
32 return nullptr; | 33 return nullptr; |
33 } | 34 } |
34 return ctx; | 35 return ctx; |
35 } | 36 } |
36 | 37 |
37 sk_sp<SkSurface> getBackbufferSurface() override; | 38 SkSurface* getBackbufferSurface() override; |
38 void swapBuffers() override; | 39 void swapBuffers() override; |
39 | 40 |
| 41 bool makeCurrent() override { return true; } |
| 42 |
40 bool isValid() override { return SkToBool(fBackendContext.get()); } | 43 bool isValid() override { return SkToBool(fBackendContext.get()); } |
41 | 44 |
42 void resize(uint32_t w, uint32_t h) override { | 45 void resize(uint32_t w, uint32_t h) override { |
43 this->createSwapchain(w, h, fDisplayParams); | 46 this->createSwapchain(w, h, fDisplayParams); |
44 } | 47 } |
45 | 48 |
| 49 const DisplayParams& getDisplayParams() override { return fDisplayParams; } |
46 void setDisplayParams(const DisplayParams& params) override { | 50 void setDisplayParams(const DisplayParams& params) override { |
47 this->createSwapchain(fWidth, fHeight, params); | 51 this->createSwapchain(fWidth, fHeight, params); |
48 } | 52 } |
49 | 53 |
50 GrBackendContext getBackendContext() override { | 54 GrBackendContext getBackendContext() override { |
51 return (GrBackendContext) fBackendContext.get(); | 55 return (GrBackendContext) fBackendContext.get(); |
52 } | 56 } |
53 | 57 |
54 private: | 58 private: |
55 VulkanWindowContext(void*, const DisplayParams&); | 59 VulkanWindowContext(void*, const DisplayParams&); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 VkPtr<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR> fGetPhysicalDeviceSurfaceFor
matsKHR; | 92 VkPtr<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR> fGetPhysicalDeviceSurfaceFor
matsKHR; |
89 VkPtr<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR> fGetPhysicalDeviceSurfa
cePresentModesKHR; | 93 VkPtr<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR> fGetPhysicalDeviceSurfa
cePresentModesKHR; |
90 | 94 |
91 VkPtr<PFN_vkCreateSwapchainKHR> fCreateSwapchainKHR; | 95 VkPtr<PFN_vkCreateSwapchainKHR> fCreateSwapchainKHR; |
92 VkPtr<PFN_vkDestroySwapchainKHR> fDestroySwapchainKHR; | 96 VkPtr<PFN_vkDestroySwapchainKHR> fDestroySwapchainKHR; |
93 VkPtr<PFN_vkGetSwapchainImagesKHR> fGetSwapchainImagesKHR; | 97 VkPtr<PFN_vkGetSwapchainImagesKHR> fGetSwapchainImagesKHR; |
94 VkPtr<PFN_vkAcquireNextImageKHR> fAcquireNextImageKHR; | 98 VkPtr<PFN_vkAcquireNextImageKHR> fAcquireNextImageKHR; |
95 VkPtr<PFN_vkQueuePresentKHR> fQueuePresentKHR; | 99 VkPtr<PFN_vkQueuePresentKHR> fQueuePresentKHR; |
96 VkPtr<PFN_vkCreateSharedSwapchainsKHR> fCreateSharedSwapchainsKHR; | 100 VkPtr<PFN_vkCreateSharedSwapchainsKHR> fCreateSharedSwapchainsKHR; |
97 | 101 |
| 102 GrContext* fContext; |
98 VkSurfaceKHR fSurface; | 103 VkSurfaceKHR fSurface; |
99 VkSwapchainKHR fSwapchain; | 104 VkSwapchainKHR fSwapchain; |
100 uint32_t fPresentQueueIndex; | 105 uint32_t fPresentQueueIndex; |
101 VkQueue fPresentQueue; | 106 VkQueue fPresentQueue; |
102 int fWidth; | 107 int fWidth; |
103 int fHeight; | 108 int fHeight; |
| 109 DisplayParams fDisplayParams; |
| 110 GrPixelConfig fPixelConfig; |
104 | 111 |
105 uint32_t fImageCount; | 112 uint32_t fImageCount; |
106 VkImage* fImages; // images in the swapchain | 113 VkImage* fImages; // images in the swapchain |
107 VkImageLayout* fImageLayouts; // layouts of these images when not
color attachment | 114 VkImageLayout* fImageLayouts; // layouts of these images when not color
attachment |
108 sk_sp<GrRenderTarget>* fRenderTargets; // wrapped rendertargets for those i
mages | 115 sk_sp<SkSurface>* fSurfaces; // wrapped surface for those images |
109 sk_sp<SkSurface>* fSurfaces; // surfaces client renders to (may n
ot be based on rts) | 116 VkCommandPool fCommandPool; |
110 VkCommandPool fCommandPool; | 117 BackbufferInfo* fBackbuffers; |
111 BackbufferInfo* fBackbuffers; | 118 uint32_t fCurrentBackbufferIndex; |
112 uint32_t fCurrentBackbufferIndex; | |
113 }; | 119 }; |
114 | 120 |
115 } // namespace sk_app | 121 } // namespace sk_app |
116 | 122 |
117 #endif // SK_VULKAN | 123 #endif // SK_VULKAN |
118 | 124 |
119 #endif | 125 #endif |
OLD | NEW |