Index: ui/gfx/canvas.cc |
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc |
index 2b0f5046cf0ced0cccf96b9274e1b8965af1e667..8fda4f232697029ee4cac591b83b3014ddae0d38 100644 |
--- a/ui/gfx/canvas.cc |
+++ b/ui/gfx/canvas.cc |
@@ -11,7 +11,7 @@ |
#include "third_party/skia/include/core/SkBitmap.h" |
#include "third_party/skia/include/effects/SkGradientShader.h" |
#include "ui/gfx/canvas.h" |
-#include "ui/gfx/font.h" |
+#include "ui/gfx/font_list.h" |
#include "ui/gfx/rect.h" |
#include "ui/gfx/size_conversions.h" |
#include "ui/gfx/skia_util.h" |
@@ -87,9 +87,29 @@ void Canvas::RecreateBackingCanvas(const gfx::Size& size, |
} |
// static |
+void Canvas::SizeStringInt(const base::string16& text, |
+ const gfx::Font& font, |
+ int* width, |
+ int* height, |
+ int line_height, |
+ int flags) { |
+ Canvas::SizeStringInt(text, gfx::FontList(font), width, height, line_height, |
msw
2013/08/13 17:39:22
nit: you shouldn't need to explicitly qualify canv
Yuki
2013/08/14 15:42:16
Done.
|
+ flags); |
+} |
+ |
+// static |
+int Canvas::GetStringWidth(const base::string16& text, |
+ const gfx::FontList& font_list) { |
+ int width = 0, height = 0; |
+ Canvas::SizeStringInt(text, font_list, &width, &height, 0, NO_ELLIPSIS); |
+ return width; |
+} |
+ |
+// static |
int Canvas::GetStringWidth(const base::string16& text, const gfx::Font& font) { |
int width = 0, height = 0; |
- Canvas::SizeStringInt(text, font, &width, &height, 0, NO_ELLIPSIS); |
+ Canvas::SizeStringInt(text, gfx::FontList(font), &width, &height, 0, |
+ NO_ELLIPSIS); |
return width; |
} |
@@ -98,6 +118,19 @@ int Canvas::DefaultCanvasTextAlignment() { |
return base::i18n::IsRTL() ? TEXT_ALIGN_RIGHT : TEXT_ALIGN_LEFT; |
} |
+void Canvas::DrawStringWithHalo(const base::string16& text, |
+ const gfx::Font& font, |
+ SkColor text_color, |
+ SkColor halo_color_in, |
+ int x, |
+ int y, |
+ int w, |
+ int h, |
+ int flags) { |
+ Canvas::DrawStringWithHalo(text, gfx::FontList(font), text_color, |
+ halo_color_in, gfx::Rect(x, y, w, h), flags); |
+} |
+ |
gfx::ImageSkiaRep Canvas::ExtractImageRep() const { |
const SkBitmap& device_bitmap = canvas_->getDevice()->accessBitmap(false); |
@@ -297,7 +330,8 @@ void Canvas::DrawImageInt(const gfx::ImageSkia& image, int x, int y, uint8 a) { |
} |
void Canvas::DrawImageInt(const gfx::ImageSkia& image, |
- int x, int y, |
+ int x, |
+ int y, |
const SkPaint& paint) { |
const gfx::ImageSkiaRep& image_rep = GetImageRepToPaint(image); |
if (image_rep.is_null()) |
@@ -316,8 +350,14 @@ void Canvas::DrawImageInt(const gfx::ImageSkia& image, |
} |
void Canvas::DrawImageInt(const gfx::ImageSkia& image, |
- int src_x, int src_y, int src_w, int src_h, |
- int dest_x, int dest_y, int dest_w, int dest_h, |
+ int src_x, |
+ int src_y, |
+ int src_w, |
+ int src_h, |
+ int dest_x, |
+ int dest_y, |
+ int dest_w, |
+ int dest_h, |
bool filter) { |
SkPaint p; |
DrawImageInt(image, src_x, src_y, src_w, src_h, dest_x, dest_y, |
@@ -325,8 +365,14 @@ void Canvas::DrawImageInt(const gfx::ImageSkia& image, |
} |
void Canvas::DrawImageInt(const gfx::ImageSkia& image, |
- int src_x, int src_y, int src_w, int src_h, |
- int dest_x, int dest_y, int dest_w, int dest_h, |
+ int src_x, |
+ int src_y, |
+ int src_w, |
+ int src_h, |
+ int dest_x, |
+ int dest_y, |
+ int dest_w, |
+ int dest_h, |
bool filter, |
const SkPaint& paint) { |
DLOG_ASSERT(src_x + src_w < std::numeric_limits<int16_t>::max() && |
@@ -409,10 +455,35 @@ void Canvas::DrawImageInPath(const gfx::ImageSkia& image, |
canvas_->drawPath(path, p); |
} |
+void Canvas::DrawString(const base::string16& text, |
+ const gfx::FontList& font_list, |
+ SkColor color, |
+ const gfx::Rect& display_rect) { |
+ DrawStringWithFlags(text, font_list, color, display_rect, |
+ DefaultCanvasTextAlignment()); |
+} |
+ |
+void Canvas::DrawStringWithFlags(const base::string16& text, |
+ const gfx::FontList& font_list, |
+ SkColor color, |
+ const gfx::Rect& display_rect, |
+ int flags) { |
+ DrawStringWithShadows(text, |
msw
2013/08/13 17:39:22
nit: wrap some args here.
Yuki
2013/08/14 15:42:16
Done.
|
+ font_list, |
+ color, |
+ display_rect, |
+ 0, |
+ flags, |
+ ShadowValues()); |
+} |
+ |
void Canvas::DrawStringInt(const base::string16& text, |
const gfx::Font& font, |
SkColor color, |
- int x, int y, int w, int h) { |
+ int x, |
+ int y, |
+ int w, |
+ int h) { |
DrawStringInt(text, font, color, x, y, w, h, DefaultCanvasTextAlignment()); |
} |
@@ -427,7 +498,10 @@ void Canvas::DrawStringInt(const base::string16& text, |
void Canvas::DrawStringInt(const base::string16& text, |
const gfx::Font& font, |
SkColor color, |
- int x, int y, int w, int h, |
+ int x, |
+ int y, |
+ int w, |
+ int h, |
int flags) { |
DrawStringWithShadows(text, |
font, |
@@ -438,21 +512,44 @@ void Canvas::DrawStringInt(const base::string16& text, |
ShadowValues()); |
} |
+void Canvas::DrawStringWithShadows(const base::string16& text, |
+ const gfx::Font& font, |
+ SkColor color, |
+ const gfx::Rect& text_bounds, |
+ int line_height, |
+ int flags, |
+ const ShadowValues& shadows) { |
+ DrawStringWithShadows(text, gfx::FontList(font), color, text_bounds, |
+ line_height, flags, shadows); |
+} |
+ |
void Canvas::TileImageInt(const gfx::ImageSkia& image, |
- int x, int y, int w, int h) { |
+ int x, |
+ int y, |
+ int w, |
+ int h) { |
TileImageInt(image, 0, 0, x, y, w, h); |
} |
void Canvas::TileImageInt(const gfx::ImageSkia& image, |
- int src_x, int src_y, |
- int dest_x, int dest_y, int w, int h) { |
+ int src_x, |
+ int src_y, |
+ int dest_x, |
+ int dest_y, |
+ int w, |
+ int h) { |
TileImageInt(image, src_x, src_y, 1.0f, 1.0f, dest_x, dest_y, w, h); |
} |
void Canvas::TileImageInt(const gfx::ImageSkia& image, |
- int src_x, int src_y, |
- float tile_scale_x, float tile_scale_y, |
- int dest_x, int dest_y, int w, int h) { |
+ int src_x, |
+ int src_y, |
+ float tile_scale_x, |
+ float tile_scale_y, |
+ int dest_x, |
+ int dest_y, |
+ int w, |
+ int h) { |
if (!IntersectsClipRectInt(dest_x, dest_y, w, h)) |
return; |
@@ -495,6 +592,18 @@ void Canvas::Transform(const gfx::Transform& transform) { |
canvas_->concat(transform.matrix()); |
} |
+void Canvas::DrawFadeTruncatingString( |
+ const base::string16& text, |
+ TruncateFadeMode truncate_mode, |
+ size_t desired_characters_to_truncate_from_head, |
+ const gfx::Font& font, |
+ SkColor color, |
+ const gfx::Rect& display_rect) { |
+ DrawFadeTruncatingString(text, truncate_mode, |
+ desired_characters_to_truncate_from_head, |
+ gfx::FontList(font), color, display_rect); |
+} |
+ |
Canvas::Canvas(SkCanvas* canvas, ui::ScaleFactor scale_factor) |
: scale_factor_(scale_factor), |
owned_canvas_(), |