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

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

Issue 10933129: Add RenderText::SetFont() function to simplify some call sites. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | « chrome/browser/ui/views/omnibox/omnibox_result_view.cc ('k') | ui/gfx/render_text.h » ('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 "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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_result_view.cc ('k') | ui/gfx/render_text.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698