Roll src/third_party/skia 591a2ca:b3fe1b8
[chromium-blink-merge.git] / ui / compositor / test / test_compositor_host_ozone.cc
blobaed3f2179fb3f4c79607566e03b849f429a2ed82
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"
8 #include "base/bind.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/thread_task_runner_handle.h"
14 #include "ui/compositor/compositor.h"
15 #include "ui/gfx/geometry/rect.h"
17 namespace ui {
19 class TestCompositorHostOzone : public TestCompositorHost {
20 public:
21 TestCompositorHostOzone(const gfx::Rect& bounds,
22 ui::ContextFactory* context_factory);
23 ~TestCompositorHostOzone() override;
25 private:
26 // Overridden from TestCompositorHost:
27 void Show() override;
28 ui::Compositor* GetCompositor() override;
30 gfx::Rect bounds_;
32 ui::ContextFactory* context_factory_;
34 scoped_ptr<ui::Compositor> compositor_;
36 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostOzone);
39 TestCompositorHostOzone::TestCompositorHostOzone(
40 const gfx::Rect& bounds,
41 ui::ContextFactory* context_factory)
42 : bounds_(bounds),
43 context_factory_(context_factory) {}
45 TestCompositorHostOzone::~TestCompositorHostOzone() {}
47 void TestCompositorHostOzone::Show() {
48 // Ozone should rightly have a backing native framebuffer
49 // An in-memory array draw into by OSMesa is a reasonble
50 // fascimile of a dumb framebuffer at present.
51 // GLSurface will allocate the array so long as it is provided
52 // with a non-0 widget.
53 // TODO(rjkroege): Use a "real" ozone widget when it is
54 // available: http://crbug.com/255128
55 compositor_.reset(new ui::Compositor(1,
56 context_factory_,
57 base::ThreadTaskRunnerHandle::Get()));
58 compositor_->SetScaleAndSize(1.0f, bounds_.size());
61 ui::Compositor* TestCompositorHostOzone::GetCompositor() {
62 return compositor_.get();
65 // static
66 TestCompositorHost* TestCompositorHost::Create(
67 const gfx::Rect& bounds,
68 ui::ContextFactory* context_factory) {
69 return new TestCompositorHostOzone(bounds, context_factory);
72 } // namespace ui