| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/gfx/compositor/test_compositor_host.h" | 5 #include "ui/gfx/compositor/test_compositor_host.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "ui/base/win/window_impl.h" | 8 #include "ui/base/win/window_impl.h" |
| 9 #include "ui/gfx/compositor/compositor.h" | 9 #include "ui/gfx/compositor/compositor.h" |
| 10 | 10 |
| 11 namespace ui { | 11 namespace ui { |
| 12 | 12 |
| 13 class TestCompositorHostWin : public TestCompositorHost, | 13 class TestCompositorHostWin : public TestCompositorHost, |
| 14 public ui::WindowImpl { | 14 public WindowImpl, |
| 15 public CompositorDelegate { |
| 15 public: | 16 public: |
| 16 TestCompositorHostWin(const gfx::Rect& bounds, | 17 TestCompositorHostWin(const gfx::Rect& bounds, |
| 17 TestCompositorHostDelegate* delegate) | 18 TestCompositorHostDelegate* delegate) |
| 18 : delegate_(delegate) { | 19 : delegate_(delegate) { |
| 19 Init(NULL, bounds); | 20 Init(NULL, bounds); |
| 20 compositor_ = ui::Compositor::Create(hwnd(), GetSize()); | 21 compositor_ = ui::Compositor::Create(this, hwnd(), GetSize()); |
| 21 } | 22 } |
| 22 | 23 |
| 23 virtual ~TestCompositorHostWin() { | 24 virtual ~TestCompositorHostWin() { |
| 24 DestroyWindow(hwnd()); | 25 DestroyWindow(hwnd()); |
| 25 } | 26 } |
| 26 | 27 |
| 27 // Overridden from MessageLoop::Dispatcher: | 28 // Overridden from MessageLoop::Dispatcher: |
| 28 virtual bool Dispatch(const MSG& msg) { | 29 virtual bool Dispatch(const MSG& msg) { |
| 29 TranslateMessage(&msg); | 30 TranslateMessage(&msg); |
| 30 DispatchMessage(&msg); | 31 DispatchMessage(&msg); |
| 31 return true; | 32 return true; |
| 32 } | 33 } |
| 33 | 34 |
| 34 // Overridden from TestCompositorHost: | 35 // Overridden from TestCompositorHost: |
| 35 virtual void Show() OVERRIDE { | 36 virtual void Show() OVERRIDE { |
| 36 ShowWindow(hwnd(), SW_SHOWNORMAL); | 37 ShowWindow(hwnd(), SW_SHOWNORMAL); |
| 37 } | 38 } |
| 38 virtual ui::Compositor* GetCompositor() OVERRIDE { | 39 virtual ui::Compositor* GetCompositor() OVERRIDE { |
| 39 return compositor_; | 40 return compositor_; |
| 40 } | 41 } |
| 41 | 42 |
| 43 // Overridden from CompositorDelegate: |
| 44 virtual void ScheduleCompositorPaint() OVERRIDE { |
| 45 RECT rect; |
| 46 ::GetClientRect(hwnd(), &rect); |
| 47 InvalidateRect(hwnd(), &rect, FALSE); |
| 48 } |
| 49 |
| 42 private: | 50 private: |
| 43 BEGIN_MSG_MAP_EX(TestCompositorHostWin) | 51 BEGIN_MSG_MAP_EX(TestCompositorHostWin) |
| 44 MSG_WM_PAINT(OnPaint) | 52 MSG_WM_PAINT(OnPaint) |
| 45 END_MSG_MAP() | 53 END_MSG_MAP() |
| 46 | 54 |
| 47 void OnPaint(HDC dc) { | 55 void OnPaint(HDC dc) { |
| 48 compositor_->NotifyStart(); | 56 compositor_->NotifyStart(); |
| 49 delegate_->Draw(); | 57 delegate_->Draw(); |
| 50 compositor_->NotifyEnd(); | 58 compositor_->NotifyEnd(); |
| 51 ValidateRect(hwnd(), NULL); | 59 ValidateRect(hwnd(), NULL); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 64 }; | 72 }; |
| 65 | 73 |
| 66 TestCompositorHost* TestCompositorHost::Create( | 74 TestCompositorHost* TestCompositorHost::Create( |
| 67 const gfx::Rect& bounds, | 75 const gfx::Rect& bounds, |
| 68 TestCompositorHostDelegate* delegate) { | 76 TestCompositorHostDelegate* delegate) { |
| 69 return new TestCompositorHostWin(bounds, delegate); | 77 return new TestCompositorHostWin(bounds, delegate); |
| 70 } | 78 } |
| 71 | 79 |
| 72 } // namespace ui | 80 } // namespace ui |
| 73 | 81 |
| OLD | NEW |