| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "ui/compositor/test/test_compositor_host.h" | 5 #include "ui/compositor/test/test_compositor_host.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "ui/base/x/x11_window_event_manager.h" | 17 #include "ui/base/x/x11_window_event_manager.h" |
| 18 #include "ui/compositor/compositor.h" | 18 #include "ui/compositor/compositor.h" |
| 19 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 20 #include "ui/gfx/x/x11_types.h" | 20 #include "ui/gfx/x/x11_types.h" |
| 21 | 21 |
| 22 namespace ui { | 22 namespace ui { |
| 23 | 23 |
| 24 class TestCompositorHostX11 : public TestCompositorHost { | 24 class TestCompositorHostX11 : public TestCompositorHost { |
| 25 public: | 25 public: |
| 26 TestCompositorHostX11(const gfx::Rect& bounds, | 26 TestCompositorHostX11(const gfx::Rect& bounds, |
| 27 ui::ContextFactory* context_factory); | 27 ui::ContextFactory* context_factory, |
| 28 ui::ContextFactoryPrivate* context_factory_private); |
| 28 ~TestCompositorHostX11() override; | 29 ~TestCompositorHostX11() override; |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 // Overridden from TestCompositorHost: | 32 // Overridden from TestCompositorHost: |
| 32 void Show() override; | 33 void Show() override; |
| 33 ui::Compositor* GetCompositor() override; | 34 ui::Compositor* GetCompositor() override; |
| 34 | 35 |
| 35 gfx::Rect bounds_; | 36 gfx::Rect bounds_; |
| 36 | 37 |
| 37 ui::ContextFactory* context_factory_; | 38 ui::ContextFactory* context_factory_; |
| 39 ui::ContextFactoryPrivate* context_factory_private_; |
| 38 | 40 |
| 39 ui::Compositor compositor_; | 41 ui::Compositor compositor_; |
| 40 | 42 |
| 41 XID window_; | 43 XID window_; |
| 42 | 44 |
| 43 std::unique_ptr<XScopedEventSelector> window_events_; | 45 std::unique_ptr<XScopedEventSelector> window_events_; |
| 44 | 46 |
| 45 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostX11); | 47 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostX11); |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 TestCompositorHostX11::TestCompositorHostX11( | 50 TestCompositorHostX11::TestCompositorHostX11( |
| 49 const gfx::Rect& bounds, | 51 const gfx::Rect& bounds, |
| 50 ui::ContextFactory* context_factory) | 52 ui::ContextFactory* context_factory, |
| 53 ui::ContextFactoryPrivate* context_factory_private) |
| 51 : bounds_(bounds), | 54 : bounds_(bounds), |
| 52 context_factory_(context_factory), | 55 context_factory_(context_factory), |
| 53 compositor_(context_factory_, base::ThreadTaskRunnerHandle::Get()) {} | 56 context_factory_private_(context_factory_private), |
| 57 compositor_(context_factory_, |
| 58 context_factory_private_, |
| 59 base::ThreadTaskRunnerHandle::Get()) {} |
| 54 | 60 |
| 55 TestCompositorHostX11::~TestCompositorHostX11() {} | 61 TestCompositorHostX11::~TestCompositorHostX11() {} |
| 56 | 62 |
| 57 void TestCompositorHostX11::Show() { | 63 void TestCompositorHostX11::Show() { |
| 58 XDisplay* display = gfx::GetXDisplay(); | 64 XDisplay* display = gfx::GetXDisplay(); |
| 59 XSetWindowAttributes swa; | 65 XSetWindowAttributes swa; |
| 60 swa.override_redirect = True; | 66 swa.override_redirect = True; |
| 61 window_ = XCreateWindow( | 67 window_ = XCreateWindow( |
| 62 display, | 68 display, |
| 63 RootWindow(display, DefaultScreen(display)), // parent | 69 RootWindow(display, DefaultScreen(display)), // parent |
| (...skipping 18 matching lines...) Expand all Loading... |
| 82 compositor_.SetVisible(true); | 88 compositor_.SetVisible(true); |
| 83 } | 89 } |
| 84 | 90 |
| 85 ui::Compositor* TestCompositorHostX11::GetCompositor() { | 91 ui::Compositor* TestCompositorHostX11::GetCompositor() { |
| 86 return &compositor_; | 92 return &compositor_; |
| 87 } | 93 } |
| 88 | 94 |
| 89 // static | 95 // static |
| 90 TestCompositorHost* TestCompositorHost::Create( | 96 TestCompositorHost* TestCompositorHost::Create( |
| 91 const gfx::Rect& bounds, | 97 const gfx::Rect& bounds, |
| 92 ui::ContextFactory* context_factory) { | 98 ui::ContextFactory* context_factory, |
| 93 return new TestCompositorHostX11(bounds, context_factory); | 99 ui::ContextFactoryPrivate* context_factory_private) { |
| 100 return new TestCompositorHostX11(bounds, context_factory, |
| 101 context_factory_private); |
| 94 } | 102 } |
| 95 | 103 |
| 96 } // namespace ui | 104 } // namespace ui |
| OLD | NEW |