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

Side by Side Diff: tools/vulkan/Window.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 unified diff | Download patch
« no previous file with comments | « tools/vulkan/Window.h ('k') | tools/vulkan/viewer/InputHandler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Window.h" 8 #include "Window.h"
9 9
10 #include "SkSurface.h" 10 #include "SkSurface.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "VulkanTestContext.h" 12 #include "VulkanTestContext.h"
13 13
14 static bool default_key_func(int key, bool down, void* userData) { 14 static bool default_char_func(SkUnichar c, uint32_t modifiers, void* userData) {
15 return false; 15 return false;
16 } 16 }
17 17
18 static bool default_mouse_func(int x, int y, bool down, void* userData) { 18 static bool default_key_func(Window::Key key, Window::InputState state, uint32_t modifiers,
19 void* userData) {
20 return false;
21 }
22
23 static bool default_mouse_func(int x, int y, Window::InputState state, uint32_t modifiers,
24 void* userData) {
19 return false; 25 return false;
20 } 26 }
21 27
22 static void default_paint_func(SkCanvas*, void* userData) {} 28 static void default_paint_func(SkCanvas*, void* userData) {}
23 29
24 Window::Window() : fKeyFunc(default_key_func) 30 Window::Window() : fCharFunc(default_char_func)
31 , fKeyFunc(default_key_func)
25 , fMouseFunc(default_mouse_func) 32 , fMouseFunc(default_mouse_func)
26 , fPaintFunc(default_paint_func) { 33 , fPaintFunc(default_paint_func) {
27 } 34 }
28 35
29 void Window::detach() { 36 void Window::detach() {
30 delete fTestContext; 37 delete fTestContext;
31 fTestContext = nullptr; 38 fTestContext = nullptr;
32 } 39 }
33 40
41 bool Window::onChar(SkUnichar c, uint32_t modifiers) {
42 return fCharFunc(c, modifiers, fCharUserData);
43 }
44
45 bool Window::onKey(Key key, InputState state, uint32_t modifiers) {
46 return fKeyFunc(key, state, modifiers, fKeyUserData);
47 }
48
49 bool Window::onMouse(int x, int y, InputState state, uint32_t modifiers) {
50 return fMouseFunc(x, y, state, modifiers, fMouseUserData);
51 }
52
34 void Window::onPaint() { 53 void Window::onPaint() {
35 SkSurface* backbuffer = fTestContext->getBackbufferSurface(); 54 SkSurface* backbuffer = fTestContext->getBackbufferSurface();
36 if (backbuffer) { 55 if (backbuffer) {
37 // draw into the canvas of this surface 56 // draw into the canvas of this surface
38 SkCanvas* canvas = backbuffer->getCanvas(); 57 SkCanvas* canvas = backbuffer->getCanvas();
39 58
40 fPaintFunc(canvas, fPaintUserData); 59 fPaintFunc(canvas, fPaintUserData);
41 60
42 canvas->flush(); 61 canvas->flush();
43 62
44 fTestContext->swapBuffers(); 63 fTestContext->swapBuffers();
45 } 64 }
46 65
47 } 66 }
48 67
49 68
50 void Window::onSize() { 69 void Window::onResize(uint32_t w, uint32_t h) {
51 fTestContext->resize(); 70 fTestContext->resize(w, h);
52 } 71 }
OLDNEW
« no previous file with comments | « tools/vulkan/Window.h ('k') | tools/vulkan/viewer/InputHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698