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

Side by Side Diff: ui/gl/gl_context_glx.cc

Issue 15928002: GPU: Keep track of the last real context and real surface made current. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nix unnecessary changes. Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gl/gl_context_glx.h ('k') | ui/gl/gl_context_nsview.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 extern "C" { 5 extern "C" {
6 #include <X11/Xlib.h> 6 #include <X11/Xlib.h>
7 } 7 }
8 8
9 #include "ui/gl/gl_context_glx.h" 9 #include "ui/gl/gl_context_glx.h"
10 10
(...skipping 16 matching lines...) Expand all
27 class ScopedPtrXFree { 27 class ScopedPtrXFree {
28 public: 28 public:
29 void operator()(void* x) const { 29 void operator()(void* x) const {
30 ::XFree(x); 30 ::XFree(x);
31 } 31 }
32 }; 32 };
33 33
34 } // namespace 34 } // namespace
35 35
36 GLContextGLX::GLContextGLX(GLShareGroup* share_group) 36 GLContextGLX::GLContextGLX(GLShareGroup* share_group)
37 : GLContext(share_group), 37 : GLContextReal(share_group),
38 context_(NULL), 38 context_(NULL),
39 display_(NULL) { 39 display_(NULL) {
40 } 40 }
41 41
42 Display* GLContextGLX::display() { 42 Display* GLContextGLX::display() {
43 return display_; 43 return display_;
44 } 44 }
45 45
46 bool GLContextGLX::Initialize( 46 bool GLContextGLX::Initialize(
47 GLSurface* compatible_surface, GpuPreference gpu_preference) { 47 GLSurface* compatible_surface, GpuPreference gpu_preference) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (!glXMakeContextCurrent( 116 if (!glXMakeContextCurrent(
117 display_, 117 display_,
118 reinterpret_cast<GLXDrawable>(surface->GetHandle()), 118 reinterpret_cast<GLXDrawable>(surface->GetHandle()),
119 reinterpret_cast<GLXDrawable>(surface->GetHandle()), 119 reinterpret_cast<GLXDrawable>(surface->GetHandle()),
120 static_cast<GLXContext>(context_))) { 120 static_cast<GLXContext>(context_))) {
121 LOG(ERROR) << "Couldn't make context current with X drawable."; 121 LOG(ERROR) << "Couldn't make context current with X drawable.";
122 Destroy(); 122 Destroy();
123 return false; 123 return false;
124 } 124 }
125 125
126 SetCurrent(this, surface); 126 SetCurrent(surface);
127 if (!InitializeExtensionBindings()) { 127 if (!InitializeExtensionBindings()) {
128 ReleaseCurrent(surface); 128 ReleaseCurrent(surface);
129 Destroy(); 129 Destroy();
130 return false; 130 return false;
131 } 131 }
132 132
133 if (!surface->OnMakeCurrent(this)) { 133 if (!surface->OnMakeCurrent(this)) {
134 LOG(ERROR) << "Could not make current."; 134 LOG(ERROR) << "Could not make current.";
135 ReleaseCurrent(surface); 135 ReleaseCurrent(surface);
136 Destroy(); 136 Destroy();
137 return false; 137 return false;
138 } 138 }
139 139
140 SetRealGLApi(); 140 SetRealGLApi();
141 return true; 141 return true;
142 } 142 }
143 143
144 void GLContextGLX::ReleaseCurrent(GLSurface* surface) { 144 void GLContextGLX::ReleaseCurrent(GLSurface* surface) {
145 if (!IsCurrent(surface)) 145 if (!IsCurrent(surface))
146 return; 146 return;
147 147
148 SetCurrent(NULL, NULL); 148 SetCurrent(NULL);
149 if (!glXMakeContextCurrent(display_, 0, 0, 0)) 149 if (!glXMakeContextCurrent(display_, 0, 0, 0))
150 LOG(ERROR) << "glXMakeCurrent failed in ReleaseCurrent"; 150 LOG(ERROR) << "glXMakeCurrent failed in ReleaseCurrent";
151 } 151 }
152 152
153 bool GLContextGLX::IsCurrent(GLSurface* surface) { 153 bool GLContextGLX::IsCurrent(GLSurface* surface) {
154 bool native_context_is_current = 154 bool native_context_is_current =
155 glXGetCurrentContext() == static_cast<GLXContext>(context_); 155 glXGetCurrentContext() == static_cast<GLXContext>(context_);
156 156
157 // If our context is current then our notion of which GLContext is 157 // If our context is current then our notion of which GLContext is
158 // current must be correct. On the other hand, third-party code 158 // current must be correct. On the other hand, third-party code
159 // using OpenGL might change the current context. 159 // using OpenGL might change the current context.
160 DCHECK(!native_context_is_current || (GetCurrent() == this)); 160 DCHECK(!native_context_is_current || (GetRealCurrent() == this));
161 161
162 if (!native_context_is_current) 162 if (!native_context_is_current)
163 return false; 163 return false;
164 164
165 if (surface) { 165 if (surface) {
166 if (glXGetCurrentDrawable() != 166 if (glXGetCurrentDrawable() !=
167 reinterpret_cast<GLXDrawable>(surface->GetHandle())) { 167 reinterpret_cast<GLXDrawable>(surface->GetHandle())) {
168 return false; 168 return false;
169 } 169 }
170 } 170 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 bool GLContextGLX::WasAllocatedUsingRobustnessExtension() { 220 bool GLContextGLX::WasAllocatedUsingRobustnessExtension() {
221 return GLSurfaceGLX::IsCreateContextRobustnessSupported(); 221 return GLSurfaceGLX::IsCreateContextRobustnessSupported();
222 } 222 }
223 223
224 GLContextGLX::~GLContextGLX() { 224 GLContextGLX::~GLContextGLX() {
225 Destroy(); 225 Destroy();
226 } 226 }
227 227
228 } // namespace gfx 228 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context_glx.h ('k') | ui/gl/gl_context_nsview.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698