summaryrefslogtreecommitdiffstats
path: root/chrome/plugin/command_buffer_stub_win.cc
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-20 00:56:25 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-20 00:56:25 +0000
commitd717e03b637b8bd133db3fde5f3108b999a51a88 (patch)
treeaca70991012a49441d24bbd201d894903ba05416 /chrome/plugin/command_buffer_stub_win.cc
parent5fe524efcaf51b401067d936b5ff331249dc99df (diff)
downloadchromium_src-d717e03b637b8bd133db3fde5f3108b999a51a88.zip
chromium_src-d717e03b637b8bd133db3fde5f3108b999a51a88.tar.gz
chromium_src-d717e03b637b8bd133db3fde5f3108b999a51a88.tar.bz2
GPU plugin forwards repaint events to Pepper plugin.
WM_PAINT results in a call to Pepper repaint callback. Implemented WM_ERASEBKGND to prevent flickering on repaint. Implemented PGL_NO_CONTEXT (copied from EGL spec). This is already reviewed by alokp but unfortunately got entangled with this CL. TEST=none BUG=none Review URL: http://codereview.chromium.org/571018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39530 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/command_buffer_stub_win.cc')
-rw-r--r--chrome/plugin/command_buffer_stub_win.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/chrome/plugin/command_buffer_stub_win.cc b/chrome/plugin/command_buffer_stub_win.cc
new file mode 100644
index 0000000..656bbd1
--- /dev/null
+++ b/chrome/plugin/command_buffer_stub_win.cc
@@ -0,0 +1,78 @@
+// 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 <windows.h>
+
+#include "chrome/common/command_buffer_messages.h"
+#include "chrome/plugin/command_buffer_stub.h"
+
+namespace {
+const wchar_t* kPreviousWndProcProperty = L"CommandBufferStubPrevWndProc";
+const wchar_t* kCommandBufferStubProperty = L"CommandBufferStub";
+
+// Message handler for the GPU plugin's child window. Used to intercept
+// WM_PAINT events and forward repaint notifications to the client.
+LRESULT WINAPI WndProc(HWND handle,
+ UINT message,
+ WPARAM w_param,
+ LPARAM l_param) {
+ WNDPROC previous_wnd_proc = reinterpret_cast<WNDPROC>(
+ ::GetProp(handle, kPreviousWndProcProperty));
+ CommandBufferStub* stub = reinterpret_cast<CommandBufferStub*>(
+ ::GetProp(handle, kCommandBufferStubProperty));
+
+ switch (message) {
+ case WM_ERASEBKGND:
+ // Do not clear background. Avoids flickering.
+ return 1;
+ case WM_PAINT:
+ // Validate the whole window to prevent another WM_PAINT message.
+ ValidateRect(handle, NULL);
+
+ // Notify client that the window is invalid and needs to be repainted.
+ stub->NotifyRepaint();
+
+ return 1;
+ default:
+ return CallWindowProc(previous_wnd_proc,
+ handle,
+ message,
+ w_param,
+ l_param);
+ }
+}
+} // namespace anonymous
+
+void CommandBufferStub::NotifyRepaint() {
+ Send(new CommandBufferMsg_NotifyRepaint(route_id_));
+}
+
+bool CommandBufferStub::InitializePlatformSpecific() {
+ // Subclass window.
+ WNDPROC previous_wnd_proc = reinterpret_cast<WNDPROC>(
+ ::GetWindowLongPtr(window_, GWLP_WNDPROC));
+ ::SetProp(window_,
+ kPreviousWndProcProperty,
+ reinterpret_cast<HANDLE>(previous_wnd_proc));
+ ::SetWindowLongPtr(window_,
+ GWLP_WNDPROC,
+ reinterpret_cast<LONG_PTR>(WndProc));
+
+ // Record pointer to this in window.
+ ::SetProp(window_,
+ kCommandBufferStubProperty,
+ reinterpret_cast<HANDLE>(this));
+
+ return true;
+}
+
+void CommandBufferStub::DestroyPlatformSpecific() {
+ // Restore window.
+ WNDPROC previous_wnd_proc = reinterpret_cast<WNDPROC>(
+ ::GetProp(window_, kPreviousWndProcProperty));
+ ::SetWindowLongPtr(window_, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(
+ previous_wnd_proc));
+ ::RemoveProp(window_, kPreviousWndProcProperty);
+ ::RemoveProp(window_, kCommandBufferStubProperty);
+}