aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2016-08-11 07:03:04 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-11 07:03:04 -0700
commit8c67ebe4c48028635e7fe34542344e0ca7006b23 (patch)
treeaee9ec85faa281c4919a531074d8559003a92404
parent6b2d7acecdd1a1e2b94d6c3b46697c8e9df3dbe5 (diff)
Clean up Xlib viewer
* Make event handling closer to GLFW's * Fix Vulkan refreshing BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2226413002 Review-Url: https://codereview.chromium.org/2226413002
-rw-r--r--tools/viewer/Viewer.cpp8
-rw-r--r--tools/viewer/sk_app/VulkanWindowContext.cpp1
-rw-r--r--tools/viewer/sk_app/unix/main_unix.cpp16
3 files changed, 19 insertions, 6 deletions
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index da329e0b3e..6f33d2c202 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -136,6 +136,10 @@ 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);
@@ -211,6 +215,10 @@ 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();
diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp
index 815e8c43f5..7f35e30f48 100644
--- a/tools/viewer/sk_app/VulkanWindowContext.cpp
+++ b/tools/viewer/sk_app/VulkanWindowContext.cpp
@@ -587,7 +587,6 @@ void VulkanWindowContext::swapBuffers() {
};
fQueuePresentKHR(fPresentQueue, &presentInfo);
-
}
} //namespace sk_app
diff --git a/tools/viewer/sk_app/unix/main_unix.cpp b/tools/viewer/sk_app/unix/main_unix.cpp
index 5e6b7fe3ee..c0fd418262 100644
--- a/tools/viewer/sk_app/unix/main_unix.cpp
+++ b/tools/viewer/sk_app/unix/main_unix.cpp
@@ -26,12 +26,13 @@ int main(int argc, char**argv) {
// Get the file descriptor for the X display
int x11_fd = ConnectionNumber(display);
- fd_set in_fds;
+ int count = x11_fd + 1;
SkTHashSet<sk_app::Window_unix*> pendingWindows;
bool done = false;
while (!done) {
// Create a file description set containing x11_fd
+ fd_set in_fds;
FD_ZERO(&in_fds);
FD_SET(x11_fd, &in_fds);
@@ -40,12 +41,15 @@ int main(int argc, char**argv) {
tv.tv_usec = 100;
tv.tv_sec = 0;
- // Wait for an event on the file descriptor or for timer expiration
- (void) select(1, &in_fds, NULL, NULL, &tv);
+ while (!XPending(display)) {
+ // Wait for an event on the file descriptor or for timer expiration
+ (void) select(count, &in_fds, NULL, NULL, &tv);
+ }
// Handle XEvents (if any) and flush the input
- XEvent event;
- while (XPending(display) && !done) {
+ 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);
@@ -73,6 +77,8 @@ int main(int argc, char**argv) {
app->onIdle();
}
pendingWindows.reset();
+
+ XFlush(display);
}
delete app;