| OLD | NEW |
| 1 // Copyright (c) 2010 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 "base/task.h" | 7 #include "base/task.h" |
| 8 #include "media/tools/shader_bench/painter.h" | 8 #include "media/tools/shader_bench/painter.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace media { |
| 11 | 11 |
| 12 LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, | 12 static LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, |
| 13 WPARAM w_param, LPARAM l_param) { | 13 WPARAM w_param, LPARAM l_param) { |
| 14 LRESULT result = 0; | 14 LRESULT result = 0; |
| 15 switch (msg) { | 15 switch (msg) { |
| 16 case WM_CLOSE: | 16 case WM_CLOSE: |
| 17 ::DestroyWindow(hwnd); | 17 ::DestroyWindow(hwnd); |
| 18 break; | 18 break; |
| 19 case WM_DESTROY: | 19 case WM_DESTROY: |
| 20 ::PostQuitMessage(0); | 20 ::PostQuitMessage(0); |
| 21 break; | 21 break; |
| 22 case WM_ERASEBKGND: | 22 case WM_ERASEBKGND: |
| 23 // Return a non-zero value to indicate that the background has been | 23 // Return a non-zero value to indicate that the background has been |
| 24 // erased. | 24 // erased. |
| 25 result = 1; | 25 result = 1; |
| 26 break; | 26 break; |
| 27 case WM_PAINT: { | 27 case WM_PAINT: { |
| 28 media::Window* window = | 28 Window* window = |
| 29 reinterpret_cast<media::Window*>( | 29 reinterpret_cast<Window*>(GetWindowLongPtr(hwnd, GWL_USERDATA)); |
| 30 GetWindowLongPtr(hwnd, GWL_USERDATA)); | |
| 31 if (window != NULL) | 30 if (window != NULL) |
| 32 window->OnPaint(); | 31 window->OnPaint(); |
| 33 ::ValidateRect(hwnd, NULL); | 32 ::ValidateRect(hwnd, NULL); |
| 34 break; | 33 break; |
| 35 } | 34 } |
| 36 default: | 35 default: |
| 37 result = ::DefWindowProc(hwnd, msg, w_param, l_param); | 36 result = ::DefWindowProc(hwnd, msg, w_param, l_param); |
| 38 break; | 37 break; |
| 39 } | 38 } |
| 40 return result; | 39 return result; |
| 41 } | 40 } |
| 42 | 41 |
| 43 } // namespace | |
| 44 | |
| 45 namespace media { | |
| 46 | |
| 47 gfx::NativeWindow Window::CreateNativeWindow(int width, int height) { | 42 gfx::NativeWindow Window::CreateNativeWindow(int width, int height) { |
| 48 WNDCLASS wnd_class = {0}; | 43 WNDCLASS wnd_class = {0}; |
| 49 HINSTANCE instance = GetModuleHandle(NULL); | 44 HINSTANCE instance = GetModuleHandle(NULL); |
| 50 wnd_class.style = CS_OWNDC; | 45 wnd_class.style = CS_OWNDC; |
| 51 wnd_class.lpfnWndProc = WindowProc; | 46 wnd_class.lpfnWndProc = WindowProc; |
| 52 wnd_class.hInstance = instance; | 47 wnd_class.hInstance = instance; |
| 53 wnd_class.hbrBackground = | 48 wnd_class.hbrBackground = |
| 54 reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)); | 49 reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)); |
| 55 wnd_class.lpszClassName = L"gpu_demo"; | 50 wnd_class.lpszClassName = L"gpu_demo"; |
| 56 if (!RegisterClass(&wnd_class)) | 51 if (!RegisterClass(&wnd_class)) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 done = true; | 125 done = true; |
| 131 ::TranslateMessage(&msg); | 126 ::TranslateMessage(&msg); |
| 132 ::DispatchMessage(&msg); | 127 ::DispatchMessage(&msg); |
| 133 if (!done) | 128 if (!done) |
| 134 ::InvalidateRect(window_handle_, NULL, FALSE); | 129 ::InvalidateRect(window_handle_, NULL, FALSE); |
| 135 } | 130 } |
| 136 } | 131 } |
| 137 } | 132 } |
| 138 | 133 |
| 139 } // namespace media | 134 } // namespace media |
| OLD | NEW |