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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 void Window::onPaint() { | 55 void Window::onPaint() { |
56 sk_sp<SkSurface> backbuffer = fWindowContext->getBackbufferSurface(); | 56 SkSurface* backbuffer = fWindowContext->getBackbufferSurface(); |
57 if (backbuffer) { | 57 if (backbuffer) { |
58 // draw into the canvas of this surface | 58 // draw into the canvas of this surface |
59 SkCanvas* canvas = backbuffer->getCanvas(); | 59 SkCanvas* canvas = backbuffer->getCanvas(); |
60 | 60 |
61 fPaintFunc(canvas, fPaintUserData); | 61 fPaintFunc(canvas, fPaintUserData); |
62 | 62 |
63 canvas->flush(); | 63 canvas->flush(); |
64 | 64 |
65 fWindowContext->swapBuffers(); | 65 fWindowContext->swapBuffers(); |
66 } else { | 66 } else { |
67 // try recreating testcontext | 67 // try recreating testcontext |
68 } | 68 } |
| 69 |
69 } | 70 } |
70 | 71 |
71 void Window::onResize(uint32_t w, uint32_t h) { | 72 void Window::onResize(uint32_t w, uint32_t h) { |
72 fWidth = w; | 73 fWidth = w; |
73 fHeight = h; | 74 fHeight = h; |
74 fWindowContext->resize(w, h); | 75 fWindowContext->resize(w, h); |
75 } | 76 } |
76 | 77 |
77 const DisplayParams& Window::getDisplayParams() { | 78 const DisplayParams& Window::getDisplayParams() { |
78 return fWindowContext->getDisplayParams(); | 79 return fWindowContext->getDisplayParams(); |
79 } | 80 } |
80 | 81 |
81 void Window::setDisplayParams(const DisplayParams& params) { | 82 void Window::setDisplayParams(const DisplayParams& params) { |
82 fWindowContext->setDisplayParams(params); | 83 fWindowContext->setDisplayParams(params); |
83 } | 84 } |
84 | 85 |
85 } // namespace sk_app | 86 } // namespace sk_app |
OLD | NEW |