diff options
-rw-r--r-- | ui/gfx/canvas.h | 18 | ||||
-rw-r--r-- | ui/gfx/canvas_paint.h | 37 | ||||
-rw-r--r-- | ui/gfx/canvas_paint_win.cc | 58 | ||||
-rw-r--r-- | ui/gfx/canvas_skia.cc | 29 | ||||
-rw-r--r-- | ui/gfx/canvas_skia_paint.h | 3 | ||||
-rw-r--r-- | ui/ui.gyp | 2 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 1 |
7 files changed, 100 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" @@ -242,6 +242,8 @@ 'gfx/brush.h', 'gfx/canvas.cc', 'gfx/canvas.h', + 'gfx/canvas_paint.h', + 'gfx/canvas_paint_win.cc', 'gfx/canvas_skia.h', 'gfx/canvas_skia.cc', 'gfx/canvas_skia_android.cc', diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index 54759f1..da6f1fc 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -25,6 +25,7 @@ #include "ui/base/view_prop.h" #include "ui/base/win/hwnd_util.h" #include "ui/base/win/mouse_wheel_util.h" +#include "ui/gfx/canvas_paint.h" #include "ui/gfx/canvas_skia.h" #include "ui/gfx/canvas_skia_paint.h" #include "ui/gfx/icon_util.h" |