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

Unified Diff: ui/gl/gl_surface_wgl.cc

Issue 649863002: Don't create child window for WGL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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
« no previous file with comments | « ui/gl/gl_surface_wgl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « ui/gl/gl_surface_wgl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698