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
3 // found in the LICENSE file.
5 #include "ui/compositor/test/test_compositor_host.h"
7 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop/message_loop.h"
14 #include "ui/compositor/compositor.h"
15 #include "ui/gfx/rect.h"
19 class TestCompositorHostOzone
: public TestCompositorHost
{
21 TestCompositorHostOzone(const gfx::Rect
& bounds
);
22 virtual ~TestCompositorHostOzone();
25 // Overridden from TestCompositorHost:
26 virtual void Show() OVERRIDE
;
27 virtual ui::Compositor
* GetCompositor() OVERRIDE
;
33 scoped_ptr
<ui::Compositor
> compositor_
;
35 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostOzone
);
38 TestCompositorHostOzone::TestCompositorHostOzone(const gfx::Rect
& bounds
)
41 TestCompositorHostOzone::~TestCompositorHostOzone() {}
43 void TestCompositorHostOzone::Show() {
44 // Ozone should rightly have a backing native framebuffer
45 // An in-memory array draw into by OSMesa is a reasonble
46 // fascimile of a dumb framebuffer at present.
47 // GLSurface will allocate the array so long as it is provided
48 // with a non-0 widget.
49 // TODO(rjkroege): Use a "real" ozone widget when it is
50 // available: http://crbug.com/255128
51 compositor_
.reset(new ui::Compositor(1));
52 compositor_
->SetScaleAndSize(1.0f
, bounds_
.size());
55 ui::Compositor
* TestCompositorHostOzone::GetCompositor() {
56 return compositor_
.get();
59 void TestCompositorHostOzone::Draw() {
60 if (compositor_
.get())
65 TestCompositorHost
* TestCompositorHost::Create(const gfx::Rect
& bounds
) {
66 return new TestCompositorHostOzone(bounds
);