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