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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: media/tools/shader_bench/window_win.cc
diff --git a/media/tools/shader_bench/window_win.cc b/media/tools/shader_bench/window_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ab8a4bbab4889458eca0a6f1b0adecd744cd35a1
--- /dev/null
+++ b/media/tools/shader_bench/window_win.cc
@@ -0,0 +1,96 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/tools/shader_bench/window.h"
+
+#include "base/utf_string_conversions.h"
+
+namespace {
+
+LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg,
+ WPARAM w_param, LPARAM l_param) {
+ LRESULT result = 0;
+ switch (msg) {
+ case WM_CLOSE:
+ ::DestroyWindow(hwnd);
+ break;
+ case WM_DESTROY:
+ ::PostQuitMessage(0);
+ break;
+ case WM_ERASEBKGND:
+ // Return a non-zero value to indicate that the background has been
+ // erased.
+ result = 1;
+ break;
+ case WM_PAINT: {
+ Painter* painter =
+ reinterpret_cast<Painter*>(GetWindowLongPtr(hwnd, GWL_USERDATA));
+ if (painter != NULL) painter->OnPaint();
+ ::ValidateRect(hwnd, NULL);
+ break;
+ }
+ default:
+ result = ::DefWindowProc(hwnd, msg, w_param, l_param);
+ break;
+ }
+ return result;
+}
+
+} // namespace.
Alpha Left Google 2010/11/15 20:43:51 just // namespace
+
+namespace media {
+
+gfx::NativeWindow Window::CreateNativeWindow(int width, int height) {
+ WNDCLASS wnd_class = {0};
+ HINSTANCE instance = GetModuleHandle(NULL);
+ wnd_class.style = CS_OWNDC;
+ wnd_class.lpfnWndProc = WindowProc;
+ wnd_class.hInstance = instance;
+ wnd_class.hbrBackground =
+ reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH));
+ wnd_class.lpszClassName = L"gpu_demo";
+ if (!RegisterClass(&wnd_class)) return NULL;
+
+ DWORD wnd_style = WS_OVERLAPPED | WS_SYSMENU;
+ RECT wnd_rect;
+ wnd_rect.left = 0;
+ wnd_rect.top = 0;
+ wnd_rect.right = width;
+ wnd_rect.bottom = height;
+ AdjustWindowRect(&wnd_rect, wnd_style, FALSE);
+
+ HWND hwnd = CreateWindow(
+ wnd_class.lpszClassName,
+ L"",
+ wnd_style,
+ 0,
+ 0,
+ wnd_rect.right - wnd_rect.left,
+ wnd_rect.bottom - wnd_rect.top,
+ NULL,
+ NULL,
+ instance,
+ NULL);
+ if (hwnd == NULL) return NULL;
+
+ ShowWindow(hwnd, SW_SHOWNORMAL);
+ return hwnd;
+}
+
+void Window::SetPainter(Painter* painter) {
+ painter_ = painter;
+ SetWindowLongPtr(window_handle_, GWL_USERDATA,
+ reinterpret_cast<LONG_PTR>(painter_));
+}
+
+gfx::PluginWindowHandle Window::PluginWindow() {
+ return window_handle_;
+}
+
+void Window::Paint() {
+ ::CallWindowProc(::WindowProc, window_handle_, WM_PAINT, 0, 0);
+ ::InvalidateRect(window_handle_, NULL, FALSE);
+}
+
+}
« 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