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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "ui/compositor/compositor.h" | 15 #include "ui/compositor/compositor.h" |
16 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
17 | 17 |
18 namespace ui { | 18 namespace ui { |
19 | 19 |
20 class TestCompositorHostOzone : public TestCompositorHost { | 20 class TestCompositorHostOzone : public TestCompositorHost { |
21 public: | 21 public: |
22 TestCompositorHostOzone(const gfx::Rect& bounds, | 22 TestCompositorHostOzone(const gfx::Rect& bounds, |
23 ui::ContextFactory* context_factory); | 23 ui::ContextFactory* context_factory, |
| 24 ui::ContextFactoryPrivate* context_factory_private); |
24 ~TestCompositorHostOzone() override; | 25 ~TestCompositorHostOzone() override; |
25 | 26 |
26 private: | 27 private: |
27 // Overridden from TestCompositorHost: | 28 // Overridden from TestCompositorHost: |
28 void Show() override; | 29 void Show() override; |
29 ui::Compositor* GetCompositor() override; | 30 ui::Compositor* GetCompositor() override; |
30 | 31 |
31 gfx::Rect bounds_; | 32 gfx::Rect bounds_; |
32 | 33 |
33 ui::Compositor compositor_; | 34 ui::Compositor compositor_; |
34 | 35 |
35 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostOzone); | 36 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostOzone); |
36 }; | 37 }; |
37 | 38 |
38 TestCompositorHostOzone::TestCompositorHostOzone( | 39 TestCompositorHostOzone::TestCompositorHostOzone( |
39 const gfx::Rect& bounds, | 40 const gfx::Rect& bounds, |
40 ui::ContextFactory* context_factory) | 41 ui::ContextFactory* context_factory, |
| 42 ui::ContextFactoryPrivate* context_factory_private) |
41 : bounds_(bounds), | 43 : bounds_(bounds), |
42 compositor_(context_factory, base::ThreadTaskRunnerHandle::Get()) {} | 44 compositor_(context_factory, |
| 45 context_factory_private, |
| 46 base::ThreadTaskRunnerHandle::Get()) {} |
43 | 47 |
44 TestCompositorHostOzone::~TestCompositorHostOzone() {} | 48 TestCompositorHostOzone::~TestCompositorHostOzone() {} |
45 | 49 |
46 void TestCompositorHostOzone::Show() { | 50 void TestCompositorHostOzone::Show() { |
47 // Ozone should rightly have a backing native framebuffer | 51 // Ozone should rightly have a backing native framebuffer |
48 // An in-memory array draw into by OSMesa is a reasonble | 52 // An in-memory array draw into by OSMesa is a reasonble |
49 // fascimile of a dumb framebuffer at present. | 53 // fascimile of a dumb framebuffer at present. |
50 // GLSurface will allocate the array so long as it is provided | 54 // GLSurface will allocate the array so long as it is provided |
51 // with a non-0 widget. | 55 // with a non-0 widget. |
52 // TODO(rjkroege): Use a "real" ozone widget when it is | 56 // TODO(rjkroege): Use a "real" ozone widget when it is |
53 // available: http://crbug.com/255128 | 57 // available: http://crbug.com/255128 |
54 compositor_.SetAcceleratedWidget(1); | 58 compositor_.SetAcceleratedWidget(1); |
55 compositor_.SetScaleAndSize(1.0f, bounds_.size()); | 59 compositor_.SetScaleAndSize(1.0f, bounds_.size()); |
56 compositor_.SetVisible(true); | 60 compositor_.SetVisible(true); |
57 } | 61 } |
58 | 62 |
59 ui::Compositor* TestCompositorHostOzone::GetCompositor() { | 63 ui::Compositor* TestCompositorHostOzone::GetCompositor() { |
60 return &compositor_; | 64 return &compositor_; |
61 } | 65 } |
62 | 66 |
63 // static | 67 // static |
64 TestCompositorHost* TestCompositorHost::Create( | 68 TestCompositorHost* TestCompositorHost::Create( |
65 const gfx::Rect& bounds, | 69 const gfx::Rect& bounds, |
66 ui::ContextFactory* context_factory) { | 70 ui::ContextFactory* context_factory, |
67 return new TestCompositorHostOzone(bounds, context_factory); | 71 ui::ContextFactoryPrivate* context_factory_private) { |
| 72 return new TestCompositorHostOzone(bounds, context_factory, |
| 73 context_factory_private); |
68 } | 74 } |
69 | 75 |
70 } // namespace ui | 76 } // namespace ui |
OLD | NEW |