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

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

Issue 299143002: glx: forward Expose event from child window to parent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 6 years, 7 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
« content/gpu/gpu_main.cc ('K') | « ui/gl/gl_surface_glx.h ('k') | 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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/synchronization/cancellation_flag.h" 18 #include "base/synchronization/cancellation_flag.h"
19 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
20 #include "base/threading/non_thread_safe.h" 20 #include "base/threading/non_thread_safe.h"
21 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
22 #include "base/time/time.h" 22 #include "base/time/time.h"
23 #include "third_party/mesa/src/include/GL/osmesa.h" 23 #include "third_party/mesa/src/include/GL/osmesa.h"
24 #include "ui/events/platform/platform_event_source.h"
24 #include "ui/gfx/x/x11_connection.h" 25 #include "ui/gfx/x/x11_connection.h"
25 #include "ui/gfx/x/x11_types.h" 26 #include "ui/gfx/x/x11_types.h"
26 #include "ui/gl/gl_bindings.h" 27 #include "ui/gl/gl_bindings.h"
27 #include "ui/gl/gl_implementation.h" 28 #include "ui/gl/gl_implementation.h"
28 #include "ui/gl/sync_control_vsync_provider.h" 29 #include "ui/gl/sync_control_vsync_provider.h"
29 30
30 namespace gfx { 31 namespace gfx {
31 32
32 namespace { 33 namespace {
33 34
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 size_.width(), 419 size_.width(),
419 size_.height(), 420 size_.height(),
420 0, 421 0,
421 CopyFromParent, 422 CopyFromParent,
422 InputOutput, 423 InputOutput,
423 CopyFromParent, 424 CopyFromParent,
424 0, 425 0,
425 NULL); 426 NULL);
426 XMapWindow(g_display, window_); 427 XMapWindow(g_display, window_);
427 428
429 ui::PlatformEventSource* event_source =
430 ui::PlatformEventSource::GetInstance();
431 // Can be NULL in tests, when we don't care about Exposes.
432 if (event_source) {
433 XSelectInput(g_display, window_, ExposureMask);
434 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
435 }
436 XFlush(g_display);
ccameron 2014/05/23 09:12:00 I was wondering if this would be needed, looks lik
piman 2014/05/23 10:09:48 I suppose it'll be kinda implicit at the next resi
437
428 gfx::AcceleratedWidget window_for_vsync = window_; 438 gfx::AcceleratedWidget window_for_vsync = window_;
429 439
430 if (g_glx_oml_sync_control_supported) 440 if (g_glx_oml_sync_control_supported)
431 vsync_provider_.reset(new OMLSyncControlVSyncProvider(window_for_vsync)); 441 vsync_provider_.reset(new OMLSyncControlVSyncProvider(window_for_vsync));
432 else if (g_glx_sgi_video_sync_supported) 442 else if (g_glx_sgi_video_sync_supported)
433 vsync_provider_.reset(new SGIVideoSyncVSyncProvider(window_for_vsync)); 443 vsync_provider_.reset(new SGIVideoSyncVSyncProvider(window_for_vsync));
434 444
435 return true; 445 return true;
436 } 446 }
437 447
438 void NativeViewGLSurfaceGLX::Destroy() { 448 void NativeViewGLSurfaceGLX::Destroy() {
439 if (window_) { 449 if (window_) {
450 ui::PlatformEventSource* event_source =
451 ui::PlatformEventSource::GetInstance();
452 if (event_source)
453 event_source->RemovePlatformEventDispatcher(this);
440 XDestroyWindow(g_display, window_); 454 XDestroyWindow(g_display, window_);
441 XFlush(g_display); 455 XFlush(g_display);
442 } 456 }
443 } 457 }
444 458
459 bool NativeViewGLSurfaceGLX::CanDispatchEvent(const ui::PlatformEvent& event) {
460 return event->type == Expose && event->xexpose.window == window_;
461 }
462
463 uint32_t NativeViewGLSurfaceGLX::DispatchEvent(const ui::PlatformEvent& event) {
464 XEvent forwarded_event = *event;
465 forwarded_event.xexpose.window = parent_window_;
466 XSendEvent(g_display, parent_window_, False, ExposureMask,
467 &forwarded_event);
468 XFlush(g_display);
469 return ui::POST_DISPATCH_STOP_PROPAGATION;
ccameron 2014/05/23 09:12:00 In the previous incarnation of this, we did a CONT
piman 2014/05/23 10:09:48 At this point this is the only class that cares ab
470 }
471
445 bool NativeViewGLSurfaceGLX::Resize(const gfx::Size& size) { 472 bool NativeViewGLSurfaceGLX::Resize(const gfx::Size& size) {
446 size_ = size; 473 size_ = size;
447 glXWaitGL(); 474 glXWaitGL();
448 XResizeWindow(g_display, window_, size.width(), size.height()); 475 XResizeWindow(g_display, window_, size.width(), size.height());
449 glXWaitX(); 476 glXWaitX();
450 return true; 477 return true;
451 } 478 }
452 479
453 bool NativeViewGLSurfaceGLX::IsOffscreen() { 480 bool NativeViewGLSurfaceGLX::IsOffscreen() {
454 return false; 481 return false;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 int x, int y, int width, int height) { 567 int x, int y, int width, int height) {
541 DCHECK(gfx::g_driver_glx.ext.b_GLX_MESA_copy_sub_buffer); 568 DCHECK(gfx::g_driver_glx.ext.b_GLX_MESA_copy_sub_buffer);
542 glXCopySubBufferMESA(g_display, GetDrawableHandle(), x, y, width, height); 569 glXCopySubBufferMESA(g_display, GetDrawableHandle(), x, y, width, height);
543 return true; 570 return true;
544 } 571 }
545 572
546 VSyncProvider* NativeViewGLSurfaceGLX::GetVSyncProvider() { 573 VSyncProvider* NativeViewGLSurfaceGLX::GetVSyncProvider() {
547 return vsync_provider_.get(); 574 return vsync_provider_.get();
548 } 575 }
549 576
550 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX()
551 : parent_window_(0),
552 window_(0),
553 config_(NULL) {
554 }
555
556 NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() { 577 NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() {
557 Destroy(); 578 Destroy();
558 } 579 }
559 580
560 PbufferGLSurfaceGLX::PbufferGLSurfaceGLX(const gfx::Size& size) 581 PbufferGLSurfaceGLX::PbufferGLSurfaceGLX(const gfx::Size& size)
561 : size_(size), 582 : size_(size),
562 config_(NULL), 583 config_(NULL),
563 pbuffer_(0) { 584 pbuffer_(0) {
564 } 585 }
565 586
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 661
641 void* PbufferGLSurfaceGLX::GetConfig() { 662 void* PbufferGLSurfaceGLX::GetConfig() {
642 return config_; 663 return config_;
643 } 664 }
644 665
645 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { 666 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() {
646 Destroy(); 667 Destroy();
647 } 668 }
648 669
649 } // namespace gfx 670 } // namespace gfx
OLDNEW
« content/gpu/gpu_main.cc ('K') | « ui/gl/gl_surface_glx.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698