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/gfx/font_list.h" | 10 #include "ui/gfx/font_list.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 const Rect& text_bounds, | 223 const Rect& text_bounds, |
224 int line_height, | 224 int line_height, |
225 int flags, | 225 int flags, |
226 const ShadowValues& shadows) { | 226 const ShadowValues& shadows) { |
227 if (!IntersectsClipRect(text_bounds)) | 227 if (!IntersectsClipRect(text_bounds)) |
228 return; | 228 return; |
229 | 229 |
230 Rect clip_rect(text_bounds); | 230 Rect clip_rect(text_bounds); |
231 clip_rect.Inset(ShadowValue::GetMargin(shadows)); | 231 clip_rect.Inset(ShadowValue::GetMargin(shadows)); |
232 | 232 |
233 canvas_->save(SkCanvas::kClip_SaveFlag); | 233 canvas_->save(); |
234 ClipRect(clip_rect); | 234 ClipRect(clip_rect); |
235 | 235 |
236 Rect rect(text_bounds); | 236 Rect rect(text_bounds); |
237 base::string16 adjusted_text = text; | 237 base::string16 adjusted_text = text; |
238 | 238 |
239 #if defined(OS_WIN) | 239 #if defined(OS_WIN) |
240 AdjustStringDirection(flags, &adjusted_text); | 240 AdjustStringDirection(flags, &adjusted_text); |
241 #endif | 241 #endif |
242 | 242 |
243 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 243 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 417 |
418 Rect rect = display_rect; | 418 Rect rect = display_rect; |
419 UpdateRenderText(rect, text, font_list, flags, color, render_text.get()); | 419 UpdateRenderText(rect, text, font_list, flags, color, render_text.get()); |
420 | 420 |
421 const int line_height = render_text->GetStringSize().height(); | 421 const int line_height = render_text->GetStringSize().height(); |
422 // Center the text vertically. | 422 // Center the text vertically. |
423 rect += Vector2d(0, (display_rect.height() - line_height) / 2); | 423 rect += Vector2d(0, (display_rect.height() - line_height) / 2); |
424 rect.set_height(line_height); | 424 rect.set_height(line_height); |
425 render_text->SetDisplayRect(rect); | 425 render_text->SetDisplayRect(rect); |
426 | 426 |
427 canvas_->save(SkCanvas::kClip_SaveFlag); | 427 canvas_->save(); |
428 ClipRect(display_rect); | 428 ClipRect(display_rect); |
429 render_text->Draw(this); | 429 render_text->Draw(this); |
430 canvas_->restore(); | 430 canvas_->restore(); |
431 } | 431 } |
432 | 432 |
433 } // namespace gfx | 433 } // namespace gfx |
OLD | NEW |