diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 16:33:23 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 16:33:23 +0000 |
commit | 74db48eb22cd8bfe4d028418d99e7aee6c220930 (patch) | |
tree | 94b62cc97d669cb965d2073c5d9a72a4a3c3ee04 /gfx/canvas_skia.cc | |
parent | 2abd00dd89a5cbc9af4a88a59269fdf9f988cf12 (diff) | |
download | chromium_src-74db48eb22cd8bfe4d028418d99e7aee6c220930.zip chromium_src-74db48eb22cd8bfe4d028418d99e7aee6c220930.tar.gz chromium_src-74db48eb22cd8bfe4d028418d99e7aee6c220930.tar.bz2 |
Canvas refactoring part 3.
- Replace Canvas instance users with CanvasSkia users.
- Rename Canvas2 to Canvas.
- Delete Canvas subclass of CanvasSkia.
This has created some ugliness around the fact that people that used SkCanvas methods on Canvas now have to go through AsCanvasSkia first. This is temporary ugliness that will be eradicated as I incrementally build out the new Canvas API.
BUG=none
TEST=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50854 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx/canvas_skia.cc')
-rw-r--r-- | gfx/canvas_skia.cc | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/gfx/canvas_skia.cc b/gfx/canvas_skia.cc index 8fa763a..8fb752de 100644 --- a/gfx/canvas_skia.cc +++ b/gfx/canvas_skia.cc @@ -2,13 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "gfx/canvas.h" +#include "gfx/canvas_skia.h" #include <limits> #include "base/i18n/rtl.h" #include "base/logging.h" -#include "gfx/canvas.h" #include "gfx/font.h" #include "gfx/rect.h" #include "third_party/skia/include/core/SkShader.h" @@ -19,6 +18,17 @@ namespace gfx { +SkBitmap CanvasSkia::ExtractBitmap() const { + const SkBitmap& device_bitmap = getDevice()->accessBitmap(false); + + // Make a bitmap to return, and a canvas to draw into it. We don't just want + // to call extractSubset or the copy constructor, since we want an actual copy + // of the bitmap. + SkBitmap result; + device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config); + return result; +} + bool CanvasSkia::GetClipRect(gfx::Rect* r) { SkRect clip; if (!getClipBounds(&clip)) { @@ -263,15 +273,12 @@ void CanvasSkia::TileImageInt(const SkBitmap& bitmap, int src_x, int src_y, restore(); } -SkBitmap CanvasSkia::ExtractBitmap() const { - const SkBitmap& device_bitmap = getDevice()->accessBitmap(false); +CanvasSkia* CanvasSkia::AsCanvasSkia() { + return this; +} - // Make a bitmap to return, and a canvas to draw into it. We don't just want - // to call extractSubset or the copy constuctor, since we want an actual copy - // of the bitmap. - SkBitmap result; - device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config); - return result; +const CanvasSkia* CanvasSkia::AsCanvasSkia() const { + return this; } // static @@ -282,19 +289,19 @@ int CanvasSkia::DefaultCanvasTextAlignment() { } //////////////////////////////////////////////////////////////////////////////// -// Canvas2, public: +// Canvas, public: -Canvas2* Canvas2::CreateCanvas() { - return new Canvas; +Canvas* Canvas::CreateCanvas() { + return new CanvasSkia; } -Canvas2* Canvas2::CreateCanvas(int width, int height, bool is_opaque) { - return new Canvas(width, height, is_opaque); +Canvas* Canvas::CreateCanvas(int width, int height, bool is_opaque) { + return new CanvasSkia(width, height, is_opaque); } #if defined(OS_WIN) // TODO(beng): move to canvas_win.cc, etc. -class CanvasPaintWin : public CanvasSkiaPaint, public CanvasPaint2 { +class CanvasPaintWin : public CanvasSkiaPaint, public CanvasPaint { public: CanvasPaintWin(gfx::NativeView view) : CanvasSkiaPaint(view) {} @@ -307,13 +314,13 @@ class CanvasPaintWin : public CanvasSkiaPaint, public CanvasPaint2 { return gfx::Rect(paintStruct().rcPaint); } - virtual Canvas2* AsCanvas2() { + virtual Canvas* AsCanvas() { return this; } }; #endif -CanvasPaint2* CanvasPaint2::CreateCanvasPaint(gfx::NativeView view) { +CanvasPaint* CanvasPaint::CreateCanvasPaint(gfx::NativeView view) { #if defined(OS_WIN) return new CanvasPaintWin(view); #else |