| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2008 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 <windows.h> | |
| 6 | |
| 7 #include "gpu/command_buffer/service/gpu_processor.h" | |
| 8 #include "gpu/gpu_plugin/gpu_plugin_object.h" | |
| 9 | |
| 10 namespace gpu_plugin { | |
| 11 | |
| 12 namespace { | |
| 13 const LPCTSTR kPluginObjectProperty = TEXT("GPUPluginObject"); | |
| 14 const LPCTSTR kOriginalWindowProc = TEXT("GPUPluginObjectOriginalWindowProc"); | |
| 15 | |
| 16 LRESULT CALLBACK WindowProc(HWND handle, | |
| 17 UINT message, | |
| 18 WPARAM w_param, | |
| 19 LPARAM l_param) { | |
| 20 return ::DefWindowProc(handle, message, w_param, l_param); | |
| 21 } | |
| 22 } // namespace anonymous | |
| 23 | |
| 24 NPError GPUPluginObject::PlatformSpecificSetWindow(NPWindow* new_window) { | |
| 25 // Detach properties from old window and restore the original window proc. | |
| 26 if (window_.window) { | |
| 27 HWND handle = reinterpret_cast<HWND>(window_.window); | |
| 28 ::RemoveProp(handle, kPluginObjectProperty); | |
| 29 | |
| 30 LONG original_window_proc = reinterpret_cast<LONG>( | |
| 31 ::GetProp(handle, kOriginalWindowProc)); | |
| 32 ::SetWindowLong(handle, GWL_WNDPROC, | |
| 33 original_window_proc); | |
| 34 ::RemoveProp(handle, kOriginalWindowProc); | |
| 35 } | |
| 36 | |
| 37 // Attach properties to new window and set a new window proc. | |
| 38 if (new_window->window) { | |
| 39 HWND handle = reinterpret_cast<HWND>(new_window->window); | |
| 40 ::SetProp(handle, | |
| 41 kPluginObjectProperty, | |
| 42 reinterpret_cast<HANDLE>(this)); | |
| 43 | |
| 44 LONG original_window_proc = ::GetWindowLong(handle, GWL_WNDPROC); | |
| 45 ::SetProp(handle, | |
| 46 kOriginalWindowProc, | |
| 47 reinterpret_cast<HANDLE>(original_window_proc)); | |
| 48 ::SetWindowLong(handle, GWL_WNDPROC, | |
| 49 reinterpret_cast<LONG>(WindowProc)); | |
| 50 | |
| 51 status_ = kWaitingForOpenCommandBuffer; | |
| 52 } else { | |
| 53 status_ = kWaitingForSetWindow; | |
| 54 if (processor_) { | |
| 55 processor_->Destroy(); | |
| 56 } | |
| 57 } | |
| 58 | |
| 59 return NPERR_NO_ERROR; | |
| 60 } | |
| 61 | |
| 62 } // namespace gpu_plugin | |
| OLD | NEW |