OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/tools/shader_bench/window.h" | 5 #include "media/tools/shader_bench/window.h" |
6 | 6 |
7 #include "media/tools/shader_bench/painter.h" | 7 #include "media/tools/shader_bench/painter.h" |
8 | 8 |
9 namespace media { | 9 namespace media { |
10 | 10 |
11 static LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, | 11 static LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, |
12 WPARAM w_param, LPARAM l_param) { | 12 WPARAM w_param, LPARAM l_param) { |
13 LRESULT result = 0; | 13 LRESULT result = 0; |
14 switch (msg) { | 14 switch (msg) { |
15 case WM_CLOSE: | 15 case WM_CLOSE: |
16 ::DestroyWindow(hwnd); | 16 ::DestroyWindow(hwnd); |
17 break; | 17 break; |
18 case WM_DESTROY: | 18 case WM_DESTROY: |
19 ::PostQuitMessage(0); | 19 ::PostQuitMessage(0); |
20 break; | 20 break; |
21 case WM_ERASEBKGND: | 21 case WM_ERASEBKGND: |
22 // Return a non-zero value to indicate that the background has been | 22 // Return a non-zero value to indicate that the background has been |
23 // erased. | 23 // erased. |
24 result = 1; | 24 result = 1; |
25 break; | 25 break; |
26 case WM_PAINT: { | 26 case WM_PAINT: { |
27 Window* window = | 27 Window* window = |
28 reinterpret_cast<Window*>(GetWindowLongPtr(hwnd, GWL_USERDATA)); | 28 reinterpret_cast<Window*>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); |
29 if (window != NULL) | 29 if (window != NULL) |
30 window->OnPaint(); | 30 window->OnPaint(); |
31 ::ValidateRect(hwnd, NULL); | 31 ::ValidateRect(hwnd, NULL); |
32 break; | 32 break; |
33 } | 33 } |
34 default: | 34 default: |
35 result = ::DefWindowProc(hwnd, msg, w_param, l_param); | 35 result = ::DefWindowProc(hwnd, msg, w_param, l_param); |
36 break; | 36 break; |
37 } | 37 } |
38 return result; | 38 return result; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 void Window::Start(int limit, const base::Closure& callback, | 83 void Window::Start(int limit, const base::Closure& callback, |
84 Painter* painter) { | 84 Painter* painter) { |
85 running_ = true; | 85 running_ = true; |
86 count_ = 0; | 86 count_ = 0; |
87 limit_ = limit; | 87 limit_ = limit; |
88 callback_ = callback; | 88 callback_ = callback; |
89 painter_ = painter; | 89 painter_ = painter; |
90 | 90 |
91 SetWindowLongPtr(window_handle_, GWL_USERDATA, | 91 SetWindowLongPtr(window_handle_, GWLP_USERDATA, |
92 reinterpret_cast<LONG_PTR>(this)); | 92 reinterpret_cast<LONG_PTR>(this)); |
93 | 93 |
94 ShowWindow(window_handle_, SW_SHOWNORMAL); | 94 ShowWindow(window_handle_, SW_SHOWNORMAL); |
95 | 95 |
96 // Post first invalidate call to kick off painting. | 96 // Post first invalidate call to kick off painting. |
97 ::InvalidateRect(window_handle_, NULL, FALSE); | 97 ::InvalidateRect(window_handle_, NULL, FALSE); |
98 | 98 |
99 MainLoop(); | 99 MainLoop(); |
100 } | 100 } |
101 | 101 |
(...skipping 23 matching lines...) Expand all Loading... |
125 done = true; | 125 done = true; |
126 ::TranslateMessage(&msg); | 126 ::TranslateMessage(&msg); |
127 ::DispatchMessage(&msg); | 127 ::DispatchMessage(&msg); |
128 if (!done) | 128 if (!done) |
129 ::InvalidateRect(window_handle_, NULL, FALSE); | 129 ::InvalidateRect(window_handle_, NULL, FALSE); |
130 } | 130 } |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 } // namespace media | 134 } // namespace media |
OLD | NEW |