Fix build break
[chromium-blink-merge.git] / ui / compositor / test / test_compositor_host_win.cc
blob452acee7f6e97081e2d166c3c5f92991ea557fcd
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 "ui/base/win/window_impl.h"
10 #include "ui/compositor/compositor.h"
12 namespace ui {
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()));
21 compositor_->SetScaleAndSize(1.0f, GetSize());
24 virtual ~TestCompositorHostWin() {
25 DestroyWindow(hwnd());
28 // Overridden from TestCompositorHost:
29 virtual void Show() OVERRIDE {
30 ShowWindow(hwnd(), SW_SHOWNORMAL);
32 virtual ui::Compositor* GetCompositor() OVERRIDE {
33 return compositor_.get();
36 // Overridden from CompositorDelegate:
37 virtual void ScheduleDraw() OVERRIDE {
38 DCHECK(!ui::Compositor::WasInitializedWithThread());
39 RECT rect;
40 ::GetClientRect(hwnd(), &rect);
41 InvalidateRect(hwnd(), &rect, FALSE);
44 private:
45 BEGIN_MSG_MAP_EX(TestCompositorHostWin)
46 MSG_WM_PAINT(OnPaint)
47 END_MSG_MAP()
49 void OnPaint(HDC dc) {
50 compositor_->Draw();
51 ValidateRect(hwnd(), NULL);
54 gfx::Size GetSize() {
55 RECT r;
56 GetClientRect(hwnd(), &r);
57 return gfx::Rect(r).size();
60 scoped_ptr<ui::Compositor> compositor_;
62 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostWin);
65 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) {
66 return new TestCompositorHostWin(bounds);
69 } // namespace ui