| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 ui::ContextFactory* context_factory); | 23 ui::ContextFactory* context_factory); |
| 24 ~TestCompositorHostOzone() override; | 24 ~TestCompositorHostOzone() override; |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 // Overridden from TestCompositorHost: | 27 // Overridden from TestCompositorHost: |
| 28 void Show() override; | 28 void Show() override; |
| 29 ui::Compositor* GetCompositor() override; | 29 ui::Compositor* GetCompositor() override; |
| 30 | 30 |
| 31 gfx::Rect bounds_; | 31 gfx::Rect bounds_; |
| 32 | 32 |
| 33 ui::ContextFactory* context_factory_; | |
| 34 | |
| 35 ui::Compositor compositor_; | 33 ui::Compositor compositor_; |
| 36 | 34 |
| 37 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostOzone); | 35 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostOzone); |
| 38 }; | 36 }; |
| 39 | 37 |
| 40 TestCompositorHostOzone::TestCompositorHostOzone( | 38 TestCompositorHostOzone::TestCompositorHostOzone( |
| 41 const gfx::Rect& bounds, | 39 const gfx::Rect& bounds, |
| 42 ui::ContextFactory* context_factory) | 40 ui::ContextFactory* context_factory) |
| 43 : bounds_(bounds), | 41 : bounds_(bounds), |
| 44 context_factory_(context_factory), | |
| 45 compositor_(context_factory, base::ThreadTaskRunnerHandle::Get()) {} | 42 compositor_(context_factory, base::ThreadTaskRunnerHandle::Get()) {} |
| 46 | 43 |
| 47 TestCompositorHostOzone::~TestCompositorHostOzone() {} | 44 TestCompositorHostOzone::~TestCompositorHostOzone() {} |
| 48 | 45 |
| 49 void TestCompositorHostOzone::Show() { | 46 void TestCompositorHostOzone::Show() { |
| 50 // Ozone should rightly have a backing native framebuffer | 47 // Ozone should rightly have a backing native framebuffer |
| 51 // An in-memory array draw into by OSMesa is a reasonble | 48 // An in-memory array draw into by OSMesa is a reasonble |
| 52 // fascimile of a dumb framebuffer at present. | 49 // fascimile of a dumb framebuffer at present. |
| 53 // GLSurface will allocate the array so long as it is provided | 50 // GLSurface will allocate the array so long as it is provided |
| 54 // with a non-0 widget. | 51 // with a non-0 widget. |
| 55 // TODO(rjkroege): Use a "real" ozone widget when it is | 52 // TODO(rjkroege): Use a "real" ozone widget when it is |
| 56 // available: http://crbug.com/255128 | 53 // available: http://crbug.com/255128 |
| 57 compositor_.SetAcceleratedWidget(1); | 54 compositor_.SetAcceleratedWidget(1); |
| 58 compositor_.SetScaleAndSize(1.0f, bounds_.size()); | 55 compositor_.SetScaleAndSize(1.0f, bounds_.size()); |
| 59 } | 56 } |
| 60 | 57 |
| 61 ui::Compositor* TestCompositorHostOzone::GetCompositor() { | 58 ui::Compositor* TestCompositorHostOzone::GetCompositor() { |
| 62 return &compositor_; | 59 return &compositor_; |
| 63 } | 60 } |
| 64 | 61 |
| 65 // static | 62 // static |
| 66 TestCompositorHost* TestCompositorHost::Create( | 63 TestCompositorHost* TestCompositorHost::Create( |
| 67 const gfx::Rect& bounds, | 64 const gfx::Rect& bounds, |
| 68 ui::ContextFactory* context_factory) { | 65 ui::ContextFactory* context_factory) { |
| 69 return new TestCompositorHostOzone(bounds, context_factory); | 66 return new TestCompositorHostOzone(bounds, context_factory); |
| 70 } | 67 } |
| 71 | 68 |
| 72 } // namespace ui | 69 } // namespace ui |
| OLD | NEW |