Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: media/tools/shader_bench/window_win.cc

Issue 4873002: Benchmark tool for GPU-accelerated video rendering (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up Window/Painter interface a little Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/tools/shader_bench/window.h"
6
7 #include "base/utf_string_conversions.h"
8
9 namespace {
10
11 LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg,
12 WPARAM w_param, LPARAM l_param) {
13 LRESULT result = 0;
14 switch (msg) {
15 case WM_CLOSE:
16 ::DestroyWindow(hwnd);
17 break;
18 case WM_DESTROY:
19 ::PostQuitMessage(0);
20 break;
21 case WM_ERASEBKGND:
22 // Return a non-zero value to indicate that the background has been
23 // erased.
24 result = 1;
25 break;
26 case WM_PAINT: {
27 Painter* painter =
28 reinterpret_cast<Painter*>(GetWindowLongPtr(hwnd, GWL_USERDATA));
29 if (painter != NULL) painter->OnPaint();
30 ::ValidateRect(hwnd, NULL);
31 break;
32 }
33 default:
34 result = ::DefWindowProc(hwnd, msg, w_param, l_param);
35 break;
36 }
37 return result;
38 }
39
40 } // namespace.
Alpha Left Google 2010/11/15 20:43:51 just // namespace
41
42 namespace media {
43
44 gfx::NativeWindow Window::CreateNativeWindow(int width, int height) {
45 WNDCLASS wnd_class = {0};
46 HINSTANCE instance = GetModuleHandle(NULL);
47 wnd_class.style = CS_OWNDC;
48 wnd_class.lpfnWndProc = WindowProc;
49 wnd_class.hInstance = instance;
50 wnd_class.hbrBackground =
51 reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH));
52 wnd_class.lpszClassName = L"gpu_demo";
53 if (!RegisterClass(&wnd_class)) return NULL;
54
55 DWORD wnd_style = WS_OVERLAPPED | WS_SYSMENU;
56 RECT wnd_rect;
57 wnd_rect.left = 0;
58 wnd_rect.top = 0;
59 wnd_rect.right = width;
60 wnd_rect.bottom = height;
61 AdjustWindowRect(&wnd_rect, wnd_style, FALSE);
62
63 HWND hwnd = CreateWindow(
64 wnd_class.lpszClassName,
65 L"",
66 wnd_style,
67 0,
68 0,
69 wnd_rect.right - wnd_rect.left,
70 wnd_rect.bottom - wnd_rect.top,
71 NULL,
72 NULL,
73 instance,
74 NULL);
75 if (hwnd == NULL) return NULL;
76
77 ShowWindow(hwnd, SW_SHOWNORMAL);
78 return hwnd;
79 }
80
81 void Window::SetPainter(Painter* painter) {
82 painter_ = painter;
83 SetWindowLongPtr(window_handle_, GWL_USERDATA,
84 reinterpret_cast<LONG_PTR>(painter_));
85 }
86
87 gfx::PluginWindowHandle Window::PluginWindow() {
88 return window_handle_;
89 }
90
91 void Window::Paint() {
92 ::CallWindowProc(::WindowProc, window_handle_, WM_PAINT, 0, 0);
93 ::InvalidateRect(window_handle_, NULL, FALSE);
94 }
95
96 }
OLDNEW
« media/tools/shader_bench/shader_bench.cc ('K') | « media/tools/shader_bench/window_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698