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

Unified Diff: tools/vulkan/viewer/VulkanViewer.cpp

Issue 1865553005: Clean up input handling in VulkanViewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rename resize params Created 4 years, 8 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/vulkan/viewer/VulkanViewer.h ('k') | tools/vulkan/win/Window_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/vulkan/viewer/VulkanViewer.cpp
diff --git a/tools/vulkan/viewer/VulkanViewer.cpp b/tools/vulkan/viewer/VulkanViewer.cpp
index 0af423ec783d2f4795ac283f0b3a4eac5098c18a..27e7b1c08253a7d51cee623956dcab2276d389da 100644
--- a/tools/vulkan/viewer/VulkanViewer.cpp
+++ b/tools/vulkan/viewer/VulkanViewer.cpp
@@ -18,16 +18,11 @@ Application* Application::Create(int argc, char** argv, void* platformData) {
return new VulkanViewer(argc, argv, platformData);
}
-static bool on_key_handler(int key, bool keyDown, void* userData) {
+static bool on_key_handler(Window::Key key, Window::InputState state, uint32_t modifiers,
+ void* userData) {
VulkanViewer* vv = reinterpret_cast<VulkanViewer*>(userData);
- return vv->onKey(key, keyDown);
-}
-
-static bool on_mouse_handler(int x, int y, bool mouseDown, void* userData) {
- VulkanViewer* vv = reinterpret_cast<VulkanViewer*>(userData);
-
- return vv->onMouse(x, y, mouseDown);
+ return vv->onKey(key, state, modifiers);
}
static void on_paint_handler(SkCanvas* canvas, void* userData) {
@@ -44,7 +39,6 @@ VulkanViewer::VulkanViewer(int argc, char** argv, void* platformData) :
// register callbacks
fWindow->registerKeyFunc(on_key_handler, this);
- fWindow->registerMouseFunc(on_mouse_handler, this);
fWindow->registerPaintFunc(on_paint_handler, this);
fWindow->setTitle("VulkanViewer");
@@ -56,21 +50,12 @@ VulkanViewer::~VulkanViewer() {
delete fWindow;
}
-bool VulkanViewer::onKey(int key, bool keyDown) {
- if (keyDown) {
- fInputHandler.onKeyDown(key);
- } else {
- fInputHandler.onKeyUp(key);
- }
- return true;
-}
+bool VulkanViewer::onKey(Window::Key key, Window::InputState state, uint32_t modifiers) {
+ if (Window::kDown_InputState == state && (modifiers & Window::kFirstPress_ModifierKey) &&
+ key == Window::kRight_Key) {
+ fGMs = fGMs->next();
+ }
-bool VulkanViewer::onMouse(int x, int y, bool mouseDown) {
- if (mouseDown) {
- fInputHandler.onMouseDown(x, y);
- } else {
- fInputHandler.onMouseUp();
- }
return true;
}
@@ -85,10 +70,5 @@ void VulkanViewer::onPaint(SkCanvas* canvas) {
}
void VulkanViewer::onIdle(float dt) {
- if (fInputHandler.isKeyPressed('l') || fInputHandler.isKeyPressed('L')) {
- fGMs = fGMs->next();
- }
fWindow->onPaint();
-
- fInputHandler.Update();
}
« no previous file with comments | « tools/vulkan/viewer/VulkanViewer.h ('k') | tools/vulkan/win/Window_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698