OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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_compositor_host.h" |
| 6 |
| 7 #include "ui/base/win/window_impl.h" |
| 8 #include "ui/gfx/compositor/compositor.h" |
| 9 |
| 10 namespace ui { |
| 11 |
| 12 class TestCompositorHostWin : public TestCompositorHost, |
| 13 public ui::WindowImpl { |
| 14 public: |
| 15 explicit TestCompositorHostWin(const gfx::Rect& bounds) { |
| 16 Init(NULL, bounds); |
| 17 compositor_ = ui::Compositor::Create(hwnd(), GetSize()); |
| 18 } |
| 19 |
| 20 virtual ~TestCompositorHostWin() { |
| 21 DestroyWindow(hwnd()); |
| 22 } |
| 23 |
| 24 // Overridden from MessageLoop::Dispatcher: |
| 25 virtual bool Dispatch(const MSG& msg) { |
| 26 TranslateMessage(&msg); |
| 27 DispatchMessage(&msg); |
| 28 return true; |
| 29 } |
| 30 |
| 31 // Overridden from TestCompositorHost: |
| 32 virtual void Show() OVERRIDE { |
| 33 ShowWindow(hwnd(), SW_SHOWNORMAL); |
| 34 } |
| 35 virtual ui::Compositor* GetCompositor() OVERRIDE { |
| 36 return compositor_; |
| 37 } |
| 38 |
| 39 private: |
| 40 BEGIN_MSG_MAP_EX(TestCompositorHostWin) |
| 41 MSG_WM_PAINT(OnPaint) |
| 42 END_MSG_MAP() |
| 43 |
| 44 void OnPaint(HDC dc) { |
| 45 ValidateRect(hwnd(), NULL); |
| 46 } |
| 47 |
| 48 gfx::Size GetSize() { |
| 49 RECT r; |
| 50 GetClientRect(hwnd(), &r); |
| 51 return gfx::Rect(r).size(); |
| 52 } |
| 53 |
| 54 scoped_refptr<ui::Compositor> compositor_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostWin); |
| 57 }; |
| 58 |
| 59 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) { |
| 60 return new TestCompositorHostWin(bounds); |
| 61 } |
| 62 |
| 63 } // namespace ui |
| 64 |
OLD | NEW |