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

Unified Diff: chrome/gpu/gpu_command_buffer_stub.cc

Issue 4815001: Use inner HWND for accelerated rendering on windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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: chrome/gpu/gpu_command_buffer_stub.cc
===================================================================
--- chrome/gpu/gpu_command_buffer_stub.cc (revision 66779)
+++ chrome/gpu/gpu_command_buffer_stub.cc (working copy)
@@ -14,6 +14,8 @@
using gpu::Buffer;
+#define kCompositorWindowOwner L"kCompositorWindowOwner"
apatrick_chromium 2010/11/19 23:09:51 nit: make this const wchar_t[]
nduca 2010/11/20 00:28:49 Other code that does this follows the define patte
+
GpuCommandBufferStub::GpuCommandBufferStub(
GpuChannel* channel,
gfx::PluginWindowHandle handle,
@@ -38,10 +40,113 @@
render_view_id_(render_view_id) {
}
+#if defined(OS_WIN)
+static LRESULT CALLBACK CompositorWindowProc(
+ HWND hwnd,
+ UINT message,
+ WPARAM wparam,
+ LPARAM lparam) {
+ switch (message) {
+ case WM_ERASEBKGND:
+ return 0;
+ case WM_DESTROY:
+ return 0;
+ case WM_PAINT: {
+ PAINTSTRUCT paint;
+ BeginPaint(hwnd, &paint);
apatrick_chromium 2010/11/19 23:09:51 Check this doesn't return null and don't call EndP
nduca 2010/11/20 00:28:49 Done.
+ HANDLE h = GetProp(hwnd, kCompositorWindowOwner);
apatrick_chromium 2010/11/19 23:09:51 Check this does not return null before calling OnC
nduca 2010/11/20 00:28:49 Done.
+ GpuCommandBufferStub* stub = reinterpret_cast<GpuCommandBufferStub*>(h);
+ stub->OnCompositorWindowPainted();
+ EndPaint(hwnd, &paint);
+ break;
+ }
+ default:
+ return DefWindowProc(hwnd, message, wparam, lparam);
+ }
+ return 0;
+}
+
+void GpuCommandBufferStub::CreateCompositorWindow() {
+ DCHECK(handle_ != gfx::kNullPluginWindow);
+
+ // Ask the browser to create the the host window.
+ ChildThread* gpu_thread = ChildThread::current();
apatrick_chromium 2010/11/19 23:09:51 nit: add a pointer from GpuCommandBufferStub to Gp
nduca 2010/11/20 00:28:49 I don't see why that would affect this call. Are y
+ gfx::PluginWindowHandle host_window_id;
+ gpu_thread->Send(new GpuHostMsg_CreateCompositorHostWindow(
+ renderer_id_,
+ render_view_id_,
+ &host_window_id));
+ HWND host_window = static_cast<HWND>(host_window_id);
apatrick_chromium 2010/11/19 23:09:51 If Send fails, host_window_id will be uninitialize
nduca 2010/11/20 00:28:49 If send fails, it means browser is dead. We're ter
+
+ // Create the compositor window itself.
+ DCHECK(host_window);
+ static ATOM window_class = 0;
+ if (!window_class) {
+ WNDCLASSEX wcex;
+ wcex.cbSize = sizeof(wcex);
+ wcex.style = 0;
+ wcex.lpfnWndProc = CompositorWindowProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = GetModuleHandle(NULL);
+ wcex.hIcon = 0;
+ wcex.hCursor = 0;
+ wcex.hbrBackground = NULL;
+ wcex.lpszMenuName = 0;
+ wcex.lpszClassName = L"CompositorWindowClass";
+ wcex.hIconSm = 0;
+ window_class = RegisterClassEx(&wcex);
+ DCHECK(window_class);
+ }
+
+ HWND compositor_window = CreateWindowEx(
+ WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
+ MAKEINTATOM(window_class),
+ 0,
+ WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED,
+ 0, 0,
+ 0, 0,
+ host_window,
+ 0,
+ GetModuleHandle(NULL),
+ 0);
+ DCHECK(compositor_window);
apatrick_chromium 2010/11/19 23:09:51 I think this might legitimately fail. It might be
nduca 2010/11/20 00:28:49 Done.
+ SetProp(compositor_window, kCompositorWindowOwner,
+ reinterpret_cast<HANDLE>(this));
+
+ RECT parent_rect;
+ GetClientRect(host_window, &parent_rect);
apatrick_chromium 2010/11/19 23:09:51 If the host window is destroyed for any reason, th
nduca 2010/11/20 00:28:49 Done.
+
+ UINT flags = SWP_NOSENDCHANGING | SWP_NOCOPYBITS | SWP_NOZORDER |
+ SWP_NOACTIVATE | SWP_DEFERERASE | SWP_SHOWWINDOW;
+ SetWindowPos(compositor_window,
apatrick_chromium 2010/11/19 23:09:51 nit: can you drop this argument to the next line a
+ NULL,
+ 0, 0,
+ parent_rect.right - parent_rect.left,
+ parent_rect.bottom - parent_rect.top,
+ flags);
+ compositor_window_ = static_cast<gfx::PluginWindowHandle>(compositor_window);
+}
+
+void GpuCommandBufferStub::OnCompositorWindowPainted() {
+ ChildThread* gpu_thread = ChildThread::current();
apatrick_chromium 2010/11/19 23:09:51 See comment about GpuThread above.
nduca 2010/11/20 00:28:49 Not sold on this being necessary.
+ gpu_thread->Send(new GpuHostMsg_ScheduleComposite(
+ renderer_id_, render_view_id_));
+}
+#endif // defined(OS_WIN)
+
+
GpuCommandBufferStub::~GpuCommandBufferStub() {
if (processor_.get()) {
processor_->Destroy();
}
+#if defined(OS_WIN)
+ if (compositor_window_) {
+ RemoveProp(compositor_window_, kCompositorWindowOwner);
+ DestroyWindow(static_cast<HWND>(compositor_window_));
+ compositor_window_ = NULL;
+ }
+#endif
}
void GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
@@ -79,6 +184,14 @@
command_buffer_.reset(new gpu::CommandBufferService);
+ // Create the child window, if needed
+#if defined(OS_WIN)
+ CreateCompositorWindow();
apatrick_chromium 2010/11/19 23:09:51 Check if this fails.
nduca 2010/11/20 00:28:49 Done.
+ gfx::PluginWindowHandle output_window_handle = compositor_window_;
+#else
+ gfx::PluginWindowHandle output_window_handle = handle_;
+#endif
+
// Initialize the CommandBufferService and GPUProcessor.
if (command_buffer_->Initialize(size)) {
Buffer buffer = command_buffer_->GetRingBuffer();
@@ -87,7 +200,7 @@
parent_ ? parent_->processor_.get() : NULL;
processor_.reset(new gpu::GPUProcessor(command_buffer_.get(), NULL));
if (processor_->Initialize(
- handle_,
+ output_window_handle,
initial_size_,
allowed_extensions_.c_str(),
requested_attribs_,

Powered by Google App Engine
This is Rietveld 408576698