Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Unified Diff: ui/gfx/canvas_skia_win.cc

Issue 8122013: Allow CanvasSkia to bind to an existing SkCanvas. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 1 more fix Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/canvas_skia_win.cc
diff --git a/ui/gfx/canvas_skia_win.cc b/ui/gfx/canvas_skia_win.cc
index e71fefdc2a441607cf3da37b6a47f283d22d8a66..07c08d58605092eded83987060a6e5720ecd2b9f 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
« ui/gfx/canvas.h ('K') | « ui/gfx/canvas_skia_paint.h ('k') | ui/gfx/compositor/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698