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

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

Issue 285373012: Temporarily adds another constructor to Compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tweak Created 6 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
« no previous file with comments | « ui/compositor/test/test_compositor_host_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/test/test_compositor_host.h" 5 #include "ui/compositor/test/test_compositor_host.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "ui/compositor/compositor.h" 16 #include "ui/compositor/compositor.h"
17 #include "ui/gfx/rect.h" 17 #include "ui/gfx/rect.h"
18 #include "ui/gfx/x/x11_types.h" 18 #include "ui/gfx/x/x11_types.h"
19 19
20 namespace ui { 20 namespace ui {
21 21
22 class TestCompositorHostX11 : public TestCompositorHost { 22 class TestCompositorHostX11 : public TestCompositorHost {
23 public: 23 public:
24 TestCompositorHostX11(const gfx::Rect& bounds); 24 TestCompositorHostX11(const gfx::Rect& bounds,
25 ui::ContextFactory* context_factory);
25 virtual ~TestCompositorHostX11(); 26 virtual ~TestCompositorHostX11();
26 27
27 private: 28 private:
28 // Overridden from TestCompositorHost: 29 // Overridden from TestCompositorHost:
29 virtual void Show() OVERRIDE; 30 virtual void Show() OVERRIDE;
30 virtual ui::Compositor* GetCompositor() OVERRIDE; 31 virtual ui::Compositor* GetCompositor() OVERRIDE;
31 32
32 void Draw(); 33 void Draw();
33 34
34 gfx::Rect bounds_; 35 gfx::Rect bounds_;
35 36
37 ui::ContextFactory* context_factory_;
38
36 scoped_ptr<ui::Compositor> compositor_; 39 scoped_ptr<ui::Compositor> compositor_;
37 40
38 XID window_; 41 XID window_;
39 42
40 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostX11); 43 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostX11);
41 }; 44 };
42 45
43 TestCompositorHostX11::TestCompositorHostX11(const gfx::Rect& bounds) 46 TestCompositorHostX11::TestCompositorHostX11(
44 : bounds_(bounds) { 47 const gfx::Rect& bounds,
48 ui::ContextFactory* context_factory)
49 : bounds_(bounds),
50 context_factory_(context_factory) {
45 } 51 }
46 52
47 TestCompositorHostX11::~TestCompositorHostX11() { 53 TestCompositorHostX11::~TestCompositorHostX11() {
48 } 54 }
49 55
50 void TestCompositorHostX11::Show() { 56 void TestCompositorHostX11::Show() {
51 XDisplay* display = gfx::GetXDisplay(); 57 XDisplay* display = gfx::GetXDisplay();
52 XSetWindowAttributes swa; 58 XSetWindowAttributes swa;
53 swa.event_mask = StructureNotifyMask | ExposureMask; 59 swa.event_mask = StructureNotifyMask | ExposureMask;
54 swa.override_redirect = True; 60 swa.override_redirect = True;
55 window_ = XCreateWindow( 61 window_ = XCreateWindow(
56 display, 62 display,
57 RootWindow(display, DefaultScreen(display)), // parent 63 RootWindow(display, DefaultScreen(display)), // parent
58 bounds_.x(), bounds_.y(), bounds_.width(), bounds_.height(), 64 bounds_.x(), bounds_.y(), bounds_.width(), bounds_.height(),
59 0, // border width 65 0, // border width
60 CopyFromParent, // depth 66 CopyFromParent, // depth
61 InputOutput, 67 InputOutput,
62 CopyFromParent, // visual 68 CopyFromParent, // visual
63 CWEventMask | CWOverrideRedirect, &swa); 69 CWEventMask | CWOverrideRedirect, &swa);
64 XMapWindow(display, window_); 70 XMapWindow(display, window_);
65 71
66 while (1) { 72 while (1) {
67 XEvent event; 73 XEvent event;
68 XNextEvent(display, &event); 74 XNextEvent(display, &event);
69 if (event.type == MapNotify && event.xmap.window == window_) 75 if (event.type == MapNotify && event.xmap.window == window_)
70 break; 76 break;
71 } 77 }
72 compositor_.reset(new ui::Compositor(window_)); 78 compositor_.reset(new ui::Compositor(window_, context_factory_));
73 compositor_->SetScaleAndSize(1.0f, bounds_.size()); 79 compositor_->SetScaleAndSize(1.0f, bounds_.size());
74 } 80 }
75 81
76 ui::Compositor* TestCompositorHostX11::GetCompositor() { 82 ui::Compositor* TestCompositorHostX11::GetCompositor() {
77 return compositor_.get(); 83 return compositor_.get();
78 } 84 }
79 85
80 void TestCompositorHostX11::Draw() { 86 void TestCompositorHostX11::Draw() {
81 if (compositor_.get()) 87 if (compositor_.get())
82 compositor_->Draw(); 88 compositor_->Draw();
83 } 89 }
84 90
85 // static 91 // static
86 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) { 92 TestCompositorHost* TestCompositorHost::Create(
87 return new TestCompositorHostX11(bounds); 93 const gfx::Rect& bounds,
94 ui::ContextFactory* context_factory) {
95 return new TestCompositorHostX11(bounds, context_factory);
88 } 96 }
89 97
90 } // namespace ui 98 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/test/test_compositor_host_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698