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