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

Unified Diff: ui/gfx/canvas.cc

Issue 22835002: Supports gfx::FontList in gfx::Canvas and ui::ElideText family. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/NOTREACHED/NOTIMPLEMENTED/ Created 7 years, 4 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.cc
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index 2b0f5046cf0ced0cccf96b9274e1b8965af1e667..062616a442c7a2e93a1c7313d772bc7ecc1bfb78 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,17 +87,23 @@ void Canvas::RecreateBackingCanvas(const gfx::Size& size,
}
// 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);
- return width;
-}
-
-// static
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) {
+ DrawStringWithHaloRect(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 +303,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 +323,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 +338,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 +428,30 @@ 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) {
+ DrawStringWithFlagsRect(text, font_list, color, display_rect,
+ DefaultCanvasTextAlignment());
+}
+
+void Canvas::DrawStringWithFlagsRect(const base::string16& text,
+ const gfx::FontList& font_list,
+ SkColor color,
+ const gfx::Rect& display_rect,
+ int flags) {
+ DrawStringWithShadowsRect(text, 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,32 +466,53 @@ 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) {
+ DrawStringWithShadowsRect(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;

Powered by Google App Engine
This is Rietveld 408576698