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

Side by Side Diff: app/gfx/gl/gl_context_linux.cc

Issue 6041002: Implicitly detect the use of --in-process-webgl by the absence of a... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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 | « no previous file | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This file implements the ViewGLContext and PbufferGLContext classes. 5 // This file implements the ViewGLContext and PbufferGLContext classes.
6 6
7 #include "app/gfx/gl/gl_context.h" 7 #include "app/gfx/gl/gl_context.h"
8 8
9 extern "C" {
10 #include <X11/Xlib.h>
11 }
12
9 #include <GL/osmesa.h> 13 #include <GL/osmesa.h>
10 14
11 #include "app/gfx/gl/gl_bindings.h" 15 #include "app/gfx/gl/gl_bindings.h"
12 #include "app/gfx/gl/gl_context_egl.h" 16 #include "app/gfx/gl/gl_context_egl.h"
13 #include "app/gfx/gl/gl_context_osmesa.h" 17 #include "app/gfx/gl/gl_context_osmesa.h"
14 #include "app/gfx/gl/gl_context_stub.h" 18 #include "app/gfx/gl/gl_context_stub.h"
15 #include "app/gfx/gl/gl_implementation.h" 19 #include "app/gfx/gl/gl_implementation.h"
16 #include "app/x11_util.h" 20 #include "app/x11_util.h"
17 #include "base/basictypes.h" 21 #include "base/basictypes.h"
18 #include "base/logging.h" 22 #include "base/logging.h"
19 #include "base/scoped_ptr.h" 23 #include "base/scoped_ptr.h"
20 24
25 namespace {
26
27 Display* GetXDisplayHelper() {
28 static Display* display = NULL;
greggman 2010/12/21 22:47:01 I'll assume this works with multiple display, as i
Ken Russell (switch to Gerrit) 2010/12/21 22:49:59 Not sure. It'll work as well as x11_util::GetXDisp
29
30 if (!display) {
31 if (x11_util::XDisplayExists()) {
32 display = x11_util::GetXDisplay();
33 } else {
34 display = XOpenDisplay(NULL);
35 }
36 }
37 return display;
38 }
39
40 }
41
21 namespace gfx { 42 namespace gfx {
22 43
23 typedef GLXContext GLContextHandle; 44 typedef GLXContext GLContextHandle;
24 typedef GLXPbuffer PbufferHandle; 45 typedef GLXPbuffer PbufferHandle;
25 46
26 class BaseLinuxGLContext : public GLContext { 47 class BaseLinuxGLContext : public GLContext {
27 public: 48 public:
28 virtual std::string GetExtensions(); 49 virtual std::string GetExtensions();
29 }; 50 };
30 51
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 kAllowedGLImplementations, 197 kAllowedGLImplementations,
177 kAllowedGLImplementations + arraysize(kAllowedGLImplementations))) { 198 kAllowedGLImplementations + arraysize(kAllowedGLImplementations))) {
178 LOG(ERROR) << "InitializeBestGLBindings failed."; 199 LOG(ERROR) << "InitializeBestGLBindings failed.";
179 return false; 200 return false;
180 } 201 }
181 202
182 switch (GetGLImplementation()) { 203 switch (GetGLImplementation()) {
183 case kGLImplementationDesktopGL: { 204 case kGLImplementationDesktopGL: {
184 // Only check the GLX version if we are in fact using GLX. We might 205 // Only check the GLX version if we are in fact using GLX. We might
185 // actually be using the mock GL implementation. 206 // actually be using the mock GL implementation.
186 Display* display = x11_util::GetXDisplay(); 207 Display* display = GetXDisplayHelper();
187 int major, minor; 208 int major, minor;
188 if (!glXQueryVersion(display, &major, &minor)) { 209 if (!glXQueryVersion(display, &major, &minor)) {
189 LOG(ERROR) << "glxQueryVersion failed"; 210 LOG(ERROR) << "glxQueryVersion failed";
190 return false; 211 return false;
191 } 212 }
192 213
193 if (major == 1 && minor < 3) { 214 if (major == 1 && minor < 3) {
194 LOG(WARNING) << "GLX 1.3 or later is recommended."; 215 LOG(WARNING) << "GLX 1.3 or later is recommended.";
195 } 216 }
196 217
197 break; 218 break;
198 } 219 }
199 case kGLImplementationEGLGLES2: 220 case kGLImplementationEGLGLES2:
200 if (!BaseEGLContext::InitializeOneOff()) { 221 if (!BaseEGLContext::InitializeOneOff()) {
201 LOG(ERROR) << "BaseEGLContext::InitializeOneOff failed."; 222 LOG(ERROR) << "BaseEGLContext::InitializeOneOff failed.";
202 return false; 223 return false;
203 } 224 }
204 break; 225 break;
205 default: 226 default:
206 break; 227 break;
207 } 228 }
208 229
209 initialized = true; 230 initialized = true;
210 return true; 231 return true;
211 } 232 }
212 233
213 std::string BaseLinuxGLContext::GetExtensions() { 234 std::string BaseLinuxGLContext::GetExtensions() {
214 Display* display = x11_util::GetXDisplay(); 235 Display* display = GetXDisplayHelper();
215 const char* extensions = glXQueryExtensionsString(display, 0); 236 const char* extensions = glXQueryExtensionsString(display, 0);
216 if (extensions) { 237 if (extensions) {
217 return GLContext::GetExtensions() + " " + extensions; 238 return GLContext::GetExtensions() + " " + extensions;
218 } 239 }
219 240
220 return GLContext::GetExtensions(); 241 return GLContext::GetExtensions();
221 } 242 }
222 243
223 bool ViewGLContext::Initialize(bool multisampled) { 244 bool ViewGLContext::Initialize(bool multisampled) {
224 if (multisampled) { 245 if (multisampled) {
225 LOG(WARNING) << "Multisampling not implemented."; 246 LOG(WARNING) << "Multisampling not implemented.";
226 } 247 }
227 248
228 Display* display = x11_util::GetXDisplay(); 249 Display* display = GetXDisplayHelper();
229 XWindowAttributes attributes; 250 XWindowAttributes attributes;
230 XGetWindowAttributes(display, window_, &attributes); 251 XGetWindowAttributes(display, window_, &attributes);
231 XVisualInfo visual_info_template; 252 XVisualInfo visual_info_template;
232 visual_info_template.visualid = XVisualIDFromVisual(attributes.visual); 253 visual_info_template.visualid = XVisualIDFromVisual(attributes.visual);
233 int visual_info_count = 0; 254 int visual_info_count = 0;
234 scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> visual_info_list( 255 scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> visual_info_list(
235 XGetVisualInfo(display, VisualIDMask, 256 XGetVisualInfo(display, VisualIDMask,
236 &visual_info_template, 257 &visual_info_template,
237 &visual_info_count)); 258 &visual_info_count));
238 DCHECK(visual_info_list.get()); 259 DCHECK(visual_info_list.get());
(...skipping 18 matching lines...) Expand all
257 if (!InitializeCommon()) { 278 if (!InitializeCommon()) {
258 LOG(ERROR) << "GLContext::InitlializeCommon failed."; 279 LOG(ERROR) << "GLContext::InitlializeCommon failed.";
259 Destroy(); 280 Destroy();
260 return false; 281 return false;
261 } 282 }
262 283
263 return true; 284 return true;
264 } 285 }
265 286
266 void ViewGLContext::Destroy() { 287 void ViewGLContext::Destroy() {
267 Display* display = x11_util::GetXDisplay(); 288 Display* display = GetXDisplayHelper();
268 bool result = glXMakeCurrent(display, 0, 0); 289 bool result = glXMakeCurrent(display, 0, 0);
269 290
270 // glXMakeCurrent isn't supposed to fail when unsetting the context, unless 291 // glXMakeCurrent isn't supposed to fail when unsetting the context, unless
271 // we have pending draws on an invalid window - which shouldn't be the case 292 // we have pending draws on an invalid window - which shouldn't be the case
272 // here. 293 // here.
273 DCHECK(result); 294 DCHECK(result);
274 if (context_) { 295 if (context_) {
275 glXDestroyContext(display, context_); 296 glXDestroyContext(display, context_);
276 context_ = NULL; 297 context_ = NULL;
277 } 298 }
278 } 299 }
279 300
280 bool ViewGLContext::MakeCurrent() { 301 bool ViewGLContext::MakeCurrent() {
281 if (IsCurrent()) { 302 if (IsCurrent()) {
282 return true; 303 return true;
283 } 304 }
284 305
285 Display* display = x11_util::GetXDisplay(); 306 Display* display = GetXDisplayHelper();
286 if (glXMakeCurrent(display, window_, context_) != True) { 307 if (glXMakeCurrent(display, window_, context_) != True) {
287 glXDestroyContext(display, context_); 308 glXDestroyContext(display, context_);
288 context_ = 0; 309 context_ = 0;
289 LOG(ERROR) << "Couldn't make context current."; 310 LOG(ERROR) << "Couldn't make context current.";
290 return false; 311 return false;
291 } 312 }
292 313
293 return true; 314 return true;
294 } 315 }
295 316
296 bool ViewGLContext::IsCurrent() { 317 bool ViewGLContext::IsCurrent() {
297 return glXGetCurrentDrawable() == window_ && 318 return glXGetCurrentDrawable() == window_ &&
298 glXGetCurrentContext() == context_; 319 glXGetCurrentContext() == context_;
299 } 320 }
300 321
301 bool ViewGLContext::IsOffscreen() { 322 bool ViewGLContext::IsOffscreen() {
302 return false; 323 return false;
303 } 324 }
304 325
305 bool ViewGLContext::SwapBuffers() { 326 bool ViewGLContext::SwapBuffers() {
306 Display* display = x11_util::GetXDisplay(); 327 Display* display = GetXDisplayHelper();
307 glXSwapBuffers(display, window_); 328 glXSwapBuffers(display, window_);
308 return true; 329 return true;
309 } 330 }
310 331
311 gfx::Size ViewGLContext::GetSize() { 332 gfx::Size ViewGLContext::GetSize() {
312 XWindowAttributes attributes; 333 XWindowAttributes attributes;
313 Display* display = x11_util::GetXDisplay(); 334 Display* display = GetXDisplayHelper();
314 XGetWindowAttributes(display, window_, &attributes); 335 XGetWindowAttributes(display, window_, &attributes);
315 return gfx::Size(attributes.width, attributes.height); 336 return gfx::Size(attributes.width, attributes.height);
316 } 337 }
317 338
318 void* ViewGLContext::GetHandle() { 339 void* ViewGLContext::GetHandle() {
319 return context_; 340 return context_;
320 } 341 }
321 342
322 void ViewGLContext::SetSwapInterval(int interval) { 343 void ViewGLContext::SetSwapInterval(int interval) {
323 DCHECK(IsCurrent()); 344 DCHECK(IsCurrent());
324 if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) { 345 if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) {
325 Display* display = x11_util::GetXDisplay(); 346 Display* display = GetXDisplayHelper();
326 glXSwapIntervalEXT(display, window_, interval); 347 glXSwapIntervalEXT(display, window_, interval);
327 } 348 }
328 } 349 }
329 350
330 bool OSMesaViewGLContext::Initialize() { 351 bool OSMesaViewGLContext::Initialize() {
331 if (!osmesa_context_.Initialize(OSMESA_BGRA, NULL)) { 352 if (!osmesa_context_.Initialize(OSMESA_BGRA, NULL)) {
332 LOG(ERROR) << "OSMesaGLContext::Initialize failed."; 353 LOG(ERROR) << "OSMesaGLContext::Initialize failed.";
333 Destroy(); 354 Destroy();
334 return false; 355 return false;
335 } 356 }
336 357
337 window_graphics_context_ = XCreateGC(x11_util::GetXDisplay(), 358 window_graphics_context_ = XCreateGC(GetXDisplayHelper(),
338 window_, 359 window_,
339 0, 360 0,
340 NULL); 361 NULL);
341 if (!window_graphics_context_) { 362 if (!window_graphics_context_) {
342 LOG(ERROR) << "XCreateGC failed."; 363 LOG(ERROR) << "XCreateGC failed.";
343 Destroy(); 364 Destroy();
344 return false; 365 return false;
345 } 366 }
346 367
347 UpdateSize(); 368 UpdateSize();
348 369
349 return true; 370 return true;
350 } 371 }
351 372
352 void OSMesaViewGLContext::Destroy() { 373 void OSMesaViewGLContext::Destroy() {
353 osmesa_context_.Destroy(); 374 osmesa_context_.Destroy();
354 375
355 Display* display = x11_util::GetXDisplay(); 376 Display* display = GetXDisplayHelper();
356 377
357 if (pixmap_graphics_context_) { 378 if (pixmap_graphics_context_) {
358 XFreeGC(display, pixmap_graphics_context_); 379 XFreeGC(display, pixmap_graphics_context_);
359 pixmap_graphics_context_ = NULL; 380 pixmap_graphics_context_ = NULL;
360 } 381 }
361 382
362 if (pixmap_) { 383 if (pixmap_) {
363 XFreePixmap(display, pixmap_); 384 XFreePixmap(display, pixmap_);
364 pixmap_ = 0; 385 pixmap_ = 0;
365 } 386 }
(...skipping 23 matching lines...) Expand all
389 bool OSMesaViewGLContext::SwapBuffers() { 410 bool OSMesaViewGLContext::SwapBuffers() {
390 // Update the size before blitting so that the blit size is exactly the same 411 // Update the size before blitting so that the blit size is exactly the same
391 // as the window. 412 // as the window.
392 if (!UpdateSize()) { 413 if (!UpdateSize()) {
393 LOG(ERROR) << "Failed to update size of OSMesaGLContext."; 414 LOG(ERROR) << "Failed to update size of OSMesaGLContext.";
394 return false; 415 return false;
395 } 416 }
396 417
397 gfx::Size size = osmesa_context_.GetSize(); 418 gfx::Size size = osmesa_context_.GetSize();
398 419
399 Display* display = x11_util::GetXDisplay(); 420 Display* display = GetXDisplayHelper();
400 421
401 // Copy the frame into the pixmap. 422 // Copy the frame into the pixmap.
402 XWindowAttributes attributes; 423 XWindowAttributes attributes;
403 XGetWindowAttributes(display, window_, &attributes); 424 XGetWindowAttributes(display, window_, &attributes);
404 x11_util::PutARGBImage(display, 425 x11_util::PutARGBImage(display,
405 attributes.visual, 426 attributes.visual,
406 attributes.depth, 427 attributes.depth,
407 pixmap_, 428 pixmap_,
408 pixmap_graphics_context_, 429 pixmap_graphics_context_,
409 static_cast<const uint8*>(osmesa_context_.buffer()), 430 static_cast<const uint8*>(osmesa_context_.buffer()),
(...skipping 22 matching lines...) Expand all
432 453
433 void OSMesaViewGLContext::SetSwapInterval(int interval) { 454 void OSMesaViewGLContext::SetSwapInterval(int interval) {
434 DCHECK(IsCurrent()); 455 DCHECK(IsCurrent());
435 // Fail silently. It is legitimate to set the swap interval on a view context 456 // Fail silently. It is legitimate to set the swap interval on a view context
436 // but XLib does not have those semantics. 457 // but XLib does not have those semantics.
437 } 458 }
438 459
439 bool OSMesaViewGLContext::UpdateSize() { 460 bool OSMesaViewGLContext::UpdateSize() {
440 // Get the window size. 461 // Get the window size.
441 XWindowAttributes attributes; 462 XWindowAttributes attributes;
442 Display* display = x11_util::GetXDisplay(); 463 Display* display = GetXDisplayHelper();
443 XGetWindowAttributes(display, window_, &attributes); 464 XGetWindowAttributes(display, window_, &attributes);
444 gfx::Size window_size = gfx::Size(std::max(1, attributes.width), 465 gfx::Size window_size = gfx::Size(std::max(1, attributes.width),
445 std::max(1, attributes.height)); 466 std::max(1, attributes.height));
446 467
447 // Early out if the size has not changed. 468 // Early out if the size has not changed.
448 gfx::Size osmesa_size = osmesa_context_.GetSize(); 469 gfx::Size osmesa_size = osmesa_context_.GetSize();
449 if (pixmap_graphics_context_ && pixmap_ && window_size == osmesa_size) 470 if (pixmap_graphics_context_ && pixmap_ && window_size == osmesa_size)
450 return true; 471 return true;
451 472
452 // Change osmesa surface size to that of window. 473 // Change osmesa surface size to that of window.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 static const int config_attributes[] = { 543 static const int config_attributes[] = {
523 GLX_DRAWABLE_TYPE, 544 GLX_DRAWABLE_TYPE,
524 GLX_PBUFFER_BIT, 545 GLX_PBUFFER_BIT,
525 GLX_RENDER_TYPE, 546 GLX_RENDER_TYPE,
526 GLX_RGBA_BIT, 547 GLX_RGBA_BIT,
527 GLX_DOUBLEBUFFER, 548 GLX_DOUBLEBUFFER,
528 0, 549 0,
529 0 550 0
530 }; 551 };
531 552
532 Display* display = x11_util::GetXDisplay(); 553 Display* display = GetXDisplayHelper();
533 554
534 int nelements = 0; 555 int nelements = 0;
535 // TODO(kbr): figure out whether hardcoding screen to 0 is sufficient. 556 // TODO(kbr): figure out whether hardcoding screen to 0 is sufficient.
536 scoped_ptr_malloc<GLXFBConfig, ScopedPtrXFree> config( 557 scoped_ptr_malloc<GLXFBConfig, ScopedPtrXFree> config(
537 glXChooseFBConfig(display, 0, config_attributes, &nelements)); 558 glXChooseFBConfig(display, 0, config_attributes, &nelements));
538 if (!config.get()) { 559 if (!config.get()) {
539 LOG(ERROR) << "glXChooseFBConfig failed."; 560 LOG(ERROR) << "glXChooseFBConfig failed.";
540 return false; 561 return false;
541 } 562 }
542 if (!nelements) { 563 if (!nelements) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 if (!InitializeCommon()) { 602 if (!InitializeCommon()) {
582 LOG(ERROR) << "GLContext::InitializeCommon failed."; 603 LOG(ERROR) << "GLContext::InitializeCommon failed.";
583 Destroy(); 604 Destroy();
584 return false; 605 return false;
585 } 606 }
586 607
587 return true; 608 return true;
588 } 609 }
589 610
590 void PbufferGLContext::Destroy() { 611 void PbufferGLContext::Destroy() {
591 Display* display = x11_util::GetXDisplay(); 612 Display* display = GetXDisplayHelper();
592 bool result = glXMakeCurrent(display, 0, 0); 613 bool result = glXMakeCurrent(display, 0, 0);
593 // glXMakeCurrent isn't supposed to fail when unsetting the context, unless 614 // glXMakeCurrent isn't supposed to fail when unsetting the context, unless
594 // we have pending draws on an invalid window - which shouldn't be the case 615 // we have pending draws on an invalid window - which shouldn't be the case
595 // here. 616 // here.
596 DCHECK(result); 617 DCHECK(result);
597 if (context_) { 618 if (context_) {
598 glXDestroyContext(display, context_); 619 glXDestroyContext(display, context_);
599 context_ = NULL; 620 context_ = NULL;
600 } 621 }
601 622
602 if (pbuffer_) { 623 if (pbuffer_) {
603 glXDestroyPbuffer(display, pbuffer_); 624 glXDestroyPbuffer(display, pbuffer_);
604 pbuffer_ = 0; 625 pbuffer_ = 0;
605 } 626 }
606 } 627 }
607 628
608 bool PbufferGLContext::MakeCurrent() { 629 bool PbufferGLContext::MakeCurrent() {
609 if (IsCurrent()) { 630 if (IsCurrent()) {
610 return true; 631 return true;
611 } 632 }
612 Display* display = x11_util::GetXDisplay(); 633 Display* display = GetXDisplayHelper();
613 if (glXMakeCurrent(display, pbuffer_, context_) != True) { 634 if (glXMakeCurrent(display, pbuffer_, context_) != True) {
614 glXDestroyContext(display, context_); 635 glXDestroyContext(display, context_);
615 context_ = NULL; 636 context_ = NULL;
616 LOG(ERROR) << "Couldn't make context current."; 637 LOG(ERROR) << "Couldn't make context current.";
617 return false; 638 return false;
618 } 639 }
619 640
620 return true; 641 return true;
621 } 642 }
622 643
(...skipping 26 matching lines...) Expand all
649 } 670 }
650 671
651 bool PixmapGLContext::Initialize(GLContext* shared_context) { 672 bool PixmapGLContext::Initialize(GLContext* shared_context) {
652 VLOG(1) << "GL context: using pixmaps."; 673 VLOG(1) << "GL context: using pixmaps.";
653 674
654 static int attributes[] = { 675 static int attributes[] = {
655 GLX_RGBA, 676 GLX_RGBA,
656 0 677 0
657 }; 678 };
658 679
659 Display* display = x11_util::GetXDisplay(); 680 Display* display = GetXDisplayHelper();
660 int screen = DefaultScreen(display); 681 int screen = DefaultScreen(display);
661 682
662 scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> visual_info( 683 scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> visual_info(
663 glXChooseVisual(display, screen, attributes)); 684 glXChooseVisual(display, screen, attributes));
664 685
665 if (!visual_info.get()) { 686 if (!visual_info.get()) {
666 LOG(ERROR) << "glXChooseVisual failed."; 687 LOG(ERROR) << "glXChooseVisual failed.";
667 return false; 688 return false;
668 } 689 }
669 690
(...skipping 29 matching lines...) Expand all
699 if (!InitializeCommon()) { 720 if (!InitializeCommon()) {
700 LOG(ERROR) << "GLContext::InitializeCommon failed."; 721 LOG(ERROR) << "GLContext::InitializeCommon failed.";
701 Destroy(); 722 Destroy();
702 return false; 723 return false;
703 } 724 }
704 725
705 return true; 726 return true;
706 } 727 }
707 728
708 void PixmapGLContext::Destroy() { 729 void PixmapGLContext::Destroy() {
709 Display* display = x11_util::GetXDisplay(); 730 Display* display = GetXDisplayHelper();
710 bool result = glXMakeCurrent(display, 0, 0); 731 bool result = glXMakeCurrent(display, 0, 0);
711 // glXMakeCurrent isn't supposed to fail when unsetting the context, unless 732 // glXMakeCurrent isn't supposed to fail when unsetting the context, unless
712 // we have pending draws on an invalid window - which shouldn't be the case 733 // we have pending draws on an invalid window - which shouldn't be the case
713 // here. 734 // here.
714 DCHECK(result); 735 DCHECK(result);
715 if (context_) { 736 if (context_) {
716 glXDestroyContext(display, context_); 737 glXDestroyContext(display, context_);
717 context_ = NULL; 738 context_ = NULL;
718 } 739 }
719 740
720 if (glx_pixmap_) { 741 if (glx_pixmap_) {
721 glXDestroyGLXPixmap(display, glx_pixmap_); 742 glXDestroyGLXPixmap(display, glx_pixmap_);
722 glx_pixmap_ = 0; 743 glx_pixmap_ = 0;
723 } 744 }
724 745
725 if (pixmap_) { 746 if (pixmap_) {
726 XFreePixmap(display, pixmap_); 747 XFreePixmap(display, pixmap_);
727 pixmap_ = 0; 748 pixmap_ = 0;
728 } 749 }
729 } 750 }
730 751
731 bool PixmapGLContext::MakeCurrent() { 752 bool PixmapGLContext::MakeCurrent() {
732 if (IsCurrent()) { 753 if (IsCurrent()) {
733 return true; 754 return true;
734 } 755 }
735 Display* display = x11_util::GetXDisplay(); 756 Display* display = GetXDisplayHelper();
736 if (glXMakeCurrent(display, glx_pixmap_, context_) != True) { 757 if (glXMakeCurrent(display, glx_pixmap_, context_) != True) {
737 glXDestroyContext(display, context_); 758 glXDestroyContext(display, context_);
738 context_ = NULL; 759 context_ = NULL;
739 LOG(ERROR) << "Couldn't make context current."; 760 LOG(ERROR) << "Couldn't make context current.";
740 return false; 761 return false;
741 } 762 }
742 763
743 return true; 764 return true;
744 } 765 }
745 766
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 } 822 }
802 case kGLImplementationMockGL: 823 case kGLImplementationMockGL:
803 return new StubGLContext; 824 return new StubGLContext;
804 default: 825 default:
805 NOTREACHED(); 826 NOTREACHED();
806 return NULL; 827 return NULL;
807 } 828 }
808 } 829 }
809 830
810 } // namespace gfx 831 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698