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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 | 56 |
57 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) { |
58 return fMouseFunc(x, y, state, modifiers, fMouseUserData); | 58 return fMouseFunc(x, y, state, modifiers, fMouseUserData); |
59 } | 59 } |
60 | 60 |
61 bool Window::onTouch(int owner, InputState state, float x, float y) { | 61 bool Window::onTouch(int owner, InputState state, float x, float y) { |
62 return fTouchFunc(owner, state, x, y, fTouchUserData); | 62 return fTouchFunc(owner, state, x, y, fTouchUserData); |
63 } | 63 } |
64 | 64 |
65 void Window::onPaint() { | 65 void Window::onPaint() { |
66 SkAutoMutexAcquire ama(fMutex); | |
jvanverth1
2016/05/23 14:22:32
How long does the mutex take? On single-threaded s
| |
67 fIsContentInvalidated = false; | |
djsollen
2016/05/23 14:44:26
putting this here won't work on Android as the inv
liyuqian
2016/05/23 14:58:24
Good catch! Revised.
| |
66 sk_sp<SkSurface> backbuffer = fWindowContext->getBackbufferSurface(); | 68 sk_sp<SkSurface> backbuffer = fWindowContext->getBackbufferSurface(); |
67 if (backbuffer) { | 69 if (backbuffer) { |
68 // draw into the canvas of this surface | 70 // draw into the canvas of this surface |
69 SkCanvas* canvas = backbuffer->getCanvas(); | 71 SkCanvas* canvas = backbuffer->getCanvas(); |
70 | 72 |
71 fPaintFunc(canvas, fPaintUserData); | 73 fPaintFunc(canvas, fPaintUserData); |
72 | 74 |
73 canvas->flush(); | 75 canvas->flush(); |
74 | 76 |
75 fWindowContext->swapBuffers(); | 77 fWindowContext->swapBuffers(); |
76 } else { | 78 } else { |
77 // try recreating testcontext | 79 // try recreating testcontext |
78 } | 80 } |
79 } | 81 } |
80 | 82 |
81 void Window::onResize(uint32_t w, uint32_t h) { | 83 void Window::onResize(uint32_t w, uint32_t h) { |
82 fWidth = w; | 84 fWidth = w; |
83 fHeight = h; | 85 fHeight = h; |
84 fWindowContext->resize(w, h); | 86 fWindowContext->resize(w, h); |
85 } | 87 } |
86 | 88 |
87 const DisplayParams& Window::getDisplayParams() { | 89 const DisplayParams& Window::getDisplayParams() { |
88 return fWindowContext->getDisplayParams(); | 90 return fWindowContext->getDisplayParams(); |
89 } | 91 } |
90 | 92 |
91 void Window::setDisplayParams(const DisplayParams& params) { | 93 void Window::setDisplayParams(const DisplayParams& params) { |
92 fWindowContext->setDisplayParams(params); | 94 fWindowContext->setDisplayParams(params); |
93 } | 95 } |
94 | 96 |
97 void Window::checkAndInval() { | |
98 SkAutoMutexAcquire ama(fMutex); | |
99 if (!fIsContentInvalidated) { | |
100 fIsContentInvalidated = true; | |
101 inval(); | |
102 } | |
103 } | |
104 | |
95 } // namespace sk_app | 105 } // namespace sk_app |
OLD | NEW |