Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp

Issue 1999213002: Add Xlib support to viewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove viewer hack Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/viewer/sk_app/android/VulkanWindowContext_android.cpp ('k') | tools/viewer/sk_app/unix/Window_unix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp
diff --git a/tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp b/tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ddfc8e3068d39583c86ea76dc39e1c57c3662fa4
--- /dev/null
+++ b/tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp
@@ -0,0 +1,74 @@
+
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "../VulkanWindowContext.h"
+#include "Window_unix.h"
+
+#include "vk/GrVkInterface.h"
+#include "vk/GrVkUtil.h"
+
+#include <X11/Xlib-xcb.h>
+
+namespace sk_app {
+
+// Platform dependant call
+VkSurfaceKHR VulkanWindowContext::createVkSurface(VkInstance instance, void* platformData) {
+ static PFN_vkCreateXcbSurfaceKHR createXcbSurfaceKHR = nullptr;
+ if (!createXcbSurfaceKHR) {
+ createXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR) vkGetInstanceProcAddr(instance,
+ "vkCreateXcbSurfaceKHR");
+ }
+
+ if (!platformData) {
+ return VK_NULL_HANDLE;
+ }
+ ContextPlatformData_unix* unixPlatformData =
+ reinterpret_cast<ContextPlatformData_unix*>(platformData);
+
+
+ VkSurfaceKHR surface;
+
+ VkXcbSurfaceCreateInfoKHR surfaceCreateInfo;
+ memset(&surfaceCreateInfo, 0, sizeof(VkXcbSurfaceCreateInfoKHR));
+ surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
+ surfaceCreateInfo.pNext = nullptr;
+ surfaceCreateInfo.flags = 0;
+ surfaceCreateInfo.connection = XGetXCBConnection(unixPlatformData->fDisplay);
+ surfaceCreateInfo.window = unixPlatformData->fHWnd;
+
+ VkResult res = createXcbSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface);
+ if (VK_SUCCESS != res) {
+ return VK_NULL_HANDLE;
+ }
+
+ return surface;
+}
+
+// Platform dependant call
+bool VulkanWindowContext::canPresent(VkInstance instance, VkPhysicalDevice physDev,
+ uint32_t queueFamilyIndex, void* platformData) {
+ static PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR
+ getPhysicalDeviceXcbPresentationSupportKHR = nullptr;
+ if (!getPhysicalDeviceXcbPresentationSupportKHR) {
+ getPhysicalDeviceXcbPresentationSupportKHR =
+ (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR) vkGetInstanceProcAddr(instance,
+ "vkGetPhysicalDeviceXcbPresentationSupportKHR");
+ }
+
+ ContextPlatformData_unix* unixPlatformData =
+ reinterpret_cast<ContextPlatformData_unix*>(platformData);
+
+ Display* display = unixPlatformData->fDisplay;
+ VkBool32 check = getPhysicalDeviceXcbPresentationSupportKHR(physDev,
+ queueFamilyIndex,
+ XGetXCBConnection(display),
+ unixPlatformData->fVisualID);
+ return (VK_FALSE != check);
+}
+
+} // namespace sk_app
« no previous file with comments | « tools/viewer/sk_app/android/VulkanWindowContext_android.cpp ('k') | tools/viewer/sk_app/unix/Window_unix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698