OLD | NEW |
| (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/compiler_specific.h" | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "ui/base/win/window_impl.h" | |
10 #include "ui/gfx/compositor/compositor.h" | |
11 | |
12 namespace ui { | |
13 | |
14 class TestCompositorHostWin : public TestCompositorHost, | |
15 public WindowImpl, | |
16 public CompositorDelegate { | |
17 public: | |
18 TestCompositorHostWin(const gfx::Rect& bounds) { | |
19 Init(NULL, bounds); | |
20 compositor_.reset(new ui::Compositor(this, hwnd(), GetSize())); | |
21 } | |
22 | |
23 virtual ~TestCompositorHostWin() { | |
24 DestroyWindow(hwnd()); | |
25 } | |
26 | |
27 // Overridden from TestCompositorHost: | |
28 virtual void Show() OVERRIDE { | |
29 ShowWindow(hwnd(), SW_SHOWNORMAL); | |
30 } | |
31 virtual ui::Compositor* GetCompositor() OVERRIDE { | |
32 return compositor_.get(); | |
33 } | |
34 | |
35 // Overridden from CompositorDelegate: | |
36 virtual void ScheduleDraw() OVERRIDE { | |
37 RECT rect; | |
38 ::GetClientRect(hwnd(), &rect); | |
39 InvalidateRect(hwnd(), &rect, FALSE); | |
40 } | |
41 | |
42 private: | |
43 BEGIN_MSG_MAP_EX(TestCompositorHostWin) | |
44 MSG_WM_PAINT(OnPaint) | |
45 END_MSG_MAP() | |
46 | |
47 void OnPaint(HDC dc) { | |
48 compositor_->Draw(false); | |
49 ValidateRect(hwnd(), NULL); | |
50 } | |
51 | |
52 gfx::Size GetSize() { | |
53 RECT r; | |
54 GetClientRect(hwnd(), &r); | |
55 return gfx::Rect(r).size(); | |
56 } | |
57 | |
58 scoped_ptr<ui::Compositor> compositor_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostWin); | |
61 }; | |
62 | |
63 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) { | |
64 return new TestCompositorHostWin(bounds); | |
65 } | |
66 | |
67 } // namespace ui | |
OLD | NEW |