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

Side by Side Diff: ui/gfx/canvas.cc

Issue 141003013: Clean-up: Removes obsolete methods in gfx::Canvas. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/canvas.h ('k') | ui/gfx/canvas_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/canvas.h" 5 #include "ui/gfx/canvas.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 int flags) { 91 int flags) {
92 float fractional_width = *width; 92 float fractional_width = *width;
93 float factional_height = *height; 93 float factional_height = *height;
94 SizeStringFloat(text, font_list, &fractional_width, 94 SizeStringFloat(text, font_list, &fractional_width,
95 &factional_height, line_height, flags); 95 &factional_height, line_height, flags);
96 *width = std::ceil(fractional_width); 96 *width = std::ceil(fractional_width);
97 *height = std::ceil(factional_height); 97 *height = std::ceil(factional_height);
98 } 98 }
99 99
100 // static 100 // static
101 void Canvas::SizeStringInt(const base::string16& text,
102 const Font& font,
103 int* width,
104 int* height,
105 int line_height,
106 int flags) {
107 SizeStringInt(text, FontList(font), width, height, line_height, flags);
108 }
109
110 // static
111 int Canvas::GetStringWidth(const base::string16& text, 101 int Canvas::GetStringWidth(const base::string16& text,
112 const FontList& font_list) { 102 const FontList& font_list) {
113 int width = 0, height = 0; 103 int width = 0, height = 0;
114 SizeStringInt(text, font_list, &width, &height, 0, NO_ELLIPSIS); 104 SizeStringInt(text, font_list, &width, &height, 0, NO_ELLIPSIS);
115 return width; 105 return width;
116 } 106 }
117 107
118 // static 108 // static
119 float Canvas::GetStringWidthF(const base::string16& text, 109 float Canvas::GetStringWidthF(const base::string16& text,
120 const FontList& font_list) { 110 const FontList& font_list) {
121 float width = 0, height = 0; 111 float width = 0, height = 0;
122 SizeStringFloat(text, font_list, &width, &height, 0, NO_ELLIPSIS); 112 SizeStringFloat(text, font_list, &width, &height, 0, NO_ELLIPSIS);
123 return width; 113 return width;
124 } 114 }
125 115
126 // static 116 // static
127 int Canvas::GetStringWidth(const base::string16& text, const Font& font) { 117 int Canvas::GetStringWidth(const base::string16& text, const Font& font) {
128 int width = 0, height = 0; 118 int width = 0, height = 0;
129 SizeStringInt(text, FontList(font), &width, &height, 0, NO_ELLIPSIS); 119 SizeStringInt(text, FontList(font), &width, &height, 0, NO_ELLIPSIS);
130 return width; 120 return width;
131 } 121 }
132 122
133 // static 123 // static
134 int Canvas::DefaultCanvasTextAlignment() { 124 int Canvas::DefaultCanvasTextAlignment() {
135 return base::i18n::IsRTL() ? TEXT_ALIGN_RIGHT : TEXT_ALIGN_LEFT; 125 return base::i18n::IsRTL() ? TEXT_ALIGN_RIGHT : TEXT_ALIGN_LEFT;
136 } 126 }
137 127
138 void Canvas::DrawStringWithHalo(const base::string16& text,
139 const Font& font,
140 SkColor text_color,
141 SkColor halo_color_in,
142 int x,
143 int y,
144 int w,
145 int h,
146 int flags) {
147 DrawStringRectWithHalo(text, FontList(font), text_color, halo_color_in,
148 Rect(x, y, w, h), flags);
149 }
150
151 ImageSkiaRep Canvas::ExtractImageRep() const { 128 ImageSkiaRep Canvas::ExtractImageRep() const {
152 const SkBitmap& device_bitmap = canvas_->getDevice()->accessBitmap(false); 129 const SkBitmap& device_bitmap = canvas_->getDevice()->accessBitmap(false);
153 130
154 // Make a bitmap to return, and a canvas to draw into it. We don't just want 131 // Make a bitmap to return, and a canvas to draw into it. We don't just want
155 // to call extractSubset or the copy constructor, since we want an actual copy 132 // to call extractSubset or the copy constructor, since we want an actual copy
156 // of the bitmap. 133 // of the bitmap.
157 SkBitmap result; 134 SkBitmap result;
158 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config); 135 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config);
159 136
160 return ImageSkiaRep(result, image_scale_); 137 return ImageSkiaRep(result, image_scale_);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 471
495 void Canvas::DrawStringRectWithFlags(const base::string16& text, 472 void Canvas::DrawStringRectWithFlags(const base::string16& text,
496 const FontList& font_list, 473 const FontList& font_list,
497 SkColor color, 474 SkColor color,
498 const Rect& display_rect, 475 const Rect& display_rect,
499 int flags) { 476 int flags) {
500 DrawStringRectWithShadows(text, font_list, color, display_rect, 0, flags, 477 DrawStringRectWithShadows(text, font_list, color, display_rect, 0, flags,
501 ShadowValues()); 478 ShadowValues());
502 } 479 }
503 480
504 void Canvas::DrawStringInt(const base::string16& text,
505 const Font& font,
506 SkColor color,
507 int x,
508 int y,
509 int w,
510 int h) {
511 DrawStringInt(text, font, color, x, y, w, h, DefaultCanvasTextAlignment());
512 }
513
514 void Canvas::DrawStringInt(const base::string16& text,
515 const Font& font,
516 SkColor color,
517 const Rect& display_rect) {
518 DrawStringInt(text, font, color, display_rect.x(), display_rect.y(),
519 display_rect.width(), display_rect.height());
520 }
521
522 void Canvas::DrawStringInt(const base::string16& text,
523 const Font& font,
524 SkColor color,
525 int x,
526 int y,
527 int w,
528 int h,
529 int flags) {
530 DrawStringWithShadows(text, font, color, Rect(x, y, w, h), 0, flags,
531 ShadowValues());
532 }
533
534 void Canvas::DrawStringWithShadows(const base::string16& text,
535 const Font& font,
536 SkColor color,
537 const Rect& text_bounds,
538 int line_height,
539 int flags,
540 const ShadowValues& shadows) {
541 DrawStringRectWithShadows(text, FontList(font), color, text_bounds,
542 line_height, flags, shadows);
543 }
544
545 void Canvas::TileImageInt(const ImageSkia& image, 481 void Canvas::TileImageInt(const ImageSkia& image,
546 int x, 482 int x,
547 int y, 483 int y,
548 int w, 484 int w,
549 int h) { 485 int h) {
550 TileImageInt(image, 0, 0, x, y, w, h); 486 TileImageInt(image, 0, 0, x, y, w, h);
551 } 487 }
552 488
553 void Canvas::TileImageInt(const ImageSkia& image, 489 void Canvas::TileImageInt(const ImageSkia& image,
554 int src_x, 490 int src_x,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 585
650 float bitmap_scale = image_rep.scale(); 586 float bitmap_scale = image_rep.scale();
651 if (scale_x < bitmap_scale || scale_y < bitmap_scale) 587 if (scale_x < bitmap_scale || scale_y < bitmap_scale)
652 const_cast<SkBitmap&>(image_rep.sk_bitmap()).buildMipMap(); 588 const_cast<SkBitmap&>(image_rep.sk_bitmap()).buildMipMap();
653 } 589 }
654 590
655 return image_rep; 591 return image_rep;
656 } 592 }
657 593
658 } // namespace gfx 594 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/canvas.h ('k') | ui/gfx/canvas_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698