OLD | NEW |
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" |
(...skipping 14 matching lines...) Expand all Loading... |
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, | 30 static bool default_touch_func(int owner, Window::InputState state, float x, flo
at y, |
31 void* userData) { | 31 void* userData) { |
32 return false; | 32 return false; |
33 } | 33 } |
34 | 34 |
35 static void default_ui_state_changed_func( | |
36 const SkString& stateName, const SkString& stateValue, void* userData) {
} | |
37 | |
38 static void default_paint_func(SkCanvas*, void* userData) {} | 35 static void default_paint_func(SkCanvas*, void* userData) {} |
39 | 36 |
40 Window::Window() : fCharFunc(default_char_func) | 37 Window::Window() : fCharFunc(default_char_func) |
41 , fKeyFunc(default_key_func) | 38 , fKeyFunc(default_key_func) |
42 , fMouseFunc(default_mouse_func) | 39 , fMouseFunc(default_mouse_func) |
43 , fTouchFunc(default_touch_func) | 40 , fTouchFunc(default_touch_func) |
44 , fUIStateChangedFunc(default_ui_state_changed_func) | |
45 , fPaintFunc(default_paint_func) { | 41 , fPaintFunc(default_paint_func) { |
46 } | 42 } |
47 | 43 |
48 void Window::detach() { | 44 void Window::detach() { |
49 delete fWindowContext; | 45 delete fWindowContext; |
50 fWindowContext = nullptr; | 46 fWindowContext = nullptr; |
51 } | 47 } |
52 | 48 |
53 bool Window::onChar(SkUnichar c, uint32_t modifiers) { | 49 bool Window::onChar(SkUnichar c, uint32_t modifiers) { |
54 return fCharFunc(c, modifiers, fCharUserData); | 50 return fCharFunc(c, modifiers, fCharUserData); |
55 } | 51 } |
56 | 52 |
57 bool Window::onKey(Key key, InputState state, uint32_t modifiers) { | 53 bool Window::onKey(Key key, InputState state, uint32_t modifiers) { |
58 return fKeyFunc(key, state, modifiers, fKeyUserData); | 54 return fKeyFunc(key, state, modifiers, fKeyUserData); |
59 } | 55 } |
60 | 56 |
61 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) { |
62 return fMouseFunc(x, y, state, modifiers, fMouseUserData); | 58 return fMouseFunc(x, y, state, modifiers, fMouseUserData); |
63 } | 59 } |
64 | 60 |
65 bool Window::onTouch(int owner, InputState state, float x, float y) { | 61 bool Window::onTouch(int owner, InputState state, float x, float y) { |
66 return fTouchFunc(owner, state, x, y, fTouchUserData); | 62 return fTouchFunc(owner, state, x, y, fTouchUserData); |
67 } | 63 } |
68 | 64 |
69 void Window::onUIStateChanged(const SkString& stateName, const SkString& stateVa
lue) { | |
70 return fUIStateChangedFunc(stateName, stateValue, fUIStateChangedUserData); | |
71 } | |
72 | |
73 void Window::onPaint() { | 65 void Window::onPaint() { |
74 markInvalProcessed(); | 66 markInvalProcessed(); |
75 sk_sp<SkSurface> backbuffer = fWindowContext->getBackbufferSurface(); | 67 sk_sp<SkSurface> backbuffer = fWindowContext->getBackbufferSurface(); |
76 if (backbuffer) { | 68 if (backbuffer) { |
77 // draw into the canvas of this surface | 69 // draw into the canvas of this surface |
78 SkCanvas* canvas = backbuffer->getCanvas(); | 70 SkCanvas* canvas = backbuffer->getCanvas(); |
79 | 71 |
80 fPaintFunc(canvas, fPaintUserData); | 72 fPaintFunc(canvas, fPaintUserData); |
81 | 73 |
82 canvas->flush(); | 74 canvas->flush(); |
(...skipping 23 matching lines...) Expand all Loading... |
106 fIsContentInvalidated = true; | 98 fIsContentInvalidated = true; |
107 onInval(); | 99 onInval(); |
108 } | 100 } |
109 } | 101 } |
110 | 102 |
111 void Window::markInvalProcessed() { | 103 void Window::markInvalProcessed() { |
112 fIsContentInvalidated = false; | 104 fIsContentInvalidated = false; |
113 } | 105 } |
114 | 106 |
115 } // namespace sk_app | 107 } // namespace sk_app |
OLD | NEW |