summaryrefslogtreecommitdiffstats
path: root/gfx/canvas_skia.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/canvas_skia.cc')
-rw-r--r--gfx/canvas_skia.cc43
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