summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-25 00:10:14 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-25 00:10:14 +0000
commitae43b850c0d3cd6f82d0b639c349ef896ca55a09 (patch)
tree9351048b577b779b3fdc80cfcaa8375ef94a732e /ui/gfx
parentbca7497622b009bca0597c48f8c43ec0a7121fbd (diff)
downloadchromium_src-ae43b850c0d3cd6f82d0b639c349ef896ca55a09.zip
chromium_src-ae43b850c0d3cd6f82d0b639c349ef896ca55a09.tar.gz
chromium_src-ae43b850c0d3cd6f82d0b639c349ef896ca55a09.tar.bz2
ui/gfx: Move CanvasPaintWin into its own file.
This fix the TODO for ben@ in canvas_skia.cc. R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/9453019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123598 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/canvas.h18
-rw-r--r--ui/gfx/canvas_paint.h37
-rw-r--r--ui/gfx/canvas_paint_win.cc58
-rw-r--r--ui/gfx/canvas_skia.cc29
-rw-r--r--ui/gfx/canvas_skia_paint.h3
5 files changed, 97 insertions, 48 deletions
diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h
index 61d42a4..e6ad62b 100644
--- a/ui/gfx/canvas.h
+++ b/ui/gfx/canvas.h
@@ -223,24 +223,6 @@ class UI_EXPORT Canvas {
virtual const SkCanvas* GetSkCanvas() const;
};
-class UI_EXPORT CanvasPaint {
- public:
- virtual ~CanvasPaint() {}
-
- // Creates a canvas that paints to |view| when it is destroyed. The canvas is
- // sized to the client area of |view|.
- static CanvasPaint* CreateCanvasPaint(gfx::NativeView view);
-
- // Returns true if the canvas has an invalid rect that needs to be repainted.
- virtual bool IsValid() const = 0;
-
- // Returns the rectangle that is invalid.
- virtual gfx::Rect GetInvalidRect() const = 0;
-
- // Returns the underlying Canvas.
- virtual Canvas* AsCanvas() = 0;
-};
-
} // namespace gfx
#endif // UI_GFX_CANVAS_H_
diff --git a/ui/gfx/canvas_paint.h b/ui/gfx/canvas_paint.h
new file mode 100644
index 0000000..105aea3
--- /dev/null
+++ b/ui/gfx/canvas_paint.h
@@ -0,0 +1,37 @@
+// 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.
+
+#ifndef UI_GFX_CANVAS_PAINT_H_
+#define UI_GFX_CANVAS_PAINT_H_
+#pragma once
+
+#include "ui/base/ui_export.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace gfx {
+
+class Canvas;
+class Rect;
+
+class CanvasPaint {
+ public:
+ // Creates a canvas that paints to |view| when it is destroyed. The canvas is
+ // sized to the client area of |view|.
+ UI_EXPORT static CanvasPaint* CreateCanvasPaint(gfx::NativeView view);
+
+ virtual ~CanvasPaint() {}
+
+ // Returns true if the canvas has an invalid rect that needs to be repainted.
+ virtual bool IsValid() const = 0;
+
+ // Returns the rectangle that is invalid.
+ virtual gfx::Rect GetInvalidRect() const = 0;
+
+ // Returns the underlying Canvas.
+ virtual Canvas* AsCanvas() = 0;
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_CANVAS_PAINT_H_
diff --git a/ui/gfx/canvas_paint_win.cc b/ui/gfx/canvas_paint_win.cc
new file mode 100644
index 0000000..3264f3c
--- /dev/null
+++ b/ui/gfx/canvas_paint_win.cc
@@ -0,0 +1,58 @@
+// 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_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
diff --git a/ui/gfx/canvas_skia.cc b/ui/gfx/canvas_skia.cc
index 6d93d8d6..6e44931 100644
--- a/ui/gfx/canvas_skia.cc
+++ b/ui/gfx/canvas_skia.cc
@@ -404,33 +404,4 @@ Canvas* Canvas::CreateCanvas(const gfx::Size& size, bool is_opaque) {
return new CanvasSkia(size, is_opaque);
}
-#if defined(OS_WIN) && !defined(USE_AURA)
-// TODO(beng): move to canvas_win.cc, etc.
-class CanvasPaintWin : public CanvasSkiaPaint, public CanvasPaint {
- public:
- CanvasPaintWin(gfx::NativeView view) : CanvasSkiaPaint(view) {}
-
- // Overridden from CanvasPaint2:
- virtual bool IsValid() const {
- return isEmpty();
- }
-
- virtual gfx::Rect GetInvalidRect() const {
- return gfx::Rect(paintStruct().rcPaint);
- }
-
- virtual Canvas* AsCanvas() {
- return this;
- }
-};
-#endif
-
-CanvasPaint* CanvasPaint::CreateCanvasPaint(gfx::NativeView view) {
-#if defined(OS_WIN) && !defined(USE_AURA)
- return new CanvasPaintWin(view);
-#else
- return NULL;
-#endif
-}
-
} // namespace gfx
diff --git a/ui/gfx/canvas_skia_paint.h b/ui/gfx/canvas_skia_paint.h
index 9d1ce8a..ed061ff 100644
--- a/ui/gfx/canvas_skia_paint.h
+++ b/ui/gfx/canvas_skia_paint.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -6,6 +6,7 @@
#define UI_GFX_CANVAS_SKIA_PAINT_H_
#pragma once
+#include "base/logging.h"
#include "skia/ext/canvas_paint.h"
#include "ui/gfx/canvas_skia.h"