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

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

Issue 24127004: Disable child X window workaround when running in test harnesses that do (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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 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) 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_surface_glx.h" 9 #include "ui/gl/gl_surface_glx.h"
10 10
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 354 }
355 355
356 typedef std::map<gfx::AcceleratedWidget, gfx::AcceleratedWidget> WindowMap; 356 typedef std::map<gfx::AcceleratedWidget, gfx::AcceleratedWidget> WindowMap;
357 WindowMap child_to_parent_map_; 357 WindowMap child_to_parent_map_;
358 358
359 DISALLOW_COPY_AND_ASSIGN(XExposeEventForwarder); 359 DISALLOW_COPY_AND_ASSIGN(XExposeEventForwarder);
360 }; 360 };
361 361
362 static base::LazyInstance<XExposeEventForwarder> g_xexpose_event_forwarder = 362 static base::LazyInstance<XExposeEventForwarder> g_xexpose_event_forwarder =
363 LAZY_INSTANCE_INITIALIZER; 363 LAZY_INSTANCE_INITIALIZER;
364
365 // Do not use this workaround when running in test harnesses that do not have
366 // a message loop or do not have a TYPE_GPU message loop.
367 bool g_create_child_windows = false;
364 #endif 368 #endif
365 369
366 } // namespace 370 } // namespace
367 371
368 GLSurfaceGLX::GLSurfaceGLX() {} 372 GLSurfaceGLX::GLSurfaceGLX() {}
369 373
370 bool GLSurfaceGLX::InitializeOneOff() { 374 bool GLSurfaceGLX::InitializeOneOff() {
371 static bool initialized = false; 375 static bool initialized = false;
372 if (initialized) 376 if (initialized)
373 return true; 377 return true;
374 378
375 // http://crbug.com/245466 379 // http://crbug.com/245466
376 setenv("force_s3tc_enable", "true", 1); 380 setenv("force_s3tc_enable", "true", 1);
377 381
378 // SGIVideoSyncProviderShim (if instantiated) will issue X commands on 382 // SGIVideoSyncProviderShim (if instantiated) will issue X commands on
379 // it's own thread. 383 // it's own thread.
380 XInitThreads(); 384 XInitThreads();
381 385
382 #if defined(TOOLKIT_GTK) 386 #if defined(TOOLKIT_GTK)
383 // Be sure to use the X display handle and not the GTK display handle if this 387 // Be sure to use the X display handle and not the GTK display handle if this
384 // is the GPU process. 388 // is the GPU process.
385 if (base::MessageLoop::current()->type() == base::MessageLoop::TYPE_GPU) 389 g_create_child_windows =
390 base::MessageLoop::current() &&
391 base::MessageLoop::current()->type() == base::MessageLoop::TYPE_GPU;
392
393 if (g_create_child_windows)
386 g_display = base::MessagePumpX11::GetDefaultXDisplay(); 394 g_display = base::MessagePumpX11::GetDefaultXDisplay();
387 else 395 else
388 g_display = base::MessagePumpForUI::GetDefaultXDisplay(); 396 g_display = base::MessagePumpForUI::GetDefaultXDisplay();
389 #else 397 #else
390 g_display = base::MessagePumpForUI::GetDefaultXDisplay(); 398 g_display = base::MessagePumpForUI::GetDefaultXDisplay();
391 #endif 399 #endif
392 400
393 if (!g_display) { 401 if (!g_display) {
394 LOG(ERROR) << "XOpenDisplay failed."; 402 LOG(ERROR) << "XOpenDisplay failed.";
395 return false; 403 return false;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 AdjustBufferAllocation(); 476 AdjustBufferAllocation();
469 return true; 477 return true;
470 } 478 }
471 479
472 void NativeViewGLSurfaceGLX::SetFrontbufferAllocation(bool allocated) { 480 void NativeViewGLSurfaceGLX::SetFrontbufferAllocation(bool allocated) {
473 frontbuffer_allocated_ = allocated; 481 frontbuffer_allocated_ = allocated;
474 AdjustBufferAllocation(); 482 AdjustBufferAllocation();
475 } 483 }
476 484
477 void NativeViewGLSurfaceGLX::AdjustBufferAllocation() { 485 void NativeViewGLSurfaceGLX::AdjustBufferAllocation() {
486 if (!g_create_child_windows)
487 return;
488
478 if (frontbuffer_allocated_ || backbuffer_allocated_) 489 if (frontbuffer_allocated_ || backbuffer_allocated_)
479 CreateChildWindow(); 490 CreateChildWindow();
480 else 491 else
481 DestroyChildWindow(); 492 DestroyChildWindow();
482 } 493 }
483 494
484 void NativeViewGLSurfaceGLX::CreateChildWindow() { 495 void NativeViewGLSurfaceGLX::CreateChildWindow() {
496 DCHECK(g_create_child_windows);
497
485 if (child_window_) 498 if (child_window_)
486 return; 499 return;
487 500
488 XSetWindowAttributes set_window_attributes; 501 XSetWindowAttributes set_window_attributes;
489 set_window_attributes.event_mask = ExposureMask; 502 set_window_attributes.event_mask = ExposureMask;
490 child_window_ = XCreateWindow( 503 child_window_ = XCreateWindow(
491 g_display, parent_window_, 0, 0, size_.width(), size_.height(), 0, 504 g_display, parent_window_, 0, 0, size_.width(), size_.height(), 0,
492 CopyFromParent, InputOutput, CopyFromParent, CWEventMask, 505 CopyFromParent, InputOutput, CopyFromParent, CWEventMask,
493 &set_window_attributes); 506 &set_window_attributes);
494 g_xexpose_event_forwarder.Pointer()->AddParentChildPair( 507 g_xexpose_event_forwarder.Pointer()->AddParentChildPair(
(...skipping 21 matching lines...) Expand all
516 child_window_(0), 529 child_window_(0),
517 dummy_window_(0), 530 dummy_window_(0),
518 backbuffer_allocated_(true), 531 backbuffer_allocated_(true),
519 frontbuffer_allocated_(true), 532 frontbuffer_allocated_(true),
520 #endif 533 #endif
521 config_(NULL) { 534 config_(NULL) {
522 } 535 }
523 536
524 gfx::AcceleratedWidget NativeViewGLSurfaceGLX::GetDrawableHandle() const { 537 gfx::AcceleratedWidget NativeViewGLSurfaceGLX::GetDrawableHandle() const {
525 #if defined(TOOLKIT_GTK) 538 #if defined(TOOLKIT_GTK)
526 if (child_window_) 539 if (g_create_child_windows) {
527 return child_window_; 540 if (child_window_)
528 return dummy_window_; 541 return child_window_;
529 #else 542 return dummy_window_;
543 }
544 #endif
530 return parent_window_; 545 return parent_window_;
531 #endif
532 } 546 }
533 547
534 bool NativeViewGLSurfaceGLX::Initialize() { 548 bool NativeViewGLSurfaceGLX::Initialize() {
535 XWindowAttributes attributes; 549 XWindowAttributes attributes;
536 if (!XGetWindowAttributes(g_display, parent_window_, &attributes)) { 550 if (!XGetWindowAttributes(g_display, parent_window_, &attributes)) {
537 LOG(ERROR) << "XGetWindowAttributes failed for window " << parent_window_ 551 LOG(ERROR) << "XGetWindowAttributes failed for window " << parent_window_
538 << "."; 552 << ".";
539 return false; 553 return false;
540 } 554 }
541 size_ = gfx::Size(attributes.width, attributes.height); 555 size_ = gfx::Size(attributes.width, attributes.height);
542 556
543 gfx::AcceleratedWidget window_for_vsync = parent_window_; 557 gfx::AcceleratedWidget window_for_vsync = parent_window_;
544 558
545 #if defined(TOOLKIT_GTK) 559 #if defined(TOOLKIT_GTK)
546 dummy_window_ = XCreateWindow( 560 if (g_create_child_windows) {
547 g_display, 561 dummy_window_ = XCreateWindow(
548 RootWindow(g_display, XScreenNumberOfScreen(attributes.screen)), 562 g_display,
549 0, 0, 1, 1, 0, CopyFromParent, InputOutput, attributes.visual, 0, NULL); 563 RootWindow(g_display, XScreenNumberOfScreen(attributes.screen)),
550 window_for_vsync = dummy_window_; 564 0, 0, 1, 1, 0, CopyFromParent, InputOutput, attributes.visual, 0, NULL);
551 CreateChildWindow(); 565 window_for_vsync = dummy_window_;
566 CreateChildWindow();
567 }
552 #endif 568 #endif
553 569
554 if (g_glx_oml_sync_control_supported) 570 if (g_glx_oml_sync_control_supported)
555 vsync_provider_.reset(new OMLSyncControlVSyncProvider(window_for_vsync)); 571 vsync_provider_.reset(new OMLSyncControlVSyncProvider(window_for_vsync));
556 else if (g_glx_sgi_video_sync_supported) 572 else if (g_glx_sgi_video_sync_supported)
557 vsync_provider_.reset(new SGIVideoSyncVSyncProvider(window_for_vsync)); 573 vsync_provider_.reset(new SGIVideoSyncVSyncProvider(window_for_vsync));
558 574
559 return true; 575 return true;
560 } 576 }
561 577
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 791
776 void* PbufferGLSurfaceGLX::GetConfig() { 792 void* PbufferGLSurfaceGLX::GetConfig() {
777 return config_; 793 return config_;
778 } 794 }
779 795
780 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { 796 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() {
781 Destroy(); 797 Destroy();
782 } 798 }
783 799
784 } // namespace gfx 800 } // 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