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

Unified Diff: ui/gl/gl_share_group_glx.cc

Issue 2347383002: X11: Use better visuals for OpenGL (Closed)
Patch Set: Fix various tests Created 4 years, 3 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
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

Powered by Google App Engine
This is Rietveld 408576698