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

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

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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
OLDNEW
(Empty)
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.
4
5 #include "ui/compositor/test/test_compositor_host.h"
6
7 #include <X11/Xlib.h>
8
9 #include "base/basictypes.h"
10 #include "base/bind.h"
11 #include "base/compiler_specific.h"
12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/thread_task_runner_handle.h"
16 #include "ui/compositor/compositor.h"
17 #include "ui/gfx/rect.h"
18 #include "ui/gfx/x/x11_types.h"
19
20 namespace ui {
21
22 class TestCompositorHostX11 : public TestCompositorHost {
23 public:
24 TestCompositorHostX11(const gfx::Rect& bounds,
25 ui::ContextFactory* context_factory);
26 virtual ~TestCompositorHostX11();
27
28 private:
29 // Overridden from TestCompositorHost:
30 virtual void Show() override;
31 virtual ui::Compositor* GetCompositor() override;
32
33 void Draw();
34
35 gfx::Rect bounds_;
36
37 ui::ContextFactory* context_factory_;
38
39 scoped_ptr<ui::Compositor> compositor_;
40
41 XID window_;
42
43 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostX11);
44 };
45
46 TestCompositorHostX11::TestCompositorHostX11(
47 const gfx::Rect& bounds,
48 ui::ContextFactory* context_factory)
49 : bounds_(bounds),
50 context_factory_(context_factory) {
51 }
52
53 TestCompositorHostX11::~TestCompositorHostX11() {
54 }
55
56 void TestCompositorHostX11::Show() {
57 XDisplay* display = gfx::GetXDisplay();
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(window_,
79 context_factory_,
80 base::ThreadTaskRunnerHandle::Get()));
81 compositor_->SetScaleAndSize(1.0f, bounds_.size());
82 }
83
84 ui::Compositor* TestCompositorHostX11::GetCompositor() {
85 return compositor_.get();
86 }
87
88 void TestCompositorHostX11::Draw() {
89 if (compositor_.get())
90 compositor_->Draw();
91 }
92
93 // static
94 TestCompositorHost* TestCompositorHost::Create(
95 const gfx::Rect& bounds,
96 ui::ContextFactory* context_factory) {
97 return new TestCompositorHostX11(bounds, context_factory);
98 }
99
100 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/test/test_compositor_host_win.cc ('k') | ui/compositor/test/test_layer_animation_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698