Truly independent web browser
UI/Qt: Show pages when the window system cannot present Vulkan frames
Luke Wilde5958d601bffb
diff --git a/UI/Qt/WebContentView.h b/UI/Qt/WebContentView.hindex a455c9fe210..5be5accd2f3 100644--- a/UI/Qt/WebContentView.h+++ b/UI/Qt/WebContentView.h@@ -459,6 +459,7 @@ private:void update_vulkan_window_geometry();void set_vulkan_window_container_visible(bool);void fall_back_to_bitmap_rendering();+ void fall_back_from_vulkan_window();void vulkan_window_exposure_changed();QRect rect_covered_by_page_window() const;bool vulkan_window_update_would_only_resize() const;diff --git a/UI/Qt/WebContentViewLinux.cpp b/UI/Qt/WebContentViewLinux.cppindex 672d9e37327..1714543e74a 100644--- a/UI/Qt/WebContentViewLinux.cpp+++ b/UI/Qt/WebContentViewLinux.cpp@@ -843,6 +843,22 @@ struct WebContentView::VulkanRenderer {size_t next_imported_texture_slot { 0 };};+// Whether one of the queue families of the window's device can present to it.+static bool can_present_to(QVulkanWindow& window)+{+ auto* physical_device = window.physicalDevice();+ u32 queue_family_count = 0;+ vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &queue_family_count, nullptr);+ for (u32 queue_family_index = 0; queue_family_index < queue_family_count; ++queue_family_index) {+ if (window.vulkanInstance()->supportsPresent(physical_device, queue_family_index, &window))+ return true;+ }+ return false;+}++// Whether the window system has refused to present the window of a view.+static bool s_vulkan_windows_cannot_present { false };+struct WebContentView::VulkanWindowRenderer final : public QVulkanWindowRenderer {AK_ALLOC_WITH_KMALLOC;@@ -852,6 +868,12 @@ struct WebContentView::VulkanWindowRenderer final : public QVulkanWindowRenderer{}+ virtual void preInitResources() override+ {+ if (!can_present_to(m_window))+ m_view.fall_back_from_vulkan_window();+ }+virtual void releaseSwapChainResources() override{m_view.m_vulkan_window_supports_alpha_blending.clear();@@ -1058,7 +1080,7 @@ struct WebContentView::VulkanWindow final : public QVulkanWindow {void WebContentView::create_vulkan_window(){auto* instance = vulkan_instance();- if (!instance)+ if (!instance || s_vulkan_windows_cannot_present)return;m_vulkan_window = new VulkanWindow(*this);@@ -1180,6 +1202,19 @@ void WebContentView::fall_back_to_bitmap_rendering()});}+void WebContentView::fall_back_from_vulkan_window()+{+ if (!s_vulkan_windows_cannot_present) {+ dbgln("The window system cannot present frames drawn with Vulkan, so Qt shows the pages instead");+ s_vulkan_windows_cannot_present = true;+ }+ // NB: This is invoked while QVulkanWindow initializes, which must finish before the window is destroyed.+ QTimer::singleShot(0, this, [this] {+ destroy_vulkan_window();+ schedule_vulkan_window_update();+ });+}+void WebContentView::destroy_vulkan_window(){if (m_vulkan_window)