Flutter Engine
The Flutter Engine
Namespaces | Classes | Functions
skwindow Namespace Reference

Namespaces

namespace  internal
 

Classes

struct  DisplayParams
 
struct  IOSWindowInfo
 
struct  MacWindowInfo
 
class  WindowContext
 
struct  XlibWindowInfo
 

Functions

std::unique_ptr< WindowContextMakeGLForAndroid (ANativeWindow *window, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeGraphiteVulkanForAndroid (ANativeWindow *window, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeRasterForAndroid (ANativeWindow *window, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeVulkanForAndroid (ANativeWindow *window, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeGLForIOS (const IOSWindowInfo &info, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeGraphiteMetalForIOS (const IOSWindowInfo &info, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeMetalForIOS (const IOSWindowInfo &info, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeRasterForIOS (const IOSWindowInfo &info, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeANGLEForMac (const MacWindowInfo &info, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeGLForMac (const MacWindowInfo &info, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeGraphiteDawnMetalForMac (const MacWindowInfo &info, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeGraphiteMetalForMac (const MacWindowInfo &info, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeMetalForMac (const MacWindowInfo &info, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeRasterForMac (const MacWindowInfo &info, const DisplayParams &params)
 
static CGFloat GetBackingScaleFactor (NSView *view)
 
std::unique_ptr< WindowContextMakeGLForXlib (const XlibWindowInfo &winInfo, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeGraphiteDawnVulkanForXlib (const XlibWindowInfo &info, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeGraphiteVulkanForXlib (const XlibWindowInfo &info, const DisplayParams &displayParams)
 
std::unique_ptr< WindowContextMakeRasterForXlib (const XlibWindowInfo &info, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeVulkanForXlib (const XlibWindowInfo &info, const DisplayParams &displayParams)
 
std::unique_ptr< WindowContextMakeANGLEForWin (HWND wnd, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeD3D12ForWin (HWND hwnd, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeGLForWin (HWND wnd, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeGraphiteDawnD3D12ForWin (HWND hwnd, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeGraphiteVulkanForWin (HWND hwnd, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeRasterForWin (HWND wnd, const DisplayParams &params)
 
std::unique_ptr< WindowContextMakeVulkanForWin (HWND hwnd, const DisplayParams &params)
 

Function Documentation

◆ GetBackingScaleFactor()

static CGFloat skwindow::GetBackingScaleFactor ( NSView *  view)
inlinestatic

Definition at line 22 of file WindowContextFactory_mac.h.

22 {
23 #ifdef SK_BUILD_FOR_IOS
24 UIScreen* screen = view.window.screen ?: [UIScreen mainScreen];
25 return screen.nativeScale;
26 #else
27 NSScreen* screen = view.window.screen ?: [NSScreen mainScreen];
28 return screen.backingScaleFactor;
29 #endif
30}

◆ MakeANGLEForMac()

std::unique_ptr< WindowContext > skwindow::MakeANGLEForMac ( const MacWindowInfo info,
const DisplayParams params 
)

Definition at line 68 of file ANGLEWindowContext_mac.mm.

69 {
70 std::unique_ptr<WindowContext> ctx(new ANGLEWindowContext_mac(info, params));
71 if (!ctx->isValid()) {
72 return nullptr;
73 }
74 return ctx;
75}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
const EmbeddedViewParams * params

◆ MakeANGLEForWin()

std::unique_ptr< WindowContext > skwindow::MakeANGLEForWin ( HWND  wnd,
const DisplayParams params 
)

Definition at line 65 of file ANGLEWindowContext_win.cpp.

65 {
66 std::unique_ptr<WindowContext> ctx(new ANGLEWindowContext_win(wnd, params));
67 if (!ctx->isValid()) {
68 return nullptr;
69 }
70 return ctx;
71}

◆ MakeD3D12ForWin()

std::unique_ptr< WindowContext > skwindow::MakeD3D12ForWin ( HWND  hwnd,
const DisplayParams params 
)

Definition at line 259 of file D3D12WindowContext_win.cpp.

259 {
260 std::unique_ptr<WindowContext> ctx(new D3D12WindowContext(hwnd, params));
261 if (!ctx->isValid()) {
262 return nullptr;
263 }
264 return ctx;
265}

◆ MakeGLForAndroid()

std::unique_ptr< WindowContext > skwindow::MakeGLForAndroid ( ANativeWindow window,
const DisplayParams params 
)

Definition at line 165 of file GLWindowContext_android.cpp.

166 {
167 std::unique_ptr<WindowContext> ctx(new GLWindowContext_android(window, params));
168 if (!ctx->isValid()) {
169 return nullptr;
170 }
171 return ctx;
172}
GLFWwindow * window
Definition: main.cc:45

◆ MakeGLForIOS()

std::unique_ptr< WindowContext > skwindow::MakeGLForIOS ( const IOSWindowInfo info,
const DisplayParams params 
)

Definition at line 155 of file GLWindowContext_ios.mm.

156 {
157 std::unique_ptr<WindowContext> ctx(new GLWindowContext_ios(info, params));
158 if (!ctx->isValid()) {
159 return nullptr;
160 }
161 return ctx;
162}

◆ MakeGLForMac()

std::unique_ptr< WindowContext > skwindow::MakeGLForMac ( const MacWindowInfo info,
const DisplayParams params 
)

Definition at line 136 of file GLWindowContext_mac.mm.

137 {
138 std::unique_ptr<WindowContext> ctx(new GLWindowContext_mac(info, params));
139 if (!ctx->isValid()) {
140 return nullptr;
141 }
142 return ctx;
143}

◆ MakeGLForWin()

std::unique_ptr< WindowContext > skwindow::MakeGLForWin ( HWND  wnd,
const DisplayParams params 
)

Definition at line 144 of file GLWindowContext_win.cpp.

144 {
145 std::unique_ptr<WindowContext> ctx(new GLWindowContext_win(wnd, params));
146 if (!ctx->isValid()) {
147 return nullptr;
148 }
149 return ctx;
150}

◆ MakeGLForXlib()

std::unique_ptr< WindowContext > skwindow::MakeGLForXlib ( const XlibWindowInfo winInfo,
const DisplayParams params 
)

Definition at line 191 of file GLWindowContext_unix.cpp.

192 {
193 std::unique_ptr<WindowContext> ctx(new GLWindowContext_xlib(winInfo, params));
194 if (!ctx->isValid()) {
195 return nullptr;
196 }
197 return ctx;
198}

◆ MakeGraphiteDawnD3D12ForWin()

std::unique_ptr< WindowContext > skwindow::MakeGraphiteDawnD3D12ForWin ( HWND  hwnd,
const DisplayParams params 
)

Definition at line 80 of file GraphiteDawnD3D12WindowContext_win.cpp.

80 {
81 std::unique_ptr<WindowContext> ctx(new GraphiteDawnD3D12WindowContext_win(hwnd, params));
82 if (!ctx->isValid()) {
83 return nullptr;
84 }
85 return ctx;
86}

◆ MakeGraphiteDawnMetalForMac()

std::unique_ptr< WindowContext > skwindow::MakeGraphiteDawnMetalForMac ( const MacWindowInfo info,
const DisplayParams params 
)

Definition at line 123 of file GraphiteDawnMetalWindowContext_mac.mm.

124 {
125 std::unique_ptr<WindowContext> ctx(new GraphiteDawnMetalWindowContext_mac(info, params));
126 if (!ctx->isValid()) {
127 return nullptr;
128 }
129 return ctx;
130}

◆ MakeGraphiteDawnVulkanForXlib()

std::unique_ptr< WindowContext > skwindow::MakeGraphiteDawnVulkanForXlib ( const XlibWindowInfo info,
const DisplayParams params 
)

Definition at line 89 of file GraphiteDawnVulkanWindowContext_unix.cpp.

90 {
91 std::unique_ptr<WindowContext> ctx(new GraphiteDawnVulkanWindowContext_unix(info, params));
92 if (!ctx->isValid()) {
93 return nullptr;
94 }
95 return ctx;
96}

◆ MakeGraphiteMetalForIOS()

std::unique_ptr< WindowContext > skwindow::MakeGraphiteMetalForIOS ( const IOSWindowInfo info,
const DisplayParams params 
)

Definition at line 99 of file GraphiteMetalWindowContext_ios.mm.

100 {
101 std::unique_ptr<WindowContext> ctx(new GraphiteMetalWindowContext_ios(info, params));
102 if (!ctx->isValid()) {
103 return nullptr;
104 }
105 return ctx;
106}

◆ MakeGraphiteMetalForMac()

std::unique_ptr< WindowContext > skwindow::MakeGraphiteMetalForMac ( const MacWindowInfo info,
const DisplayParams params 
)

Definition at line 94 of file GraphiteMetalWindowContext_mac.mm.

95 {
96 std::unique_ptr<WindowContext> ctx(new GraphiteMetalWindowContext_mac(info, params));
97 if (!ctx->isValid()) {
98 return nullptr;
99 }
100 return ctx;
101}

◆ MakeGraphiteVulkanForAndroid()

std::unique_ptr< WindowContext > skwindow::MakeGraphiteVulkanForAndroid ( ANativeWindow window,
const DisplayParams params 
)

Definition at line 16 of file GraphiteVulkanWindowContext_android.cpp.

17 {
19 if (!sk_gpu_test::LoadVkLibraryAndGetProcAddrFuncs(&instProc)) {
20 return nullptr;
21 }
22
23 auto createVkSurface = [window, instProc] (VkInstance instance) -> VkSurfaceKHR {
24 PFN_vkCreateAndroidSurfaceKHR createAndroidSurfaceKHR =
25 (PFN_vkCreateAndroidSurfaceKHR) instProc(instance, "vkCreateAndroidSurfaceKHR");
26
27 if (!window) {
28 return VK_NULL_HANDLE;
29 }
30 VkSurfaceKHR surface;
31
32 VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo;
33 memset(&surfaceCreateInfo, 0, sizeof(VkAndroidSurfaceCreateInfoKHR));
35 surfaceCreateInfo.pNext = nullptr;
36 surfaceCreateInfo.flags = 0;
37 surfaceCreateInfo.window = window;
38
39 VkResult res = createAndroidSurfaceKHR(instance, &surfaceCreateInfo,
40 nullptr, &surface);
41 return (VK_SUCCESS == res) ? surface : VK_NULL_HANDLE;
42 };
43
44 auto canPresent = [](VkInstance, VkPhysicalDevice, uint32_t) { return true; };
45
46 std::unique_ptr<WindowContext> ctx(
47 new internal::GraphiteVulkanWindowContext(params,
48 createVkSurface,
49 canPresent,
50 instProc));
51 if (!ctx->isValid()) {
52 return nullptr;
53 }
54
55 return ctx;
56}
VkInstance instance
Definition: main.cc:48
VkSurfaceKHR surface
Definition: main.cc:49
struct ANativeWindow * window
VkAndroidSurfaceCreateFlagsKHR flags
VkResult(VKAPI_PTR * PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
VkResult
Definition: vulkan_core.h:140
@ VK_SUCCESS
Definition: vulkan_core.h:141
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46
PFN_vkVoidFunction(VKAPI_PTR * PFN_vkGetInstanceProcAddr)(VkInstance instance, const char *pName)
Definition: vulkan_core.h:3989
@ VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR
Definition: vulkan_core.h:432

◆ MakeGraphiteVulkanForWin()

std::unique_ptr< WindowContext > skwindow::MakeGraphiteVulkanForWin ( HWND  hwnd,
const DisplayParams params 
)

Definition at line 19 of file GraphiteVulkanWindowContext_win.cpp.

19 {
21 if (!sk_gpu_test::LoadVkLibraryAndGetProcAddrFuncs(&instProc)) {
22 return nullptr;
23 }
24
25 auto createVkSurface = [hwnd, instProc] (VkInstance instance) -> VkSurfaceKHR {
26 static PFN_vkCreateWin32SurfaceKHR createWin32SurfaceKHR = nullptr;
27 if (!createWin32SurfaceKHR) {
28 createWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)
29 instProc(instance, "vkCreateWin32SurfaceKHR");
30 }
31 HINSTANCE hinstance = GetModuleHandle(0);
32 VkSurfaceKHR surface;
33
34 VkWin32SurfaceCreateInfoKHR surfaceCreateInfo;
35 memset(&surfaceCreateInfo, 0, sizeof(VkWin32SurfaceCreateInfoKHR));
37 surfaceCreateInfo.pNext = nullptr;
38 surfaceCreateInfo.flags = 0;
39 surfaceCreateInfo.hinstance = hinstance;
40 surfaceCreateInfo.hwnd = hwnd;
41
42 VkResult res = createWin32SurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface);
43 if (VK_SUCCESS != res) {
44 return VK_NULL_HANDLE;
45 }
46
47 return surface;
48 };
49
50 auto canPresent = [instProc] (VkInstance instance, VkPhysicalDevice physDev,
51 uint32_t queueFamilyIndex) {
53 getPhysicalDeviceWin32PresentationSupportKHR = nullptr;
54 if (!getPhysicalDeviceWin32PresentationSupportKHR) {
55 getPhysicalDeviceWin32PresentationSupportKHR =
57 instProc(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
58 }
59
60 VkBool32 check = getPhysicalDeviceWin32PresentationSupportKHR(physDev, queueFamilyIndex);
61 return (VK_FALSE != check);
62 };
63
64 std::unique_ptr<WindowContext> ctx(
65 new internal::GraphiteVulkanWindowContext(params, createVkSurface,
66 canPresent, instProc));
67 if (!ctx->isValid()) {
68 return nullptr;
69 }
70 return ctx;
71}
#define check(reporter, ref, unref, make, kill)
Definition: RefCntTest.cpp:85
VkWin32SurfaceCreateFlagsKHR flags
Definition: vulkan_win32.h:30
#define VK_FALSE
Definition: vulkan_core.h:125
uint32_t VkBool32
Definition: vulkan_core.h:94
@ VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR
Definition: vulkan_core.h:433
VkResult(VKAPI_PTR * PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
Definition: vulkan_win32.h:35
VkBool32(VKAPI_PTR * PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex)
Definition: vulkan_win32.h:36

◆ MakeGraphiteVulkanForXlib()

std::unique_ptr< WindowContext > skwindow::MakeGraphiteVulkanForXlib ( const XlibWindowInfo info,
const DisplayParams displayParams 
)

Definition at line 18 of file GraphiteVulkanWindowContext_unix.cpp.

19 {
21 if (!sk_gpu_test::LoadVkLibraryAndGetProcAddrFuncs(&instProc)) {
22 SkDebugf("Could not load vulkan library\n");
23 return nullptr;
24 }
25
26 auto createVkSurface = [&info, instProc](VkInstance instance) -> VkSurfaceKHR {
27 static PFN_vkCreateXcbSurfaceKHR createXcbSurfaceKHR = nullptr;
28 if (!createXcbSurfaceKHR) {
29 createXcbSurfaceKHR =
30 (PFN_vkCreateXcbSurfaceKHR) instProc(instance, "vkCreateXcbSurfaceKHR");
31 }
32
33 VkSurfaceKHR surface;
34
35 VkXcbSurfaceCreateInfoKHR surfaceCreateInfo;
36 memset(&surfaceCreateInfo, 0, sizeof(VkXcbSurfaceCreateInfoKHR));
38 surfaceCreateInfo.pNext = nullptr;
39 surfaceCreateInfo.flags = 0;
40 surfaceCreateInfo.connection = XGetXCBConnection(info.fDisplay);
41 surfaceCreateInfo.window = info.fWindow;
42
43 VkResult res = createXcbSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface);
44 if (res != VK_SUCCESS) {
45 return VK_NULL_HANDLE;
46 }
47
48 return surface;
49 };
50
51 auto canPresent = [&info, instProc](VkInstance instance, VkPhysicalDevice physDev,
52 uint32_t queueFamilyIndex) {
54 getPhysicalDeviceXcbPresentationSupportKHR = nullptr;
55 if (!getPhysicalDeviceXcbPresentationSupportKHR) {
56 getPhysicalDeviceXcbPresentationSupportKHR =
58 instProc(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
59 }
60
61 Display* display = info.fDisplay;
62 VisualID visualID = XVisualIDFromVisual(DefaultVisual(info.fDisplay,
63 DefaultScreen(info.fDisplay)));
64 VkBool32 check = getPhysicalDeviceXcbPresentationSupportKHR(physDev,
65 queueFamilyIndex,
66 XGetXCBConnection(display),
67 visualID);
68 return (check != VK_FALSE);
69 };
70 std::unique_ptr<WindowContext> ctx(
71 new internal::GraphiteVulkanWindowContext(displayParams,
72 createVkSurface,
73 canPresent,
74 instProc));
75 if (!ctx->isValid()) {
76 return nullptr;
77 }
78 return ctx;
79}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
VkStructureType sType
Definition: vulkan_xcb.h:28
VkXcbSurfaceCreateFlagsKHR flags
Definition: vulkan_xcb.h:30
xcb_connection_t * connection
Definition: vulkan_xcb.h:31
@ VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR
Definition: vulkan_core.h:430
VkResult(VKAPI_PTR * PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
Definition: vulkan_xcb.h:35
VkBool32(VKAPI_PTR * PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t *connection, xcb_visualid_t visual_id)
Definition: vulkan_xcb.h:36

◆ MakeMetalForIOS()

std::unique_ptr< WindowContext > skwindow::MakeMetalForIOS ( const IOSWindowInfo info,
const DisplayParams params 
)

Definition at line 98 of file MetalWindowContext_ios.mm.

99 {
100 std::unique_ptr<WindowContext> ctx(new MetalWindowContext_ios(info, params));
101 if (!ctx->isValid()) {
102 return nullptr;
103 }
104 return ctx;
105}

◆ MakeMetalForMac()

std::unique_ptr< WindowContext > skwindow::MakeMetalForMac ( const MacWindowInfo info,
const DisplayParams params 
)

Definition at line 93 of file MetalWindowContext_mac.mm.

94 {
95 std::unique_ptr<WindowContext> ctx(new MetalWindowContext_mac(info, params));
96 if (!ctx->isValid()) {
97 return nullptr;
98 }
99 return ctx;
100}

◆ MakeRasterForAndroid()

std::unique_ptr< WindowContext > skwindow::MakeRasterForAndroid ( ANativeWindow window,
const DisplayParams params 
)

Definition at line 95 of file RasterWindowContext_android.cpp.

96 {
97 std::unique_ptr<WindowContext> ctx(new RasterWindowContext_android(window, params));
98 if (!ctx->isValid()) {
99 return nullptr;
100 }
101 return ctx;
102}

◆ MakeRasterForIOS()

std::unique_ptr< WindowContext > skwindow::MakeRasterForIOS ( const IOSWindowInfo info,
const DisplayParams params 
)

Definition at line 188 of file RasterWindowContext_ios.mm.

189 {
190 std::unique_ptr<WindowContext> ctx(new RasterWindowContext_ios(info, params));
191 if (!ctx->isValid()) {
192 return nullptr;
193 }
194 return ctx;
195}

◆ MakeRasterForMac()

std::unique_ptr< WindowContext > skwindow::MakeRasterForMac ( const MacWindowInfo info,
const DisplayParams params 
)

Definition at line 180 of file RasterWindowContext_mac.mm.

181 {
182 std::unique_ptr<WindowContext> ctx(new RasterWindowContext_mac(info, params));
183 if (!ctx->isValid()) {
184 return nullptr;
185 }
186 return ctx;
187}

◆ MakeRasterForWin()

std::unique_ptr< WindowContext > skwindow::MakeRasterForWin ( HWND  wnd,
const DisplayParams params 
)

Definition at line 87 of file RasterWindowContext_win.cpp.

87 {
88 std::unique_ptr<WindowContext> ctx(new RasterWindowContext_win(wnd, params));
89 if (!ctx->isValid()) {
90 ctx = nullptr;
91 }
92 return ctx;
93}

◆ MakeRasterForXlib()

std::unique_ptr< WindowContext > skwindow::MakeRasterForXlib ( const XlibWindowInfo info,
const DisplayParams params 
)

Definition at line 90 of file RasterWindowContext_unix.cpp.

91 {
92 std::unique_ptr<WindowContext> ctx(new RasterWindowContext_xlib(
93 info.fDisplay, info.fWindow, info.fWidth, info.fHeight, params));
94 if (!ctx->isValid()) {
95 ctx = nullptr;
96 }
97 return ctx;
98}

◆ MakeVulkanForAndroid()

std::unique_ptr< WindowContext > skwindow::MakeVulkanForAndroid ( ANativeWindow window,
const DisplayParams params 
)

Definition at line 16 of file VulkanWindowContext_android.cpp.

17 {
19 if (!sk_gpu_test::LoadVkLibraryAndGetProcAddrFuncs(&instProc)) {
20 return nullptr;
21 }
22
23 auto createVkSurface = [window, instProc] (VkInstance instance) -> VkSurfaceKHR {
24 PFN_vkCreateAndroidSurfaceKHR createAndroidSurfaceKHR =
25 (PFN_vkCreateAndroidSurfaceKHR) instProc(instance, "vkCreateAndroidSurfaceKHR");
26
27 if (!window) {
28 return VK_NULL_HANDLE;
29 }
30 VkSurfaceKHR surface;
31
32 VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo;
33 memset(&surfaceCreateInfo, 0, sizeof(VkAndroidSurfaceCreateInfoKHR));
35 surfaceCreateInfo.pNext = nullptr;
36 surfaceCreateInfo.flags = 0;
37 surfaceCreateInfo.window = window;
38
39 VkResult res = createAndroidSurfaceKHR(instance, &surfaceCreateInfo,
40 nullptr, &surface);
41 return (VK_SUCCESS == res) ? surface : VK_NULL_HANDLE;
42 };
43
44 auto canPresent = [](VkInstance, VkPhysicalDevice, uint32_t) { return true; };
45
46 std::unique_ptr<WindowContext> ctx(
47 new internal::VulkanWindowContext(params, createVkSurface, canPresent, instProc));
48 if (!ctx->isValid()) {
49 return nullptr;
50 }
51 return ctx;
52}

◆ MakeVulkanForWin()

std::unique_ptr< WindowContext > skwindow::MakeVulkanForWin ( HWND  hwnd,
const DisplayParams params 
)

Definition at line 22 of file VulkanWindowContext_win.cpp.

22 {
24 if (!sk_gpu_test::LoadVkLibraryAndGetProcAddrFuncs(&instProc)) {
25 return nullptr;
26 }
27
28 auto createVkSurface = [hwnd, instProc] (VkInstance instance) -> VkSurfaceKHR {
29 static PFN_vkCreateWin32SurfaceKHR createWin32SurfaceKHR = nullptr;
30 if (!createWin32SurfaceKHR) {
31 createWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)
32 instProc(instance, "vkCreateWin32SurfaceKHR");
33 }
34 HINSTANCE hinstance = GetModuleHandle(0);
35 VkSurfaceKHR surface;
36
37 VkWin32SurfaceCreateInfoKHR surfaceCreateInfo;
38 memset(&surfaceCreateInfo, 0, sizeof(VkWin32SurfaceCreateInfoKHR));
40 surfaceCreateInfo.pNext = nullptr;
41 surfaceCreateInfo.flags = 0;
42 surfaceCreateInfo.hinstance = hinstance;
43 surfaceCreateInfo.hwnd = hwnd;
44
45 VkResult res = createWin32SurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface);
46 if (VK_SUCCESS != res) {
47 return VK_NULL_HANDLE;
48 }
49
50 return surface;
51 };
52
53 auto canPresent = [instProc] (VkInstance instance, VkPhysicalDevice physDev,
54 uint32_t queueFamilyIndex) {
56 getPhysicalDeviceWin32PresentationSupportKHR = nullptr;
57 if (!getPhysicalDeviceWin32PresentationSupportKHR) {
58 getPhysicalDeviceWin32PresentationSupportKHR =
60 instProc(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
61 }
62
63 VkBool32 check = getPhysicalDeviceWin32PresentationSupportKHR(physDev, queueFamilyIndex);
64 return (VK_FALSE != check);
65 };
66
67 std::unique_ptr<WindowContext> ctx(
68 new internal::VulkanWindowContext(params, createVkSurface, canPresent, instProc));
69 if (!ctx->isValid()) {
70 return nullptr;
71 }
72 return ctx;
73}

◆ MakeVulkanForXlib()

std::unique_ptr< WindowContext > skwindow::MakeVulkanForXlib ( const XlibWindowInfo info,
const DisplayParams displayParams 
)

Definition at line 19 of file VulkanWindowContext_unix.cpp.

20 {
22 if (!sk_gpu_test::LoadVkLibraryAndGetProcAddrFuncs(&instProc)) {
23 SkDebugf("Could not load vulkan library\n");
24 return nullptr;
25 }
26
27 auto createVkSurface = [&info, instProc](VkInstance instance) -> VkSurfaceKHR {
28 static PFN_vkCreateXcbSurfaceKHR createXcbSurfaceKHR = nullptr;
29 if (!createXcbSurfaceKHR) {
30 createXcbSurfaceKHR =
31 (PFN_vkCreateXcbSurfaceKHR) instProc(instance, "vkCreateXcbSurfaceKHR");
32 }
33
34 VkSurfaceKHR surface;
35
36 VkXcbSurfaceCreateInfoKHR surfaceCreateInfo;
37 memset(&surfaceCreateInfo, 0, sizeof(VkXcbSurfaceCreateInfoKHR));
39 surfaceCreateInfo.pNext = nullptr;
40 surfaceCreateInfo.flags = 0;
41 surfaceCreateInfo.connection = XGetXCBConnection(info.fDisplay);
42 surfaceCreateInfo.window = info.fWindow;
43
44 VkResult res = createXcbSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface);
45 if (VK_SUCCESS != res) {
46 return VK_NULL_HANDLE;
47 }
48
49 return surface;
50 };
51
52 auto canPresent = [&info, instProc](VkInstance instance, VkPhysicalDevice physDev,
53 uint32_t queueFamilyIndex) {
55 getPhysicalDeviceXcbPresentationSupportKHR = nullptr;
56 if (!getPhysicalDeviceXcbPresentationSupportKHR) {
57 getPhysicalDeviceXcbPresentationSupportKHR =
59 instProc(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
60 }
61
62 Display* display = info.fDisplay;
63 VisualID visualID = XVisualIDFromVisual(DefaultVisual(info.fDisplay,
64 DefaultScreen(info.fDisplay)));
65 VkBool32 check = getPhysicalDeviceXcbPresentationSupportKHR(physDev,
66 queueFamilyIndex,
67 XGetXCBConnection(display),
68 visualID);
69 return (VK_FALSE != check);
70 };
71 std::unique_ptr<WindowContext> ctx(
72 new internal::VulkanWindowContext(displayParams,
73 createVkSurface,
74 canPresent,
75 instProc));
76 if (!ctx->isValid()) {
77 return nullptr;
78 }
79 return ctx;
80}