Chromium Code Reviews| Index: ui/gfx/gl/gl_context_glx.cc |
| =================================================================== |
| --- ui/gfx/gl/gl_context_glx.cc (revision 85357) |
| +++ ui/gfx/gl/gl_context_glx.cc (working copy) |
| @@ -33,9 +33,8 @@ |
| } // namespace anonymous |
| -GLContextGLX::GLContextGLX(GLSurfaceGLX* surface) |
| - : surface_(surface), |
| - context_(NULL) { |
| +GLContextGLX::GLContextGLX() |
| + : context_(NULL) { |
| } |
| GLContextGLX::~GLContextGLX() { |
| @@ -45,7 +44,7 @@ |
| bool GLContextGLX::Initialize(GLContext* shared_context) { |
| context_ = glXCreateNewContext( |
| GLSurfaceGLX::GetDisplay(), |
| - static_cast<GLXFBConfig>(surface_->GetConfig()), |
| + static_cast<GLXFBConfig>(NULL /* TODO: fix */), |
|
Alexey Marinichev
2011/05/17 20:20:54
Nvidia driver segfaults on this. No good!
|
| GLX_RGBA_TYPE, |
| static_cast<GLXContext>( |
| shared_context ? shared_context->GetHandle() : NULL), |
| @@ -67,15 +66,15 @@ |
| } |
| } |
| -bool GLContextGLX::MakeCurrent() { |
| - if (IsCurrent()) { |
| +bool GLContextGLX::MakeCurrent(GLSurface* surface) { |
| + DCHECK(context_); |
| + if (IsCurrent(surface)) |
| return true; |
| - } |
| if (!glXMakeContextCurrent( |
| GLSurfaceGLX::GetDisplay(), |
| - reinterpret_cast<GLXDrawable>(surface_->GetHandle()), |
| - reinterpret_cast<GLXDrawable>(surface_->GetHandle()), |
| + reinterpret_cast<GLXDrawable>(surface->GetHandle()), |
| + reinterpret_cast<GLXDrawable>(surface->GetHandle()), |
| static_cast<GLXContext>(context_))) { |
| Destroy(); |
| LOG(ERROR) << "Couldn't make context current."; |
| @@ -85,27 +84,25 @@ |
| return true; |
| } |
| -bool GLContextGLX::IsCurrent() { |
| - // TODO(apatrick): When surface is split from context, cannot use surface_ |
| - // here. |
| - return glXGetCurrentDrawable() == |
| - reinterpret_cast<GLXDrawable>(surface_->GetHandle()) && |
| - glXGetCurrentContext() == static_cast<GLXContext>(context_); |
| -} |
| +void GLContextGLX::ReleaseCurrent(GLSurface* surface) { |
| + if (!IsCurrent(surface)) |
| + return; |
| -bool GLContextGLX::IsOffscreen() { |
| - // TODO(apatrick): remove this from GLContext interface. |
| - return surface_->IsOffscreen(); |
| + glXMakeContextCurrent(GLSurfaceGLX::GetDisplay(), 0, 0, NULL); |
| } |
| -bool GLContextGLX::SwapBuffers() { |
| - // TODO(apatrick): remove this from GLContext interface. |
| - return surface_->SwapBuffers(); |
| -} |
| +bool GLContextGLX::IsCurrent(GLSurface* surface) { |
| + if (glXGetCurrentContext() == static_cast<GLXContext>(context_)) |
| + return false; |
| -gfx::Size GLContextGLX::GetSize() { |
| - // TODO(apatrick): remove this from GLContext interface. |
| - return surface_->GetSize(); |
| + if (surface) { |
| + if (glXGetCurrentDrawable() != |
| + reinterpret_cast<GLXDrawable>(surface->GetHandle())) { |
| + return false; |
| + } |
| + } |
| + |
| + return true; |
| } |
| void* GLContextGLX::GetHandle() { |
| @@ -113,7 +110,7 @@ |
| } |
| void GLContextGLX::SetSwapInterval(int interval) { |
| - DCHECK(IsCurrent()); |
| + DCHECK(IsCurrent(NULL)); |
| if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) { |
| // Only enable vsync if we aren't using a compositing window |
| // manager. At the moment, compositing window managers don't |
| @@ -122,14 +119,14 @@ |
| if (!IsCompositingWindowManagerActive(GLSurfaceGLX::GetDisplay())) { |
| glXSwapIntervalEXT( |
| GLSurfaceGLX::GetDisplay(), |
| - reinterpret_cast<GLXDrawable>(surface_->GetHandle()), |
| + glXGetCurrentDrawable(), |
| interval); |
| } |
| } |
| } |
| std::string GLContextGLX::GetExtensions() { |
| - DCHECK(IsCurrent()); |
| + DCHECK(IsCurrent(NULL)); |
| const char* extensions = glXQueryExtensionsString( |
| GLSurfaceGLX::GetDisplay(), |
| 0); |