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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 bool Window::onKey(Key key, InputState state, uint32_t modifiers) { | 47 bool Window::onKey(Key key, InputState state, uint32_t modifiers) { |
48 return fKeyFunc(key, state, modifiers, fKeyUserData); | 48 return fKeyFunc(key, state, modifiers, fKeyUserData); |
49 } | 49 } |
50 | 50 |
51 bool Window::onMouse(int x, int y, InputState state, uint32_t modifiers) { | 51 bool Window::onMouse(int x, int y, InputState state, uint32_t modifiers) { |
52 return fMouseFunc(x, y, state, modifiers, fMouseUserData); | 52 return fMouseFunc(x, y, state, modifiers, fMouseUserData); |
53 } | 53 } |
54 | 54 |
| 55 bool Window::onTouch(int owner, InputState state, float x, float y) { |
| 56 void* castedOwner = reinterpret_cast<void*>(owner); |
| 57 switch (state) { |
| 58 case Window::kUp_InputState: { |
| 59 fGesture.touchEnd(castedOwner); |
| 60 break; |
| 61 } |
| 62 case Window::kDown_InputState: { |
| 63 fGesture.touchBegin(castedOwner, x, y); |
| 64 break; |
| 65 } |
| 66 case Window::kMove_InputState: { |
| 67 fGesture.touchMoved(castedOwner, x, y); |
| 68 break; |
| 69 } |
| 70 } |
| 71 inval(); |
| 72 return true; |
| 73 } |
| 74 |
55 void Window::onPaint() { | 75 void Window::onPaint() { |
56 SkSurface* backbuffer = fWindowContext->getBackbufferSurface(); | 76 SkSurface* backbuffer = fWindowContext->getBackbufferSurface(); |
57 if (backbuffer) { | 77 if (backbuffer) { |
58 // draw into the canvas of this surface | 78 // draw into the canvas of this surface |
59 SkCanvas* canvas = backbuffer->getCanvas(); | 79 SkCanvas* canvas = backbuffer->getCanvas(); |
60 | 80 |
61 fPaintFunc(canvas, fPaintUserData); | 81 fPaintFunc(canvas, fPaintUserData); |
62 | 82 |
63 canvas->flush(); | 83 canvas->flush(); |
64 | 84 |
(...skipping 11 matching lines...) Expand all Loading... |
76 } | 96 } |
77 | 97 |
78 const DisplayParams& Window::getDisplayParams() { | 98 const DisplayParams& Window::getDisplayParams() { |
79 return fWindowContext->getDisplayParams(); | 99 return fWindowContext->getDisplayParams(); |
80 } | 100 } |
81 | 101 |
82 void Window::setDisplayParams(const DisplayParams& params) { | 102 void Window::setDisplayParams(const DisplayParams& params) { |
83 fWindowContext->setDisplayParams(params); | 103 fWindowContext->setDisplayParams(params); |
84 } | 104 } |
85 | 105 |
| 106 const SkMatrix& Window::getGestureLocalM() { |
| 107 return fGesture.localM(); |
| 108 } |
| 109 |
| 110 const SkMatrix& Window::getGestureGlobalM() const { |
| 111 return fGesture.globalM(); |
| 112 } |
| 113 |
86 } // namespace sk_app | 114 } // namespace sk_app |
OLD | NEW |