summaryrefslogtreecommitdiffstats
path: root/ui/gfx/canvas_paint_win.cc
blob: 8bafe6de3aac482cb62a3f227a8b69d936446146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/canvas_paint.h"
#include "ui/gfx/canvas_skia_paint.h"
#include "ui/gfx/rect.h"

namespace {

#if !defined(USE_AURA)
class CanvasPaintWin : public gfx::CanvasPaint, public gfx::CanvasSkiaPaint {
 public:
  CanvasPaintWin(gfx::NativeView view);
  virtual ~CanvasPaintWin();

  // Overridden from CanvasPaint:
  virtual bool IsValid() const OVERRIDE;
  virtual gfx::Rect GetInvalidRect() const OVERRIDE;
  virtual gfx::Canvas* AsCanvas() OVERRIDE;

 private:
  DISALLOW_COPY_AND_ASSIGN(CanvasPaintWin);
};

CanvasPaintWin::CanvasPaintWin(gfx::NativeView view)
    : gfx::CanvasSkiaPaint(view) {}

CanvasPaintWin::~CanvasPaintWin() {}

bool CanvasPaintWin::IsValid() const {
  return isEmpty();
}

gfx::Rect CanvasPaintWin::GetInvalidRect() const {
  return gfx::Rect(paintStruct().rcPaint);
}

gfx::Canvas* CanvasPaintWin::AsCanvas() {
  return this;
}
#endif

}  // namespace

namespace gfx {

CanvasPaint* CanvasPaint::CreateCanvasPaint(gfx::NativeView view) {
#if !defined(USE_AURA)
  return new CanvasPaintWin(view);
#else
  return NULL;
#endif
}

}  // namespace gfx