Index: ui/gl/gl_surface_wgl.cc |
diff --git a/ui/gl/gl_surface_wgl.cc b/ui/gl/gl_surface_wgl.cc |
index 23391eada1e3cf3be59f3898530261dd9bf30404..690f4f42f18fecb4706460df32388c66edf55bba 100644 |
--- a/ui/gl/gl_surface_wgl.cc |
+++ b/ui/gl/gl_surface_wgl.cc |
@@ -176,7 +176,6 @@ HDC GLSurfaceWGL::GetDisplayDC() { |
NativeViewGLSurfaceWGL::NativeViewGLSurfaceWGL(gfx::AcceleratedWidget window) |
: window_(window), |
- child_window_(NULL), |
device_context_(NULL) { |
DCHECK(window); |
} |
@@ -188,34 +187,16 @@ NativeViewGLSurfaceWGL::~NativeViewGLSurfaceWGL() { |
bool NativeViewGLSurfaceWGL::Initialize() { |
DCHECK(!device_context_); |
- RECT rect; |
- if (!GetClientRect(window_, &rect)) { |
- LOG(ERROR) << "GetClientRect failed.\n"; |
- Destroy(); |
- return false; |
- } |
- |
- // Create a child window. WGL has problems using a window handle owned by |
- // another process. |
- child_window_ = CreateWindow( |
- reinterpret_cast<wchar_t*>(g_display->window_class()), |
- L"", |
- WS_CHILDWINDOW | WS_DISABLED | WS_VISIBLE, |
- 0, 0, |
- rect.right - rect.left, |
- rect.bottom - rect.top, |
- window_, |
- NULL, |
- NULL, |
- NULL); |
- if (!child_window_) { |
- LOG(ERROR) << "CreateWindow failed.\n"; |
+ DWORD process_id; |
+ GetWindowThreadProcessId(window_, &process_id); |
+ if (process_id != GetCurrentProcessId()) { |
+ LOG(ERROR) << "Can't use window created in " << process_id |
+ << " with wgl in " << GetCurrentProcessId(); |
Destroy(); |
return false; |
} |
- // The GL context will render to this window. |
- device_context_ = GetDC(child_window_); |
+ device_context_ = GetDC(window_); |
if (!device_context_) { |
LOG(ERROR) << "Unable to get device context for window."; |
Destroy(); |
@@ -234,13 +215,9 @@ bool NativeViewGLSurfaceWGL::Initialize() { |
} |
void NativeViewGLSurfaceWGL::Destroy() { |
- if (child_window_ && device_context_) |
- ReleaseDC(child_window_, device_context_); |
- |
- if (child_window_) |
- DestroyWindow(child_window_); |
+ if (window_ && device_context_) |
+ ReleaseDC(window_, device_context_); |
- child_window_ = NULL; |
device_context_ = NULL; |
} |
@@ -253,26 +230,13 @@ bool NativeViewGLSurfaceWGL::SwapBuffers() { |
"width", GetSize().width(), |
"height", GetSize().height()); |
- // Resize the child window to match the parent before swapping. Do not repaint |
- // it as it moves. |
- RECT rect; |
- if (!GetClientRect(window_, &rect)) |
- return false; |
- if (!MoveWindow(child_window_, |
- 0, 0, |
- rect.right - rect.left, |
- rect.bottom - rect.top, |
- FALSE)) { |
- return false; |
- } |
- |
DCHECK(device_context_); |
return ::SwapBuffers(device_context_) == TRUE; |
} |
gfx::Size NativeViewGLSurfaceWGL::GetSize() { |
RECT rect; |
- BOOL result = GetClientRect(child_window_, &rect); |
+ BOOL result = GetClientRect(window_, &rect); |
DCHECK(result); |
return gfx::Size(rect.right - rect.left, rect.bottom - rect.top); |
} |