Index: ui/gfx/canvas.cc |
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc |
index 2b0f5046cf0ced0cccf96b9274e1b8965af1e667..ff13156984bc15c7fe40e1926c26978d78c4283d 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,10 +87,42 @@ 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) { |
+#if defined(OS_ANDROID) |
msw
2013/08/16 16:59:25
I believe avoiding these platform-specific preproc
Yuki
2013/08/16 17:24:31
Note that these defined(OS_ANDROID) appear only in
msw
2013/08/16 17:31:39
If the obsolete redirection methods can be consoli
Yuki
2013/08/16 18:29:28
Okay, I'll leave the redirection code here in canv
|
+ NOTIMPLEMENTED(); |
+#else |
+ SizeStringInt(text, gfx::FontList(font), width, height, line_height, flags); |
+#endif |
+} |
+ |
+// static |
+int Canvas::GetStringWidth(const base::string16& text, |
+ const gfx::FontList& font_list) { |
+#if defined(OS_ANDROID) |
+ NOTIMPLEMENTED(); |
+ return 0; |
+#else |
+ int width = 0, height = 0; |
+ SizeStringInt(text, font_list, &width, &height, 0, NO_ELLIPSIS); |
+ return width; |
+#endif |
+} |
+ |
+// static |
int Canvas::GetStringWidth(const base::string16& text, const gfx::Font& font) { |
+#if defined(OS_ANDROID) |
+ NOTIMPLEMENTED(); |
+ return 0; |
+#else |
int width = 0, height = 0; |
- Canvas::SizeStringInt(text, font, &width, &height, 0, NO_ELLIPSIS); |
+ SizeStringInt(text, gfx::FontList(font), &width, &height, 0, NO_ELLIPSIS); |
return width; |
+#endif |
} |
// static |
@@ -98,6 +130,23 @@ 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) { |
+#if defined(OS_ANDROID) || defined(OS_IOS) |
+ NOTIMPLEMENTED(); |
+#else |
+ DrawStringWithHaloRect(text, gfx::FontList(font), text_color, halo_color_in, |
+ gfx::Rect(x, y, w, h), flags); |
+#endif |
+} |
+ |
gfx::ImageSkiaRep Canvas::ExtractImageRep() const { |
const SkBitmap& device_bitmap = canvas_->getDevice()->accessBitmap(false); |
@@ -297,7 +346,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 +366,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 +381,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 +471,38 @@ void Canvas::DrawImageInPath(const gfx::ImageSkia& image, |
canvas_->drawPath(path, p); |
} |
+void Canvas::DrawStringRect(const base::string16& text, |
+ const gfx::FontList& font_list, |
+ SkColor color, |
+ const gfx::Rect& display_rect) { |
+#if defined(OS_ANDROID) || defined(OS_IOS) |
+ NOTIMPLEMENTED(); |
+#else |
+ DrawStringWithFlagsRect(text, font_list, color, display_rect, |
+ DefaultCanvasTextAlignment()); |
+#endif |
+} |
+ |
+void Canvas::DrawStringWithFlagsRect(const base::string16& text, |
+ const gfx::FontList& font_list, |
+ SkColor color, |
+ const gfx::Rect& display_rect, |
+ int flags) { |
+#if defined(OS_ANDROID) || defined(OS_IOS) |
+ NOTIMPLEMENTED(); |
+#else |
+ DrawStringWithShadowsRect(text, font_list, color, display_rect, 0, flags, |
+ ShadowValues()); |
+#endif |
+} |
+ |
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,32 +517,57 @@ 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, |
- color, |
- gfx::Rect(x, y, w, h), |
- 0, |
- flags, |
+ DrawStringWithShadows(text, font, color, gfx::Rect(x, y, w, h), 0, flags, |
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) { |
+#if defined(OS_ANDROID) || defined(OS_IOS) |
+ NOTIMPLEMENTED(); |
+#else |
+ DrawStringWithShadowsRect(text, gfx::FontList(font), color, text_bounds, |
+ line_height, flags, shadows); |
+#endif |
+} |
+ |
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 +610,22 @@ 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) { |
+#if defined(OS_ANDROID) || defined(OS_IOS) || defined(OS_MACOSX) |
+ NOTIMPLEMENTED(); |
+#else |
+ DrawFadeTruncatingStringRect(text, truncate_mode, |
+ desired_characters_to_truncate_from_head, |
+ gfx::FontList(font), color, display_rect); |
+#endif |
+} |
+ |
Canvas::Canvas(SkCanvas* canvas, ui::ScaleFactor scale_factor) |
: scale_factor_(scale_factor), |
owned_canvas_(), |