| 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/compositor/test/test_compositor_host.h" | |
| 6 | |
| 7 #include "base/compiler_specific.h" | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/thread_task_runner_handle.h" | |
| 10 #include "ui/compositor/compositor.h" | |
| 11 #include "ui/gfx/win/window_impl.h" | |
| 12 | |
| 13 namespace ui { | |
| 14 | |
| 15 class TestCompositorHostWin : public TestCompositorHost, | |
| 16 public gfx::WindowImpl { | |
| 17 public: | |
| 18 TestCompositorHostWin(const gfx::Rect& bounds, | |
| 19 ui::ContextFactory* context_factory) { | |
| 20 Init(NULL, bounds); | |
| 21 compositor_.reset(new ui::Compositor(hwnd(), | |
| 22 context_factory, | |
| 23 base::ThreadTaskRunnerHandle::Get())); | |
| 24 compositor_->SetScaleAndSize(1.0f, GetSize()); | |
| 25 } | |
| 26 | |
| 27 virtual ~TestCompositorHostWin() { | |
| 28 DestroyWindow(hwnd()); | |
| 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_.get(); | |
| 37 } | |
| 38 | |
| 39 private: | |
| 40 CR_BEGIN_MSG_MAP_EX(TestCompositorHostWin) | |
| 41 CR_MSG_WM_PAINT(OnPaint) | |
| 42 CR_END_MSG_MAP() | |
| 43 | |
| 44 void OnPaint(HDC dc) { | |
| 45 compositor_->Draw(); | |
| 46 ValidateRect(hwnd(), NULL); | |
| 47 } | |
| 48 | |
| 49 gfx::Size GetSize() { | |
| 50 RECT r; | |
| 51 GetClientRect(hwnd(), &r); | |
| 52 return gfx::Rect(r).size(); | |
| 53 } | |
| 54 | |
| 55 scoped_ptr<ui::Compositor> compositor_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostWin); | |
| 58 }; | |
| 59 | |
| 60 TestCompositorHost* TestCompositorHost::Create( | |
| 61 const gfx::Rect& bounds, | |
| 62 ui::ContextFactory* context_factory) { | |
| 63 return new TestCompositorHostWin(bounds, context_factory); | |
| 64 } | |
| 65 | |
| 66 } // namespace ui | |
| OLD | NEW |