OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "ui/gl/gl_share_group_glx.h" |
| 6 |
| 7 #include "ui/gl/gl_bindings.h" |
| 8 #include "ui/gl/gl_context.h" |
| 9 #include "ui/gl/gl_surface_glx.h" |
| 10 |
| 11 namespace gl { |
| 12 |
| 13 namespace { |
| 14 |
| 15 int GetFBConfigID(GLSurface* compatible) { |
| 16 GLSurfaceGLX* surface = static_cast<GLSurfaceGLX*>(compatible); |
| 17 XDisplay* display = static_cast<XDisplay*>(surface->GetDisplay()); |
| 18 GLXFBConfig config = static_cast<GLXFBConfig>(surface->GetConfig()); |
| 19 int fbconfig_id = 0; |
| 20 int err = glXGetFBConfigAttrib(display, config, GLX_VISUAL_ID, &fbconfig_id); |
| 21 DCHECK(!err); |
| 22 return fbconfig_id; |
| 23 } |
| 24 |
| 25 } // anonymous namespace |
| 26 |
| 27 GLShareGroupGLX::GLShareGroupGLX() {} |
| 28 GLShareGroupGLX::~GLShareGroupGLX() {} |
| 29 |
| 30 void GLShareGroupGLX::SetSharedContext(GLSurface* compatible, |
| 31 GLContext* context) { |
| 32 shared_contexts_[GetFBConfigID(compatible)] = context->GetWeakPtr(); |
| 33 } |
| 34 |
| 35 GLContext* GLShareGroupGLX::GetSharedContext(GLSurface* compatible) { |
| 36 int fbconfig_id = GetFBConfigID(compatible); |
| 37 auto it = shared_contexts_.find(fbconfig_id); |
| 38 if (it == shared_contexts_.end()) |
| 39 return nullptr; |
| 40 GLContext* context = shared_contexts_[fbconfig_id].get(); |
| 41 if (context == nullptr) |
| 42 shared_contexts_.erase(it); |
| 43 return context; |
| 44 } |
| 45 |
| 46 } // namespace gl |
OLD | NEW |