| OLD | NEW |
| 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 "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/base/range/range.h" | 10 #include "ui/base/range/range.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 // Updates |render_text| from the specified parameters. | 127 // Updates |render_text| from the specified parameters. |
| 128 void UpdateRenderText(const gfx::Rect& rect, | 128 void UpdateRenderText(const gfx::Rect& rect, |
| 129 const string16& text, | 129 const string16& text, |
| 130 const gfx::Font& font, | 130 const gfx::Font& font, |
| 131 int flags, | 131 int flags, |
| 132 SkColor color, | 132 SkColor color, |
| 133 gfx::RenderText* render_text) { | 133 gfx::RenderText* render_text) { |
| 134 render_text->SetFontList(gfx::FontList(font)); | 134 render_text->SetFont(font); |
| 135 render_text->SetText(text); | 135 render_text->SetText(text); |
| 136 render_text->SetCursorEnabled(false); | 136 render_text->SetCursorEnabled(false); |
| 137 | 137 |
| 138 gfx::Rect display_rect = rect; | 138 gfx::Rect display_rect = rect; |
| 139 display_rect.set_height(font.GetHeight()); | 139 display_rect.set_height(font.GetHeight()); |
| 140 render_text->SetDisplayRect(display_rect); | 140 render_text->SetDisplayRect(display_rect); |
| 141 | 141 |
| 142 // Set the text alignment explicitly based on the directionality of the UI, | 142 // Set the text alignment explicitly based on the directionality of the UI, |
| 143 // if not specified. | 143 // if not specified. |
| 144 if (!(flags & (gfx::Canvas::TEXT_ALIGN_CENTER | | 144 if (!(flags & (gfx::Canvas::TEXT_ALIGN_CENTER | |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 rect.set_height(line_height); | 470 rect.set_height(line_height); |
| 471 render_text->SetDisplayRect(rect); | 471 render_text->SetDisplayRect(rect); |
| 472 | 472 |
| 473 canvas_->save(SkCanvas::kClip_SaveFlag); | 473 canvas_->save(SkCanvas::kClip_SaveFlag); |
| 474 ClipRect(display_rect); | 474 ClipRect(display_rect); |
| 475 render_text->Draw(this); | 475 render_text->Draw(this); |
| 476 canvas_->restore(); | 476 canvas_->restore(); |
| 477 } | 477 } |
| 478 | 478 |
| 479 } // namespace gfx | 479 } // namespace gfx |
| OLD | NEW |