| Index: ui/gl/gl_share_group_glx.cc
|
| diff --git a/ui/gl/gl_share_group_glx.cc b/ui/gl/gl_share_group_glx.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..89ccaba7f4543d350d78881e9aca2ced40a55877
|
| --- /dev/null
|
| +++ b/ui/gl/gl_share_group_glx.cc
|
| @@ -0,0 +1,46 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/gl/gl_share_group_glx.h"
|
| +
|
| +#include "ui/gl/gl_bindings.h"
|
| +#include "ui/gl/gl_context.h"
|
| +#include "ui/gl/gl_surface_glx.h"
|
| +
|
| +namespace gl {
|
| +
|
| +namespace {
|
| +
|
| +int GetFBConfigID(GLSurface* compatible) {
|
| + GLSurfaceGLX* surface = static_cast<GLSurfaceGLX*>(compatible);
|
| + XDisplay* display = static_cast<XDisplay*>(surface->GetDisplay());
|
| + GLXFBConfig config = static_cast<GLXFBConfig>(surface->GetConfig());
|
| + int fbconfig_id = 0;
|
| + int err = glXGetFBConfigAttrib(display, config, GLX_VISUAL_ID, &fbconfig_id);
|
| + DCHECK(!err);
|
| + return fbconfig_id;
|
| +}
|
| +
|
| +} // anonymous namespace
|
| +
|
| +GLShareGroupGLX::GLShareGroupGLX() {}
|
| +GLShareGroupGLX::~GLShareGroupGLX() {}
|
| +
|
| +void GLShareGroupGLX::SetSharedContext(GLSurface* compatible,
|
| + GLContext* context) {
|
| + shared_contexts_[GetFBConfigID(compatible)] = context->GetWeakPtr();
|
| +}
|
| +
|
| +GLContext* GLShareGroupGLX::GetSharedContext(GLSurface* compatible) {
|
| + int fbconfig_id = GetFBConfigID(compatible);
|
| + auto it = shared_contexts_.find(fbconfig_id);
|
| + if (it == shared_contexts_.end())
|
| + return nullptr;
|
| + GLContext* context = shared_contexts_[fbconfig_id].get();
|
| + if (context == nullptr)
|
| + shared_contexts_.erase(it);
|
| + return context;
|
| +}
|
| +
|
| +} // namespace gl
|
|
|