OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "ui/compositor/compositor.h" | 12 #include "ui/compositor/compositor.h" |
13 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 class TestCompositorHostAndroid : public TestCompositorHost { | 17 class TestCompositorHostAndroid : public TestCompositorHost { |
18 public: | 18 public: |
19 TestCompositorHostAndroid(const gfx::Rect& bounds, | 19 TestCompositorHostAndroid(const gfx::Rect& bounds, |
20 ui::ContextFactory* context_factory) { | 20 ui::ContextFactory* context_factory) { |
21 compositor_.reset(new ui::Compositor(context_factory, | 21 compositor_.reset(new ui::Compositor(context_factory, |
22 base::ThreadTaskRunnerHandle::Get())); | 22 base::ThreadTaskRunnerHandle::Get())); |
23 // TODO(sievers): Support onscreen here. | 23 // TODO(sievers): Support onscreen here. |
24 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); | 24 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); |
25 compositor_->SetScaleAndSize(1.0f, | 25 compositor_->SetScaleAndSize(1.0f, |
26 gfx::Size(bounds.width(), bounds.height())); | 26 gfx::Size(bounds.width(), bounds.height())); |
27 } | 27 } |
28 | 28 |
29 // Overridden from TestCompositorHost: | 29 // Overridden from TestCompositorHost: |
30 void Show() override {} | 30 void Show() override { compositor_->SetVisible(true); } |
31 ui::Compositor* GetCompositor() override { return compositor_.get(); } | 31 ui::Compositor* GetCompositor() override { return compositor_.get(); } |
32 | 32 |
33 private: | 33 private: |
34 std::unique_ptr<ui::Compositor> compositor_; | 34 std::unique_ptr<ui::Compositor> compositor_; |
35 | 35 |
36 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostAndroid); | 36 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostAndroid); |
37 }; | 37 }; |
38 | 38 |
39 TestCompositorHost* TestCompositorHost::Create( | 39 TestCompositorHost* TestCompositorHost::Create( |
40 const gfx::Rect& bounds, | 40 const gfx::Rect& bounds, |
41 ui::ContextFactory* context_factory) { | 41 ui::ContextFactory* context_factory) { |
42 return new TestCompositorHostAndroid(bounds, context_factory); | 42 return new TestCompositorHostAndroid(bounds, context_factory); |
43 } | 43 } |
44 | 44 |
45 } // namespace ui | 45 } // namespace ui |
OLD | NEW |