summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-05 19:05:07 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-05 19:05:07 +0000
commitbe172ba8194e48970d90e9d873160b259df69b96 (patch)
tree677a1fedc8a836a42de1dba22d8c0663173a0f96 /ui/gfx
parent2c572bd1d4eec134ae40e00adbfa2c9d3d1ff1e7 (diff)
downloadchromium_src-be172ba8194e48970d90e9d873160b259df69b96.zip
chromium_src-be172ba8194e48970d90e9d873160b259df69b96.tar.gz
chromium_src-be172ba8194e48970d90e9d873160b259df69b96.tar.bz2
Allow CanvasSkia to bind to an existing SkCanvas.
BUG=None TEST=None Review URL: http://codereview.chromium.org/8122013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/canvas.cc10
-rw-r--r--ui/gfx/canvas.h4
-rw-r--r--ui/gfx/canvas_skia.cc74
-rw-r--r--ui/gfx/canvas_skia.h10
-rw-r--r--ui/gfx/canvas_skia_linux.cc20
-rw-r--r--ui/gfx/canvas_skia_mac.mm12
-rw-r--r--ui/gfx/canvas_skia_paint.h13
-rw-r--r--ui/gfx/canvas_skia_win.cc30
-rw-r--r--ui/gfx/compositor/layer.cc2
-rw-r--r--ui/gfx/compositor/layer_unittest.cc4
-rw-r--r--ui/gfx/render_text.cc10
-rw-r--r--ui/gfx/render_text_linux.cc4
-rw-r--r--ui/gfx/render_text_win.cc14
13 files changed, 118 insertions, 89 deletions
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index e787aab..2ac1718 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -14,4 +14,12 @@ const CanvasSkia* Canvas::AsCanvasSkia() const {
return NULL;
}
+SkCanvas* Canvas::GetSkCanvas() {
+ return NULL;
+}
+
+const SkCanvas* Canvas::GetSkCanvas() const {
+ return NULL;
+}
+
} // namespace gfx;
diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h
index 5fa067e..38ad3ac 100644
--- a/ui/gfx/canvas.h
+++ b/ui/gfx/canvas.h
@@ -15,6 +15,8 @@
#include "ui/base/ui_export.h"
#include "ui/gfx/native_widget_types.h"
+class SkCanvas;
+
namespace ui {
class Transform;
@@ -233,6 +235,8 @@ class UI_EXPORT Canvas {
// A quick and dirty way to obtain the underlying SkCanvas.
virtual CanvasSkia* AsCanvasSkia();
virtual const CanvasSkia* AsCanvasSkia() const;
+ virtual SkCanvas* GetSkCanvas();
+ virtual const SkCanvas* GetSkCanvas() const;
};
class UI_EXPORT CanvasPaint {
diff --git a/ui/gfx/canvas_skia.cc b/ui/gfx/canvas_skia.cc
index 9083d1d..c93dd09 100644
--- a/ui/gfx/canvas_skia.cc
+++ b/ui/gfx/canvas_skia.cc
@@ -47,6 +47,25 @@ namespace gfx {
////////////////////////////////////////////////////////////////////////////////
// CanvasSkia, public:
+CanvasSkia::CanvasSkia(int width, int height, bool is_opaque)
+ : owned_canvas_(new skia::PlatformCanvas(width, height, is_opaque)),
+ canvas_(owned_canvas_.get()) {
+}
+
+CanvasSkia::CanvasSkia()
+ : owned_canvas_(new skia::PlatformCanvas()),
+ canvas_(owned_canvas_.get()) {
+}
+
+CanvasSkia::CanvasSkia(SkCanvas* canvas)
+ : owned_canvas_(),
+ canvas_(canvas) {
+ DCHECK(canvas);
+}
+
+CanvasSkia::~CanvasSkia() {
+}
+
// static
int CanvasSkia::DefaultCanvasTextAlignment() {
if (!base::i18n::IsRTL())
@@ -55,7 +74,7 @@ int CanvasSkia::DefaultCanvasTextAlignment() {
}
SkBitmap CanvasSkia::ExtractBitmap() const {
- const SkBitmap& device_bitmap = getDevice()->accessBitmap(false);
+ const SkBitmap& device_bitmap = canvas_->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
@@ -69,11 +88,11 @@ SkBitmap CanvasSkia::ExtractBitmap() const {
// CanvasSkia, Canvas implementation:
void CanvasSkia::Save() {
- save();
+ canvas_->save();
}
void CanvasSkia::SaveLayerAlpha(uint8 alpha) {
- saveLayerAlpha(NULL, alpha);
+ canvas_->saveLayerAlpha(NULL, alpha);
}
@@ -83,26 +102,26 @@ void CanvasSkia::SaveLayerAlpha(uint8 alpha, const gfx::Rect& layer_bounds) {
SkIntToScalar(layer_bounds.y()),
SkIntToScalar(layer_bounds.right()),
SkIntToScalar(layer_bounds.bottom()));
- saveLayerAlpha(&bounds, alpha);
+ canvas_->saveLayerAlpha(&bounds, alpha);
}
void CanvasSkia::Restore() {
- restore();
+ canvas_->restore();
}
bool CanvasSkia::ClipRectInt(int x, int y, int w, int h) {
SkRect new_clip;
new_clip.set(SkIntToScalar(x), SkIntToScalar(y),
SkIntToScalar(x + w), SkIntToScalar(y + h));
- return clipRect(new_clip);
+ return canvas_->clipRect(new_clip);
}
void CanvasSkia::TranslateInt(int x, int y) {
- translate(SkIntToScalar(x), SkIntToScalar(y));
+ canvas_->translate(SkIntToScalar(x), SkIntToScalar(y));
}
void CanvasSkia::ScaleInt(int x, int y) {
- scale(SkIntToScalar(x), SkIntToScalar(y));
+ canvas_->scale(SkIntToScalar(x), SkIntToScalar(y));
}
void CanvasSkia::FillRectInt(const SkColor& color, int x, int y, int w, int h) {
@@ -149,7 +168,7 @@ void CanvasSkia::DrawRectInt(const SkColor& color,
void CanvasSkia::DrawRectInt(int x, int y, int w, int h, const SkPaint& paint) {
SkIRect rc = { x, y, x + w, y + h };
- drawIRect(rc, paint);
+ canvas_->drawIRect(rc, paint);
}
void CanvasSkia::DrawLineInt(const SkColor& color,
@@ -158,8 +177,8 @@ void CanvasSkia::DrawLineInt(const SkColor& color,
SkPaint paint;
paint.setColor(color);
paint.setStrokeWidth(SkIntToScalar(1));
- drawLine(SkIntToScalar(x1), SkIntToScalar(y1), SkIntToScalar(x2),
- SkIntToScalar(y2), paint);
+ canvas_->drawLine(SkIntToScalar(x1), SkIntToScalar(y1), SkIntToScalar(x2),
+ SkIntToScalar(y2), paint);
}
void CanvasSkia::DrawFocusRect(int x, int y, int width, int height) {
@@ -207,13 +226,13 @@ void CanvasSkia::DrawFocusRect(int x, int y, int width, int height) {
}
void CanvasSkia::DrawBitmapInt(const SkBitmap& bitmap, int x, int y) {
- drawBitmap(bitmap, SkIntToScalar(x), SkIntToScalar(y));
+ canvas_->drawBitmap(bitmap, SkIntToScalar(x), SkIntToScalar(y));
}
void CanvasSkia::DrawBitmapInt(const SkBitmap& bitmap,
int x, int y,
const SkPaint& paint) {
- drawBitmap(bitmap, SkIntToScalar(x), SkIntToScalar(y), &paint);
+ canvas_->drawBitmap(bitmap, SkIntToScalar(x), SkIntToScalar(y), &paint);
}
void CanvasSkia::DrawBitmapInt(const SkBitmap& bitmap,
@@ -249,7 +268,7 @@ void CanvasSkia::DrawBitmapInt(const SkBitmap& bitmap,
// Workaround for apparent bug in Skia that causes image to occasionally
// shift.
SkIRect src_rect = { src_x, src_y, src_x + src_w, src_y + src_h };
- drawBitmapRect(bitmap, &src_rect, dest_rect, &paint);
+ canvas_->drawBitmapRect(bitmap, &src_rect, dest_rect, &paint);
return;
}
@@ -275,7 +294,7 @@ void CanvasSkia::DrawBitmapInt(const SkBitmap& bitmap,
shader->unref();
// The rect will be filled by the bitmap.
- drawRect(dest_rect, p);
+ canvas_->drawRect(dest_rect, p);
}
void CanvasSkia::DrawStringInt(const string16& text,
@@ -316,24 +335,25 @@ void CanvasSkia::TileImageInt(const SkBitmap& bitmap,
// CreateBitmapShader returns a Shader with a reference count of one, we
// need to unref after paint takes ownership of the shader.
shader->unref();
- save();
- translate(SkIntToScalar(dest_x - src_x), SkIntToScalar(dest_y - src_y));
+ canvas_->save();
+ canvas_->translate(SkIntToScalar(dest_x - src_x),
+ SkIntToScalar(dest_y - src_y));
ClipRectInt(src_x, src_y, w, h);
- drawPaint(paint);
- restore();
+ canvas_->drawPaint(paint);
+ canvas_->restore();
}
gfx::NativeDrawingContext CanvasSkia::BeginPlatformPaint() {
- return skia::BeginPlatformPaint(this);
+ return skia::BeginPlatformPaint(canvas_);
}
void CanvasSkia::EndPlatformPaint() {
- skia::EndPlatformPaint(this);
+ skia::EndPlatformPaint(canvas_);
}
#if !defined(OS_MACOSX)
void CanvasSkia::Transform(const ui::Transform& transform) {
- concat(transform.matrix());
+ canvas_->concat(transform.matrix());
}
#endif
@@ -345,12 +365,20 @@ const CanvasSkia* CanvasSkia::AsCanvasSkia() const {
return this;
}
+SkCanvas* CanvasSkia::GetSkCanvas() {
+ return canvas_;
+}
+
+const SkCanvas* CanvasSkia::GetSkCanvas() const {
+ return canvas_;
+}
+
////////////////////////////////////////////////////////////////////////////////
// CanvasSkia, private:
bool CanvasSkia::IntersectsClipRectInt(int x, int y, int w, int h) {
SkRect clip;
- return getClipBounds(&clip) &&
+ return canvas_->getClipBounds(&clip) &&
clip.intersect(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + w),
SkIntToScalar(y + h));
}
diff --git a/ui/gfx/canvas_skia.h b/ui/gfx/canvas_skia.h
index e7ec18b..b315af9 100644
--- a/ui/gfx/canvas_skia.h
+++ b/ui/gfx/canvas_skia.h
@@ -7,6 +7,7 @@
#pragma once
#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "skia/ext/platform_canvas.h"
#include "ui/gfx/canvas.h"
@@ -34,7 +35,7 @@ class Canvas;
// source and destination colors are combined. Unless otherwise specified,
// the variant that does not take a SkXfermode::Mode uses a transfer mode
// of kSrcOver_Mode.
-class UI_EXPORT CanvasSkia : public skia::PlatformCanvas, public Canvas {
+class UI_EXPORT CanvasSkia : public Canvas {
public:
enum TruncateFadeMode {
TruncateFadeTail,
@@ -47,6 +48,7 @@ class UI_EXPORT CanvasSkia : public skia::PlatformCanvas, public Canvas {
CanvasSkia();
CanvasSkia(int width, int height, bool is_opaque);
+ explicit CanvasSkia(SkCanvas* canvas);
virtual ~CanvasSkia();
@@ -163,6 +165,10 @@ class UI_EXPORT CanvasSkia : public skia::PlatformCanvas, public Canvas {
virtual ui::TextureID GetTextureID();
virtual CanvasSkia* AsCanvasSkia();
virtual const CanvasSkia* AsCanvasSkia() const;
+ virtual SkCanvas* GetSkCanvas();
+ virtual const SkCanvas* GetSkCanvas() const;
+ SkCanvas* sk_canvas() const { return canvas_; }
+ skia::PlatformCanvas* platform_canvas() const { return owned_canvas_.get(); }
private:
// Test whether the provided rectangle intersects the current clip rect.
@@ -179,6 +185,8 @@ class UI_EXPORT CanvasSkia : public skia::PlatformCanvas, public Canvas {
int flags);
#endif
+ scoped_ptr<skia::PlatformCanvas> owned_canvas_;
+ SkCanvas* canvas_;
DISALLOW_COPY_AND_ASSIGN(CanvasSkia);
};
diff --git a/ui/gfx/canvas_skia_linux.cc b/ui/gfx/canvas_skia_linux.cc
index 882b381..8101dfa 100644
--- a/ui/gfx/canvas_skia_linux.cc
+++ b/ui/gfx/canvas_skia_linux.cc
@@ -93,7 +93,7 @@ DrawStringContext::DrawStringContext(gfx::CanvasSkia* canvas,
text_direction_(base::i18n::GetFirstStrongCharacterDirection(text)) {
DCHECK(!bounds_.IsEmpty());
- cr_ = skia::BeginPlatformPaint(canvas_);
+ cr_ = skia::BeginPlatformPaint(canvas_->sk_canvas());
layout_ = pango_cairo_create_layout(cr_);
gfx::SetupPangoLayout(
@@ -120,7 +120,7 @@ DrawStringContext::DrawStringContext(gfx::CanvasSkia* canvas,
DrawStringContext::~DrawStringContext() {
cairo_restore(cr_);
- skia::EndPlatformPaint(canvas_);
+ skia::EndPlatformPaint(canvas_->sk_canvas());
g_object_unref(layout_);
// NOTE: BeginPlatformPaint returned its surface, we shouldn't destroy it.
}
@@ -176,7 +176,7 @@ void DrawStringContext::DrawWithHalo(const SkColor& text_color,
0, 0, bounds_.width() + 2, bounds_.height() + 2);
{
- skia::ScopedPlatformPaint scoped_platform_paint(&text_canvas);
+ skia::ScopedPlatformPaint scoped_platform_paint(text_canvas.sk_canvas());
cairo_t* text_cr = scoped_platform_paint.GetPlatformSurface();
// TODO: The current approach (stroking the text path to generate the halo
@@ -216,7 +216,7 @@ void DrawStringContext::DrawWithHalo(const SkColor& text_color,
}
const SkBitmap& text_bitmap = const_cast<SkBitmap&>(
- skia::GetTopDevice(text_canvas)->accessBitmap(false));
+ skia::GetTopDevice(*text_canvas.sk_canvas())->accessBitmap(false));
canvas_->DrawBitmapInt(text_bitmap, text_x_ - 1, text_y_ - 1);
}
@@ -237,16 +237,6 @@ void DrawStringContext::DrawUnderline(cairo_t* cr, double extra_edge_width) {
namespace gfx {
-CanvasSkia::CanvasSkia(int width, int height, bool is_opaque)
- : skia::PlatformCanvas(width, height, is_opaque) {
-}
-
-CanvasSkia::CanvasSkia() : skia::PlatformCanvas() {
-}
-
-CanvasSkia::~CanvasSkia() {
-}
-
// static
void CanvasSkia::SizeStringInt(const string16& text,
const gfx::Font& font,
@@ -338,7 +328,7 @@ void CanvasSkia::DrawGdkPixbuf(GdkPixbuf* pixbuf, int x, int y) {
return;
}
- skia::ScopedPlatformPaint scoped_platform_paint(this);
+ skia::ScopedPlatformPaint scoped_platform_paint(canvas_);
cairo_t* cr = scoped_platform_paint.GetPlatformSurface();
gdk_cairo_set_source_pixbuf(cr, pixbuf, x, y);
cairo_paint(cr);
diff --git a/ui/gfx/canvas_skia_mac.mm b/ui/gfx/canvas_skia_mac.mm
index 6d40d0c..a20f92a 100644
--- a/ui/gfx/canvas_skia_mac.mm
+++ b/ui/gfx/canvas_skia_mac.mm
@@ -15,16 +15,6 @@
namespace gfx {
-CanvasSkia::CanvasSkia(int width, int height, bool is_opaque)
- : skia::PlatformCanvas(width, height, is_opaque) {
-}
-
-CanvasSkia::CanvasSkia() : skia::PlatformCanvas() {
-}
-
-CanvasSkia::~CanvasSkia() {
-}
-
// static
void CanvasSkia::SizeStringInt(const string16& text,
const gfx::Font& font,
@@ -48,7 +38,7 @@ void CanvasSkia::DrawStringInt(const string16& text,
if (!IntersectsClipRectInt(x, y, w, h))
return;
- skia::ScopedPlatformPaint scoped_platform_paint(this);
+ skia::ScopedPlatformPaint scoped_platform_paint(canvas_);
CGContextRef context = scoped_platform_paint.GetPlatformSurface();
CGContextSaveGState(context);
diff --git a/ui/gfx/canvas_skia_paint.h b/ui/gfx/canvas_skia_paint.h
index 1d67b37..9d1ce8a 100644
--- a/ui/gfx/canvas_skia_paint.h
+++ b/ui/gfx/canvas_skia_paint.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -12,6 +12,17 @@
// Define a gfx::CanvasSkiaPaint type that wraps our gfx::Canvas like the
// skia::PlatformCanvasPaint wraps PlatformCanvas.
+namespace skia {
+
+template<> inline
+PlatformCanvas* GetPlatformCanvas(skia::CanvasPaintT<gfx::CanvasSkia>* canvas) {
+ PlatformCanvas* platform_canvas = canvas->platform_canvas();
+ DCHECK(platform_canvas);
+ return platform_canvas;
+}
+
+} // namespace skia
+
namespace gfx {
typedef skia::CanvasPaintT<CanvasSkia> CanvasSkiaPaint;
diff --git a/ui/gfx/canvas_skia_win.cc b/ui/gfx/canvas_skia_win.cc
index e71fefd..07c08d5 100644
--- a/ui/gfx/canvas_skia_win.cc
+++ b/ui/gfx/canvas_skia_win.cc
@@ -281,16 +281,6 @@ void DivideRect(const gfx::Rect& rect,
namespace gfx {
-CanvasSkia::CanvasSkia(int width, int height, bool is_opaque)
- : skia::PlatformCanvas(width, height, is_opaque) {
-}
-
-CanvasSkia::CanvasSkia() : skia::PlatformCanvas() {
-}
-
-CanvasSkia::~CanvasSkia() {
-}
-
// static
void CanvasSkia::SizeStringInt(const string16& text,
const gfx::Font& font,
@@ -336,7 +326,7 @@ void CanvasSkia::DrawStringInt(const string16& text,
int x, int y, int w, int h,
int flags) {
SkRect fclip;
- if (!getClipBounds(&fclip))
+ if (!canvas_->getClipBounds(&fclip))
return;
RECT text_bounds = { x, y, x + w, y + h };
SkIRect clip;
@@ -354,7 +344,7 @@ void CanvasSkia::DrawStringInt(const string16& text,
HDC dc;
HFONT old_font;
{
- skia::ScopedPlatformPaint scoped_platform_paint(this);
+ skia::ScopedPlatformPaint scoped_platform_paint(canvas_);
dc = scoped_platform_paint.GetPlatformSurface();
SetBkMode(dc, TRANSPARENT);
old_font = (HFONT)SelectObject(dc, font);
@@ -373,7 +363,7 @@ void CanvasSkia::DrawStringInt(const string16& text,
// Windows will have cleared the alpha channel of the text we drew. Assume
// we're drawing to an opaque surface, or at least the text rect area is
// opaque.
- skia::MakeOpaque(this, clip.fLeft, clip.fTop, clip.width(),
+ skia::MakeOpaque(canvas_, clip.fLeft, clip.fTop, clip.width(),
clip.height());
}
@@ -438,11 +428,11 @@ void CanvasSkia::DrawStringWithHalo(const string16& text,
// opaque. We have to do this first since pixelShouldGetHalo will check for
// 0 to see if a pixel has been modified to transparent, and black text that
// Windows draw will look transparent to it!
- skia::MakeOpaque(&text_canvas, 0, 0, w + 2, h + 2);
+ skia::MakeOpaque(text_canvas.sk_canvas(), 0, 0, w + 2, h + 2);
uint32_t halo_premul = SkPreMultiplyColor(halo_color);
SkBitmap& text_bitmap = const_cast<SkBitmap&>(
- skia::GetTopDevice(text_canvas)->accessBitmap(true));
+ skia::GetTopDevice(*text_canvas.sk_canvas())->accessBitmap(true));
for (int cur_y = 0; cur_y < h + 2; cur_y++) {
uint32_t* text_row = text_bitmap.getAddr32(0, cur_y);
for (int cur_x = 0; cur_x < w + 2; cur_x++) {
@@ -541,7 +531,7 @@ void CanvasSkia::DrawFadeTruncatingString(
// Move the origin to |display_rect.origin()|. This simplifies all the
// drawing so that both the source and destination can be (0,0).
- save(kMatrix_SaveFlag);
+ canvas_->save(SkCanvas::kMatrix_SaveFlag);
TranslateInt(display_rect.x(), display_rect.y());
gfx::Rect solid_part(gfx::Point(), display_rect.size());
@@ -565,7 +555,7 @@ void CanvasSkia::DrawFadeTruncatingString(
display_rect.width(), display_rect.height(), false));
{
- skia::ScopedPlatformPaint scoped_platform_paint(this);
+ skia::ScopedPlatformPaint scoped_platform_paint(canvas_);
HDC hdc = scoped_platform_paint.GetPlatformSurface();
if (is_truncating_head)
DrawTextGradientPart(hdc, gradient_canvas.get(), text, color,
@@ -578,15 +568,15 @@ void CanvasSkia::DrawFadeTruncatingString(
}
// Draw the solid part.
- save(kClip_SaveFlag);
+ canvas_->save(SkCanvas::kClip_SaveFlag);
ClipRectInt(solid_part.x(), solid_part.y(),
solid_part.width(), solid_part.height());
DrawStringInt(text, font, color,
text_rect.x(), text_rect.y(),
text_rect.width(), text_rect.height(),
flags);
- restore();
- restore();
+ canvas_->restore();
+ canvas_->restore();
}
} // namespace gfx
diff --git a/ui/gfx/compositor/layer.cc b/ui/gfx/compositor/layer.cc
index e0a3a3a..af3514fc 100644
--- a/ui/gfx/compositor/layer.cc
+++ b/ui/gfx/compositor/layer.cc
@@ -293,7 +293,7 @@ void Layer::UpdateLayerCanvas() {
draw_rect.width(), draw_rect.height(), false));
canvas->TranslateInt(-draw_rect.x(), -draw_rect.y());
delegate_->OnPaintLayer(canvas.get());
- SetCanvas(*canvas->AsCanvasSkia(), draw_rect.origin());
+ SetCanvas(*canvas->GetSkCanvas(), draw_rect.origin());
}
void Layer::RecomputeHole() {
diff --git a/ui/gfx/compositor/layer_unittest.cc b/ui/gfx/compositor/layer_unittest.cc
index 0c839dd..df9405f 100644
--- a/ui/gfx/compositor/layer_unittest.cc
+++ b/ui/gfx/compositor/layer_unittest.cc
@@ -71,7 +71,7 @@ class LayerWithRealCompositorTest : public testing::Test {
scoped_ptr<gfx::Canvas> canvas(CreateCanvasForLayer(layer));
canvas->FillRectInt(color, 0, 0, layer->bounds().width(),
layer->bounds().height());
- layer->SetCanvas(*canvas->AsCanvasSkia(), layer->bounds().origin());
+ layer->SetCanvas(*canvas->GetSkCanvas(), layer->bounds().origin());
}
void DrawTree(Layer* root) {
@@ -238,7 +238,7 @@ class LayerWithDelegateTest : public testing::Test {
scoped_ptr<gfx::Canvas> canvas(CreateCanvasForLayer(layer));
canvas->FillRectInt(color, 0, 0, layer->bounds().width(),
layer->bounds().height());
- layer->SetCanvas(*canvas->AsCanvasSkia(), layer->bounds().origin());
+ layer->SetCanvas(canvas->GetSkCanvas(), layer->bounds().origin());
}
void DrawTree(Layer* root) {
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index 5de4260..001b4b2 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -352,11 +352,11 @@ void RenderText::Draw(Canvas* canvas) {
paint.setStyle(SkPaint::kFill_Style);
paint.setColor(i->foreground);
paint.setStrokeWidth(kStrikeWidth);
- canvas->AsCanvasSkia()->drawLine(SkIntToScalar(bounds.x()),
- SkIntToScalar(bounds.bottom()),
- SkIntToScalar(bounds.right()),
- SkIntToScalar(bounds.y()),
- paint);
+ canvas->GetSkCanvas()->drawLine(SkIntToScalar(bounds.x()),
+ SkIntToScalar(bounds.bottom()),
+ SkIntToScalar(bounds.right()),
+ SkIntToScalar(bounds.y()),
+ paint);
}
bounds.set_x(bounds.x() + bounds.width());
diff --git a/ui/gfx/render_text_linux.cc b/ui/gfx/render_text_linux.cc
index d744a94..92af95e 100644
--- a/ui/gfx/render_text_linux.cc
+++ b/ui/gfx/render_text_linux.cc
@@ -94,7 +94,7 @@ void RenderTextLinux::Draw(Canvas* canvas) {
Rect bounds(display_rect());
// Clip the canvas to the text display area.
- CanvasSkia* canvas_skia = canvas->AsCanvasSkia();
+ SkCanvas* canvas_skia = canvas->GetSkCanvas();
skia::ScopedPlatformPaint scoped_platform_paint(canvas_skia);
cairo_t* cr = scoped_platform_paint.GetPlatformSurface();
@@ -498,7 +498,7 @@ SelectionModel RenderTextLinux::RightSelectionModelByWord(
PangoLayout* RenderTextLinux::EnsureLayout() {
if (layout_ == NULL) {
CanvasSkia canvas(display_rect().width(), display_rect().height(), false);
- skia::ScopedPlatformPaint scoped_platform_paint(&canvas);
+ skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas());
cairo_t* cr = scoped_platform_paint.GetPlatformSurface();
layout_ = pango_cairo_create_layout(cr);
diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc
index f6b983d..114a963 100644
--- a/ui/gfx/render_text_win.cc
+++ b/ui/gfx/render_text_win.cc
@@ -100,7 +100,7 @@ int RenderTextWin::GetStringWidth() {
}
void RenderTextWin::Draw(Canvas* canvas) {
- skia::ScopedPlatformPaint scoped_platform_paint(canvas->AsCanvasSkia());
+ skia::ScopedPlatformPaint scoped_platform_paint(canvas->GetSkCanvas());
HDC hdc = scoped_platform_paint.GetPlatformSurface();
int saved_dc = SaveDC(hdc);
DrawSelection(canvas);
@@ -590,7 +590,7 @@ void RenderTextWin::DrawVisualText(Canvas* canvas) {
if (text().empty())
return;
- CanvasSkia* canvas_skia = canvas->AsCanvasSkia();
+ SkCanvas* canvas_skia = canvas->GetSkCanvas();
skia::ScopedPlatformPaint scoped_platform_paint(canvas_skia);
Point offset(ToViewPoint(Point()));
@@ -645,11 +645,11 @@ void RenderTextWin::DrawVisualText(Canvas* canvas) {
strike.setStyle(SkPaint::kFill_Style);
strike.setColor(run->foreground);
strike.setStrokeWidth(kStrikeWidth);
- canvas->AsCanvasSkia()->drawLine(SkIntToScalar(bounds.x()),
- SkIntToScalar(bounds.bottom()),
- SkIntToScalar(bounds.right()),
- SkIntToScalar(bounds.y()),
- strike);
+ canvas->GetSkCanvas()->drawLine(SkIntToScalar(bounds.x()),
+ SkIntToScalar(bounds.bottom()),
+ SkIntToScalar(bounds.right()),
+ SkIntToScalar(bounds.y()),
+ strike);
}
offset.Offset(run->width, 0);
}