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

Side by Side Diff: ui/gfx/compositor/test/test_compositor_host_linux.cc

Issue 10365007: ui: Move compositor/ directory out of gfx/, up to ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix DEPS Created 8 years, 7 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) 2012 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/gfx/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 "ui/base/x/x11_util.h"
14 #include "ui/gfx/compositor/compositor.h"
15 #include "ui/gfx/rect.h"
16
17 #include <X11/Xlib.h>
18
19 namespace ui {
20
21 class TestCompositorHostLinux : public TestCompositorHost,
22 public CompositorDelegate {
23 public:
24 TestCompositorHostLinux(const gfx::Rect& bounds);
25 virtual ~TestCompositorHostLinux();
26
27 private:
28 // Overridden from TestCompositorHost:
29 virtual void Show() OVERRIDE;
30 virtual ui::Compositor* GetCompositor() OVERRIDE;
31
32 // Overridden from CompositorDelegate:
33 virtual void ScheduleDraw() OVERRIDE;
34
35 void Draw();
36
37 gfx::Rect bounds_;
38
39 scoped_ptr<ui::Compositor> compositor_;
40
41 XID window_;
42
43 base::WeakPtrFactory<TestCompositorHostLinux> method_factory_;
44
45 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostLinux);
46 };
47
48 TestCompositorHostLinux::TestCompositorHostLinux(const gfx::Rect& bounds)
49 : bounds_(bounds),
50 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
51 }
52
53 TestCompositorHostLinux::~TestCompositorHostLinux() {
54 }
55
56 void TestCompositorHostLinux::Show() {
57 Display* display = base::MessagePumpForUI::GetDefaultXDisplay();
58 XSetWindowAttributes swa;
59 swa.event_mask = StructureNotifyMask | ExposureMask;
60 swa.override_redirect = True;
61 window_ = XCreateWindow(
62 display,
63 RootWindow(display, DefaultScreen(display)), // parent
64 bounds_.x(), bounds_.y(), bounds_.width(), bounds_.height(),
65 0, // border width
66 CopyFromParent, // depth
67 InputOutput,
68 CopyFromParent, // visual
69 CWEventMask | CWOverrideRedirect, &swa);
70 XMapWindow(display, window_);
71
72 while (1) {
73 XEvent event;
74 XNextEvent(display, &event);
75 if (event.type == MapNotify && event.xmap.window == window_)
76 break;
77 }
78 compositor_.reset(new ui::Compositor(this, window_, bounds_.size()));
79 }
80
81 ui::Compositor* TestCompositorHostLinux::GetCompositor() {
82 return compositor_.get();
83 }
84
85 void TestCompositorHostLinux::ScheduleDraw() {
86 if (!method_factory_.HasWeakPtrs()) {
87 MessageLoopForUI::current()->PostTask(
88 FROM_HERE,
89 base::Bind(&TestCompositorHostLinux::Draw,
90 method_factory_.GetWeakPtr()));
91 }
92 }
93
94 void TestCompositorHostLinux::Draw() {
95 if (compositor_.get())
96 compositor_->Draw(false);
97 }
98
99 // static
100 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) {
101 return new TestCompositorHostLinux(bounds);
102 }
103
104 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/compositor/test/test_compositor_host.h ('k') | ui/gfx/compositor/test/test_compositor_host_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698