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.
5 #include "ui/compositor/test/test_compositor_host.h"
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"
15 class TestCompositorHostWin
: public TestCompositorHost
,
16 public gfx::WindowImpl
{
18 TestCompositorHostWin(const gfx::Rect
& bounds
,
19 ui::ContextFactory
* context_factory
) {
21 compositor_
.reset(new ui::Compositor(hwnd(),
23 base::ThreadTaskRunnerHandle::Get()));
24 compositor_
->SetScaleAndSize(1.0f
, GetSize());
27 ~TestCompositorHostWin() override
{ DestroyWindow(hwnd()); }
29 // Overridden from TestCompositorHost:
30 void Show() override
{ ShowWindow(hwnd(), SW_SHOWNORMAL
); }
31 ui::Compositor
* GetCompositor() override
{ return compositor_
.get(); }
34 CR_BEGIN_MSG_MAP_EX(TestCompositorHostWin
)
35 CR_MSG_WM_PAINT(OnPaint
)
38 void OnPaint(HDC dc
) {
39 compositor_
->ScheduleFullRedraw();
40 ValidateRect(hwnd(), NULL
);
45 GetClientRect(hwnd(), &r
);
46 return gfx::Rect(r
).size();
49 scoped_ptr
<ui::Compositor
> compositor_
;
51 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostWin
);
54 TestCompositorHost
* TestCompositorHost::Create(
55 const gfx::Rect
& bounds
,
56 ui::ContextFactory
* context_factory
) {
57 return new TestCompositorHostWin(bounds
, context_factory
);