Clean-up: Removes obsolete methods in gfx::Canvas.

Removes unused obsolete methods in gfx::Canvas.

I'm planning to remove gfx::Canvas::GetStringWidth(text, font) in a separate CL when I finish rewriting the client code.

BUG=265485
TEST=none

Review URL: https://codereview.chromium.org/141003013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247980 0039d316-1c4b-4281-b951-d872f2087c98
parent 863b9140
...@@ -97,16 +97,6 @@ void Canvas::SizeStringInt(const base::string16& text, ...@@ -97,16 +97,6 @@ void Canvas::SizeStringInt(const base::string16& text,
*height = std::ceil(factional_height); *height = std::ceil(factional_height);
} }
// static
void Canvas::SizeStringInt(const base::string16& text,
const Font& font,
int* width,
int* height,
int line_height,
int flags) {
SizeStringInt(text, FontList(font), width, height, line_height, flags);
}
// static // static
int Canvas::GetStringWidth(const base::string16& text, int Canvas::GetStringWidth(const base::string16& text,
const FontList& font_list) { const FontList& font_list) {
...@@ -135,19 +125,6 @@ int Canvas::DefaultCanvasTextAlignment() { ...@@ -135,19 +125,6 @@ int Canvas::DefaultCanvasTextAlignment() {
return base::i18n::IsRTL() ? TEXT_ALIGN_RIGHT : TEXT_ALIGN_LEFT; return base::i18n::IsRTL() ? TEXT_ALIGN_RIGHT : TEXT_ALIGN_LEFT;
} }
void Canvas::DrawStringWithHalo(const base::string16& text,
const Font& font,
SkColor text_color,
SkColor halo_color_in,
int x,
int y,
int w,
int h,
int flags) {
DrawStringRectWithHalo(text, FontList(font), text_color, halo_color_in,
Rect(x, y, w, h), flags);
}
ImageSkiaRep Canvas::ExtractImageRep() const { ImageSkiaRep Canvas::ExtractImageRep() const {
const SkBitmap& device_bitmap = canvas_->getDevice()->accessBitmap(false); const SkBitmap& device_bitmap = canvas_->getDevice()->accessBitmap(false);
...@@ -501,47 +478,6 @@ void Canvas::DrawStringRectWithFlags(const base::string16& text, ...@@ -501,47 +478,6 @@ void Canvas::DrawStringRectWithFlags(const base::string16& text,
ShadowValues()); ShadowValues());
} }
void Canvas::DrawStringInt(const base::string16& text,
const Font& font,
SkColor color,
int x,
int y,
int w,
int h) {
DrawStringInt(text, font, color, x, y, w, h, DefaultCanvasTextAlignment());
}
void Canvas::DrawStringInt(const base::string16& text,
const Font& font,
SkColor color,
const Rect& display_rect) {
DrawStringInt(text, font, color, display_rect.x(), display_rect.y(),
display_rect.width(), display_rect.height());
}
void Canvas::DrawStringInt(const base::string16& text,
const Font& font,
SkColor color,
int x,
int y,
int w,
int h,
int flags) {
DrawStringWithShadows(text, font, color, Rect(x, y, w, h), 0, flags,
ShadowValues());
}
void Canvas::DrawStringWithShadows(const base::string16& text,
const Font& font,
SkColor color,
const Rect& text_bounds,
int line_height,
int flags,
const ShadowValues& shadows) {
DrawStringRectWithShadows(text, FontList(font), color, text_bounds,
line_height, flags, shadows);
}
void Canvas::TileImageInt(const ImageSkia& image, void Canvas::TileImageInt(const ImageSkia& image,
int x, int x,
int y, int y,
......
...@@ -45,7 +45,7 @@ class GFX_EXPORT Canvas { ...@@ -45,7 +45,7 @@ class GFX_EXPORT Canvas {
TruncateFadeHead, TruncateFadeHead,
}; };
// Specifies the alignment for text rendered with the DrawStringInt method. // Specifies the alignment for text rendered with the DrawStringRect method.
enum { enum {
TEXT_ALIGN_LEFT = 1 << 0, TEXT_ALIGN_LEFT = 1 << 0,
TEXT_ALIGN_CENTER = 1 << 1, TEXT_ALIGN_CENTER = 1 << 1,
...@@ -54,7 +54,7 @@ class GFX_EXPORT Canvas { ...@@ -54,7 +54,7 @@ class GFX_EXPORT Canvas {
// Specifies the text consists of multiple lines. // Specifies the text consists of multiple lines.
MULTI_LINE = 1 << 3, MULTI_LINE = 1 << 3,
// By default DrawStringInt does not process the prefix ('&') character // By default DrawStringRect does not process the prefix ('&') character
// specially. That is, the string "&foo" is rendered as "&foo". When // specially. That is, the string "&foo" is rendered as "&foo". When
// rendering text from a resource that uses the prefix character for // rendering text from a resource that uses the prefix character for
// mnemonics, the prefix should be processed and can be rendered as an // mnemonics, the prefix should be processed and can be rendered as an
...@@ -69,7 +69,7 @@ class GFX_EXPORT Canvas { ...@@ -69,7 +69,7 @@ class GFX_EXPORT Canvas {
// This only works with MULTI_LINE. // This only works with MULTI_LINE.
CHARACTER_BREAK = 1 << 7, CHARACTER_BREAK = 1 << 7,
// Instructs DrawStringInt() to render the text using RTL directionality. // Instructs DrawStringRect() to render the text using RTL directionality.
// In most cases, passing this flag is not necessary because information // In most cases, passing this flag is not necessary because information
// about the text directionality is going to be embedded within the string // about the text directionality is going to be embedded within the string
// in the form of special Unicode characters. However, we don't insert // in the form of special Unicode characters. However, we don't insert
...@@ -83,7 +83,7 @@ class GFX_EXPORT Canvas { ...@@ -83,7 +83,7 @@ class GFX_EXPORT Canvas {
// See FORCE_RTL_DIRECTIONALITY for details. // See FORCE_RTL_DIRECTIONALITY for details.
FORCE_LTR_DIRECTIONALITY = 1 << 9, FORCE_LTR_DIRECTIONALITY = 1 << 9,
// Instructs DrawStringInt() to not use subpixel rendering. This is useful // Instructs DrawStringRect() to not use subpixel rendering. This is useful
// when rendering text onto a fully- or partially-transparent background // when rendering text onto a fully- or partially-transparent background
// that will later be blended with another image. // that will later be blended with another image.
NO_SUBPIXEL_RENDERING = 1 << 10, NO_SUBPIXEL_RENDERING = 1 << 10,
...@@ -130,13 +130,6 @@ class GFX_EXPORT Canvas { ...@@ -130,13 +130,6 @@ class GFX_EXPORT Canvas {
int* height, int* height,
int line_height, int line_height,
int flags); int flags);
// Obsolete version. Use the above version which takes FontList.
static void SizeStringInt(const base::string16& text,
const Font& font,
int* width,
int* height,
int line_height,
int flags);
// This is same as SizeStringInt except that fractional size is returned. // This is same as SizeStringInt except that fractional size is returned.
// See comment in GetStringWidthF for its usage. // See comment in GetStringWidthF for its usage.
...@@ -164,7 +157,7 @@ class GFX_EXPORT Canvas { ...@@ -164,7 +157,7 @@ class GFX_EXPORT Canvas {
// Returns the default text alignment to be used when drawing text on a // Returns the default text alignment to be used when drawing text on a
// Canvas based on the directionality of the system locale language. // Canvas based on the directionality of the system locale language.
// This function is used by Canvas::DrawStringInt when the text alignment // This function is used by Canvas::DrawStringRect when the text alignment
// is not specified. // is not specified.
// //
// This function returns either Canvas::TEXT_ALIGN_LEFT or // This function returns either Canvas::TEXT_ALIGN_LEFT or
...@@ -186,16 +179,6 @@ class GFX_EXPORT Canvas { ...@@ -186,16 +179,6 @@ class GFX_EXPORT Canvas {
SkColor halo_color, SkColor halo_color,
const Rect& display_rect, const Rect& display_rect,
int flags); int flags);
// Obsolete version. Use the above version which takes FontList.
void DrawStringWithHalo(const base::string16& text,
const Font& font,
SkColor text_color,
SkColor halo_color,
int x,
int y,
int w,
int h,
int flags);
// Extracts an ImageSkiaRep from the contents of this canvas. // Extracts an ImageSkiaRep from the contents of this canvas.
ImageSkiaRep ExtractImageRep() const; ImageSkiaRep ExtractImageRep() const;
...@@ -356,18 +339,6 @@ class GFX_EXPORT Canvas { ...@@ -356,18 +339,6 @@ class GFX_EXPORT Canvas {
const FontList& font_list, const FontList& font_list,
SkColor color, SkColor color,
const Rect& display_rect); const Rect& display_rect);
// Obsolete versions. Use the above versions which take FontList.
void DrawStringInt(const base::string16& text,
const Font& font,
SkColor color,
int x,
int y,
int w,
int h);
void DrawStringInt(const base::string16& text,
const Font& font,
SkColor color,
const Rect& display_rect);
// Draws text with the specified color, fonts and location. The last argument // Draws text with the specified color, fonts and location. The last argument
// specifies flags for how the text should be rendered. It can be one of // specifies flags for how the text should be rendered. It can be one of
...@@ -377,17 +348,8 @@ class GFX_EXPORT Canvas { ...@@ -377,17 +348,8 @@ class GFX_EXPORT Canvas {
SkColor color, SkColor color,
const Rect& display_rect, const Rect& display_rect,
int flags); int flags);
// Obsolete version. Use the above version which takes FontList.
void DrawStringInt(const base::string16& text, // Similar to above DrawStringRect method but with text shadows support.
const Font& font,
SkColor color,
int x,
int y,
int w,
int h,
int flags);
// Similar to above DrawStringInt method but with text shadows support.
// Currently it's only implemented for canvas skia. Specifying a 0 line_height // Currently it's only implemented for canvas skia. Specifying a 0 line_height
// will cause the default height to be used. // will cause the default height to be used.
void DrawStringRectWithShadows(const base::string16& text, void DrawStringRectWithShadows(const base::string16& text,
...@@ -397,14 +359,6 @@ class GFX_EXPORT Canvas { ...@@ -397,14 +359,6 @@ class GFX_EXPORT Canvas {
int line_height, int line_height,
int flags, int flags,
const ShadowValues& shadows); const ShadowValues& shadows);
// Obsolete version. Use the above version which takes FontList.
void DrawStringWithShadows(const base::string16& text,
const Font& font,
SkColor color,
const Rect& text_bounds,
int line_height,
int flags,
const ShadowValues& shadows);
// Draws a dotted gray rectangle used for focus purposes. // Draws a dotted gray rectangle used for focus purposes.
void DrawFocusRect(const Rect& rect); void DrawFocusRect(const Rect& rect);
......
...@@ -2,32 +2,34 @@ ...@@ -2,32 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/gfx/canvas.h"
#include <limits> #include <limits>
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/font_list.h"
#include "ui/gfx/font.h"
namespace gfx { namespace gfx {
class CanvasTest : public testing::Test { class CanvasTest : public testing::Test {
protected: protected:
int GetStringWidth(const char *text) { int GetStringWidth(const char *text) {
return Canvas::GetStringWidth(base::UTF8ToUTF16(text), font_); return Canvas::GetStringWidth(base::UTF8ToUTF16(text), font_list_);
} }
gfx::Size SizeStringInt(const char *text, int width, int line_height) { gfx::Size SizeStringInt(const char *text, int width, int line_height) {
base::string16 text16 = base::UTF8ToUTF16(text); base::string16 text16 = base::UTF8ToUTF16(text);
int height = 0; int height = 0;
int flags = int flags =
(text16.find('\n') != base::string16::npos) ? Canvas::MULTI_LINE : 0; (text16.find('\n') != base::string16::npos) ? Canvas::MULTI_LINE : 0;
Canvas::SizeStringInt(text16, font_, &width, &height, line_height, flags); Canvas::SizeStringInt(text16, font_list_, &width, &height, line_height,
flags);
return gfx::Size(width, height); return gfx::Size(width, height);
} }
private: private:
gfx::Font font_; FontList font_list_;
}; };
TEST_F(CanvasTest, StringWidth) { TEST_F(CanvasTest, StringWidth) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment