Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: ui/compositor/test/test_compositor_host_ozone.cc

Issue 17932004: Support ozone=1 compositor_unittests with OSMesa (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added missed files Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 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.
4
5 #include "ui/compositor/test/test_compositor_host.h"
6
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/message_loop.h"
14 #include "ui/compositor/compositor.h"
15 #include "ui/gfx/rect.h"
16
17 namespace ui {
18
19 class TestCompositorHostOzone : public TestCompositorHost,
20 public CompositorDelegate {
21 public:
22 TestCompositorHostOzone(const gfx::Rect& bounds);
23 virtual ~TestCompositorHostOzone();
24
25 private:
26 // Overridden from TestCompositorHost:
27 virtual void Show() OVERRIDE;
28 virtual ui::Compositor* GetCompositor() OVERRIDE;
29
30 // Overridden from CompositorDelegate:
31 virtual void ScheduleDraw() OVERRIDE;
32
33 void Draw();
34
35 gfx::Rect bounds_;
36
37 scoped_ptr<ui::Compositor> compositor_;
38
39 base::WeakPtrFactory<TestCompositorHostOzone> method_factory_;
40
41 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostOzone);
42 };
43
44 TestCompositorHostOzone::TestCompositorHostOzone(const gfx::Rect& bounds)
45 : bounds_(bounds), method_factory_(this) {
46 }
47
48 TestCompositorHostOzone::~TestCompositorHostOzone() {}
49
50 void TestCompositorHostOzone::Show() {
51 // Ozone should rightly have a backing native framebuffer
52 // An in-memory array draw into by OSMesa is a reasonble
53 // fascimile of a dumb framebuffer at present.
54 // GLSurface will allocate the array so long as it is provided
55 // with a non-0 widget.
56 // TODO(rjkroege): Use a "real" ozone widget when it is
57 // available.
jonathan.backer 2013/06/27 17:13:28 Maybe file a crbug and reference it from the TODO?
rjkroege 2013/06/28 00:25:01 Done.
58 compositor_.reset(new ui::Compositor(this, 1));
59 compositor_->SetScaleAndSize(1.0f, bounds_.size());
60 }
61
62 ui::Compositor* TestCompositorHostOzone::GetCompositor() {
63 return compositor_.get();
64 }
65
66 void TestCompositorHostOzone::ScheduleDraw() {
67 DCHECK(!ui::Compositor::WasInitializedWithThread());
68 if (!method_factory_.HasWeakPtrs()) {
69 base::MessageLoopForUI::current()->PostTask(
70 FROM_HERE,
71 base::Bind(&TestCompositorHostOzone::Draw,
72 method_factory_.GetWeakPtr()));
73 }
74 }
75
76 void TestCompositorHostOzone::Draw() {
77 if (compositor_.get())
78 compositor_->Draw();
79 }
80
81 // static
82 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) {
83 return new TestCompositorHostOzone(bounds);
84 }
85
86 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.gyp ('k') | ui/gl/gl.gyp » ('j') | ui/gl/gl_context_ozone.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698