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

Unified Diff: ui/gfx/canvas_skia_win.cc

Issue 6879013: skia::PlatformCanvas is being deprecated. Going forward we will use gfx::Canvas wherever we need ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
« no previous file with comments | « ui/gfx/canvas_skia_paint_win.cc ('k') | ui/gfx/image.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/canvas_skia_win.cc
===================================================================
--- ui/gfx/canvas_skia_win.cc (revision 82144)
+++ ui/gfx/canvas_skia_win.cc (working copy)
@@ -275,16 +275,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,
@@ -330,7 +320,7 @@
int x, int y, int w, int h,
int flags) {
SkRect fclip;
- if (!getClipBounds(&fclip))
+ if (!skia_canvas_->getClipBounds(&fclip))
return;
RECT text_bounds = { x, y, x + w, y + h };
SkIRect clip;
@@ -345,7 +335,7 @@
const int kMaxStringLength = 32768 - 1; // So the trailing \0 fits in 32K.
string16 clamped_string(text.substr(0, kMaxStringLength));
- HDC dc = beginPlatformPaint();
+ HDC dc = BeginPlatformPaint();
SetBkMode(dc, TRANSPARENT);
HFONT old_font = (HFONT)SelectObject(dc, font);
COLORREF brush_color = RGB(SkColorGetR(color), SkColorGetG(color),
@@ -354,7 +344,7 @@
int f = ComputeFormatFlags(flags, clamped_string);
DoDrawText(dc, clamped_string, &text_bounds, f);
- endPlatformPaint();
+ EndPlatformPaint();
// Restore the old font. This way we don't have to worry if the caller
// deletes the font and the DC lives longer.
@@ -363,8 +353,7 @@
// 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.
- getTopPlatformDevice().makeOpaque(clip.fLeft, clip.fTop,
- clip.width(), clip.height());
+ skia::MakeOpaque(clip, skia_canvas_.get());
}
void CanvasSkia::DrawStringInt(const string16& text,
@@ -415,7 +404,10 @@
// Create a temporary buffer filled with the halo color. It must leave room
// for the 1-pixel border around the text.
- CanvasSkia text_canvas(w + 2, h + 2, true);
+ CanvasSkia text_canvas;
+ if (!text_canvas.Init(w + 2, h + 2, true))
+ return;
+
SkPaint bkgnd_paint;
bkgnd_paint.setColor(halo_color);
text_canvas.DrawRectInt(0, 0, w + 2, h + 2, bkgnd_paint);
@@ -428,11 +420,11 @@
// 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!
- text_canvas.getTopPlatformDevice().makeOpaque(0, 0, w + 2, h + 2);
+ skia::MakeOpaque(SkIRect::MakeWH(w + 2, h + 2), text_canvas.skia_canvas());
uint32_t halo_premul = SkPreMultiplyColor(halo_color);
SkBitmap& text_bitmap = const_cast<SkBitmap&>(
- text_canvas.getTopPlatformDevice().accessBitmap(true));
+ text_canvas.skia_canvas()->getTopDevice()->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++) {
@@ -531,7 +523,7 @@
// 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);
+ skia_canvas_->save(SkCanvas::kMatrix_SaveFlag);
TranslateInt(display_rect.x(), display_rect.y());
gfx::Rect solid_part(gfx::Point(), display_rect.size());
@@ -563,25 +555,35 @@
display_rect.width(), display_rect.height(), false, NULL));
DCHECK(gradient_bitmap.get());
- HDC hdc = beginPlatformPaint();
+ HDC hdc = BeginPlatformPaint();
if (is_truncating_head)
DrawTextGradientPart(hdc, *gradient_bitmap, text, color, gray_scale_font,
text_rect, head_part, is_rtl, flags);
if (is_truncating_tail)
DrawTextGradientPart(hdc, *gradient_bitmap, text, color, gray_scale_font,
text_rect, tail_part, !is_rtl, flags);
- endPlatformPaint();
+ EndPlatformPaint();
// Draw the solid part.
- save(kClip_SaveFlag);
+ skia_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();
+ skia_canvas_->restore();
+ skia_canvas_->restore();
}
+void CanvasSkia::BlitToNativeContext(const Rect& src_rect,
+ const Point& dst_origin,
+ NativeDrawingContext dst_context) {
+ skia::BitmapPlatformDevice* device =
+ static_cast<skia::BitmapPlatformDevice*>(skia_canvas_->getTopDevice());
+ device->drawToHDC(dst_context, dst_origin.x(), dst_origin.y(),
+ &src_rect.ToRECT());
+}
+
} // namespace gfx
+
« no previous file with comments | « ui/gfx/canvas_skia_paint_win.cc ('k') | ui/gfx/image.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698