Correct comment added on r267371
[chromium-blink-merge.git] / ui / compositor / test / test_compositor_host_win.cc
blob4ea0df8fc0713654cf475840ec7769f43d423ce3
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/compositor/compositor.h"
10 #include "ui/gfx/win/window_impl.h"
12 namespace ui {
14 class TestCompositorHostWin : public TestCompositorHost,
15 public gfx::WindowImpl {
16 public:
17 TestCompositorHostWin(const gfx::Rect& bounds) {
18 Init(NULL, bounds);
19 compositor_.reset(new ui::Compositor(hwnd()));
20 compositor_->SetScaleAndSize(1.0f, GetSize());
23 virtual ~TestCompositorHostWin() {
24 DestroyWindow(hwnd());
27 // Overridden from TestCompositorHost:
28 virtual void Show() OVERRIDE {
29 ShowWindow(hwnd(), SW_SHOWNORMAL);
31 virtual ui::Compositor* GetCompositor() OVERRIDE {
32 return compositor_.get();
35 private:
36 CR_BEGIN_MSG_MAP_EX(TestCompositorHostWin)
37 CR_MSG_WM_PAINT(OnPaint)
38 CR_END_MSG_MAP()
40 void OnPaint(HDC dc) {
41 compositor_->Draw();
42 ValidateRect(hwnd(), NULL);
45 gfx::Size GetSize() {
46 RECT r;
47 GetClientRect(hwnd(), &r);
48 return gfx::Rect(r).size();
51 scoped_ptr<ui::Compositor> compositor_;
53 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostWin);
56 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) {
57 return new TestCompositorHostWin(bounds);
60 } // namespace ui