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

Side by Side Diff: tools/viewer/sk_app/Window.cpp

Issue 1982643004: Implement touch control (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkMutex Created 4 years, 7 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/viewer/sk_app/Window.h ('k') | tools/viewer/sk_app/android/Window_android.cpp » ('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 "VulkanWindowContext.h" 12 #include "VulkanWindowContext.h"
13 13
14 namespace sk_app { 14 namespace sk_app {
15 15
16 static bool default_char_func(SkUnichar c, uint32_t modifiers, void* userData) { 16 static bool default_char_func(SkUnichar c, uint32_t modifiers, void* userData) {
17 return false; 17 return false;
18 } 18 }
19 19
20 static bool default_key_func(Window::Key key, Window::InputState state, uint32_t modifiers, 20 static bool default_key_func(Window::Key key, Window::InputState state, uint32_t modifiers,
21 void* userData) { 21 void* userData) {
22 return false; 22 return false;
23 } 23 }
24 24
25 static bool default_mouse_func(int x, int y, Window::InputState state, uint32_t modifiers, 25 static bool default_mouse_func(int x, int y, Window::InputState state, uint32_t modifiers,
26 void* userData) { 26 void* userData) {
27 return false; 27 return false;
28 } 28 }
29 29
30 static bool default_touch_func(int owner, Window::InputState state, float x, flo at y,
31 void* userData) {
32 return false;
33 }
34
30 static void default_paint_func(SkCanvas*, void* userData) {} 35 static void default_paint_func(SkCanvas*, void* userData) {}
31 36
32 Window::Window() : fCharFunc(default_char_func) 37 Window::Window() : fCharFunc(default_char_func)
33 , fKeyFunc(default_key_func) 38 , fKeyFunc(default_key_func)
34 , fMouseFunc(default_mouse_func) 39 , fMouseFunc(default_mouse_func)
40 , fTouchFunc(default_touch_func)
35 , fPaintFunc(default_paint_func) { 41 , fPaintFunc(default_paint_func) {
36 } 42 }
37 43
38 void Window::detach() { 44 void Window::detach() {
39 delete fWindowContext; 45 delete fWindowContext;
40 fWindowContext = nullptr; 46 fWindowContext = nullptr;
41 } 47 }
42 48
43 bool Window::onChar(SkUnichar c, uint32_t modifiers) { 49 bool Window::onChar(SkUnichar c, uint32_t modifiers) {
44 return fCharFunc(c, modifiers, fCharUserData); 50 return fCharFunc(c, modifiers, fCharUserData);
45 } 51 }
46 52
47 bool Window::onKey(Key key, InputState state, uint32_t modifiers) { 53 bool Window::onKey(Key key, InputState state, uint32_t modifiers) {
48 return fKeyFunc(key, state, modifiers, fKeyUserData); 54 return fKeyFunc(key, state, modifiers, fKeyUserData);
49 } 55 }
50 56
51 bool Window::onMouse(int x, int y, InputState state, uint32_t modifiers) { 57 bool Window::onMouse(int x, int y, InputState state, uint32_t modifiers) {
52 return fMouseFunc(x, y, state, modifiers, fMouseUserData); 58 return fMouseFunc(x, y, state, modifiers, fMouseUserData);
53 } 59 }
54 60
61 bool Window::onTouch(int owner, InputState state, float x, float y) {
62 return fTouchFunc(owner, state, x, y, fTouchUserData);
63 }
64
55 void Window::onPaint() { 65 void Window::onPaint() {
56 SkSurface* backbuffer = fWindowContext->getBackbufferSurface(); 66 SkSurface* backbuffer = fWindowContext->getBackbufferSurface();
57 if (backbuffer) { 67 if (backbuffer) {
58 // draw into the canvas of this surface 68 // draw into the canvas of this surface
59 SkCanvas* canvas = backbuffer->getCanvas(); 69 SkCanvas* canvas = backbuffer->getCanvas();
60 70
61 fPaintFunc(canvas, fPaintUserData); 71 fPaintFunc(canvas, fPaintUserData);
62 72
63 canvas->flush(); 73 canvas->flush();
64 74
(...skipping 12 matching lines...) Expand all
77 87
78 const DisplayParams& Window::getDisplayParams() { 88 const DisplayParams& Window::getDisplayParams() {
79 return fWindowContext->getDisplayParams(); 89 return fWindowContext->getDisplayParams();
80 } 90 }
81 91
82 void Window::setDisplayParams(const DisplayParams& params) { 92 void Window::setDisplayParams(const DisplayParams& params) {
83 fWindowContext->setDisplayParams(params); 93 fWindowContext->setDisplayParams(params);
84 } 94 }
85 95
86 } // namespace sk_app 96 } // namespace sk_app
OLDNEW
« no previous file with comments | « tools/viewer/sk_app/Window.h ('k') | tools/viewer/sk_app/android/Window_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698