From d63c10225c008cec541024fd9468a5faf2db1fbc Mon Sep 17 00:00:00 2001 From: Jim Van Verth Date: Thu, 5 Jan 2017 13:50:49 -0500 Subject: [PATCH] Minor fixes for the Linux viewer BUG=skia:6091 Change-Id: Ia954c16610634e34f10bfe4273efc6677ca9563e Reviewed-on: https://skia-review.googlesource.com/6618 Reviewed-by: Greg Daniel --- tools/viewer/Viewer.cpp | 28 +++++++++------------ tools/viewer/sk_app/VulkanWindowContext.cpp | 3 +++ tools/viewer/sk_app/unix/Window_unix.cpp | 1 + tools/viewer/sk_app/unix/main_unix.cpp | 6 +++-- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index c1d08d1241..49a331bcf4 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -150,10 +150,6 @@ Viewer::Viewer(int argc, char** argv, void* platformData) fBackendType = get_backend_type(FLAGS_backend[0]); fWindow = Window::CreateNativeWindow(platformData); fWindow->attach(fBackendType, DisplayParams()); -#if defined(SK_VULKAN) && defined(SK_BUILD_FOR_UNIX) - // Vulkan doesn't seem to handle a single refresh properly on Linux - fRefresh = (sk_app::Window::kVulkan_BackendType == fBackendType); -#endif // register callbacks fCommands.attach(fWindow); @@ -198,8 +194,8 @@ Viewer::Viewer(int argc, char** argv, void* platformData) this->changeZoomLevel(-1.f / 32.f); fWindow->inval(); }); -#if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC) fCommands.addCommand('d', "Modes", "Change rendering backend", [this]() { +#if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC) if (sk_app::Window::kRaster_BackendType == fBackendType) { fBackendType = sk_app::Window::kNativeGL_BackendType; #ifdef SK_VULKAN @@ -209,14 +205,19 @@ Viewer::Viewer(int argc, char** argv, void* platformData) } else { fBackendType = sk_app::Window::kRaster_BackendType; } - +#elif defined(SK_BUILD_FOR_UNIX) + // Switching to and from Vulkan is problematic on Linux so disabled for now + if (sk_app::Window::kRaster_BackendType == fBackendType) { + fBackendType = sk_app::Window::kNativeGL_BackendType; + } else if (sk_app::Window::kNativeGL_BackendType == fBackendType) { + fBackendType = sk_app::Window::kRaster_BackendType; + } +#endif fWindow->detach(); -#ifdef SK_VULKAN - // Switching from OpenGL to Vulkan in the same window is problematic at this point, - // so we just delete the window and recreate it. - // On Windows, only tearing down the window when going from OpenGL to Vulkan works fine. - // On Linux, we may need to tear down the window for the Vulkan to OpenGL case as well. +#if defined(SK_BUILD_FOR_WIN) && defined(SK_VULKAN) + // Switching from OpenGL to Vulkan in the same window is problematic at this point on + // Windows, so we just delete the window and recreate it. if (sk_app::Window::kVulkan_BackendType == fBackendType) { delete fWindow; fWindow = Window::CreateNativeWindow(nullptr); @@ -229,16 +230,11 @@ Viewer::Viewer(int argc, char** argv, void* platformData) } #endif fWindow->attach(fBackendType, DisplayParams()); -#if defined(SK_VULKAN) && defined(SK_BUILD_FOR_UNIX) - // Vulkan doesn't seem to handle a single refresh properly on Linux - fRefresh = (sk_app::Window::kVulkan_BackendType == fBackendType); -#endif this->updateTitle(); fWindow->inval(); fWindow->show(); }); -#endif // set up slides this->initSlides(); diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp index 9d1e043097..c8335d28b4 100644 --- a/tools/viewer/sk_app/VulkanWindowContext.cpp +++ b/tools/viewer/sk_app/VulkanWindowContext.cpp @@ -446,6 +446,9 @@ sk_sp VulkanWindowContext::getBackbufferSurface() { if (!this->createSwapchain(-1, -1, fDisplayParams)) { return nullptr; } + backbuffer = this->getAvailableBackbuffer(); + GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, + ResetFences(fBackendContext->fDevice, 2, backbuffer->fUsageFences)); // acquire the image res = fAcquireNextImageKHR(fBackendContext->fDevice, fSwapchain, UINT64_MAX, diff --git a/tools/viewer/sk_app/unix/Window_unix.cpp b/tools/viewer/sk_app/unix/Window_unix.cpp index 3520257b5f..d22502bc91 100644 --- a/tools/viewer/sk_app/unix/Window_unix.cpp +++ b/tools/viewer/sk_app/unix/Window_unix.cpp @@ -26,6 +26,7 @@ SkTDynamicHash Window_unix::gWindowMap; Window* Window::CreateNativeWindow(void* platformData) { Display* display = (Display*)platformData; + SkASSERT(display); Window_unix* window = new Window_unix(); if (!window->initWindow(display, nullptr)) { diff --git a/tools/viewer/sk_app/unix/main_unix.cpp b/tools/viewer/sk_app/unix/main_unix.cpp index c0fd418262..a5e7004423 100644 --- a/tools/viewer/sk_app/unix/main_unix.cpp +++ b/tools/viewer/sk_app/unix/main_unix.cpp @@ -46,16 +46,18 @@ int main(int argc, char**argv) { (void) select(count, &in_fds, NULL, NULL, &tv); } - // Handle XEvents (if any) and flush the input + // Handle XEvents (if any) and flush the input int count = XPending(display); while (count-- && !done) { XEvent event; XNextEvent(display, &event); sk_app::Window_unix* win = sk_app::Window_unix::gWindowMap.find(event.xany.window); + SkASSERT(win); + // paint and resize events get collapsed switch (event.type) { - case Expose: + case Expose: win->markPendingPaint(); pendingWindows.add(win); break;