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" |
11 #include "ui/gfx/insets.h" | 11 #include "ui/gfx/insets.h" |
12 #include "ui/gfx/range/range.h" | 12 #include "ui/gfx/range/range.h" |
13 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
14 #include "ui/gfx/render_text.h" | 14 #include "ui/gfx/render_text.h" |
15 #include "ui/gfx/shadow_value.h" | 15 #include "ui/gfx/shadow_value.h" |
16 #include "ui/gfx/text_elider.h" | 16 #include "ui/gfx/text_elider.h" |
17 #include "ui/gfx/text_utils.h" | 17 #include "ui/gfx/text_utils.h" |
18 | 18 |
19 namespace gfx { | 19 namespace gfx { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
| 23 #if defined(OS_WIN) |
23 // If necessary, wraps |text| with RTL/LTR directionality characters based on | 24 // If necessary, wraps |text| with RTL/LTR directionality characters based on |
24 // |flags| and |text| content. | 25 // |flags| and |text| content. |
25 // Returns true if the text will be rendered right-to-left. | 26 // Returns true if the text will be rendered right-to-left. |
26 // TODO(msw): Nix this, now that RenderTextWin supports directionality directly. | 27 // TODO(msw): Nix this, now that RenderTextWin supports directionality directly. |
27 bool AdjustStringDirection(int flags, base::string16* text) { | 28 bool AdjustStringDirection(int flags, base::string16* text) { |
28 // TODO(msw): FORCE_LTR_DIRECTIONALITY does not work for RTL text now. | 29 // TODO(msw): FORCE_LTR_DIRECTIONALITY does not work for RTL text now. |
29 | 30 |
30 // If the string is empty or LTR was forced, simply return false since the | 31 // If the string is empty or LTR was forced, simply return false since the |
31 // default RenderText directionality is already LTR. | 32 // default RenderText directionality is already LTR. |
32 if (text->empty() || (flags & Canvas::FORCE_LTR_DIRECTIONALITY)) | 33 if (text->empty() || (flags & Canvas::FORCE_LTR_DIRECTIONALITY)) |
(...skipping 12 matching lines...) Expand all Loading... |
45 return true; | 46 return true; |
46 } | 47 } |
47 | 48 |
48 // In the default case, the string should be rendered as LTR. RenderText's | 49 // In the default case, the string should be rendered as LTR. RenderText's |
49 // default directionality is LTR, so the text doesn't need to be wrapped. | 50 // default directionality is LTR, so the text doesn't need to be wrapped. |
50 // Note that individual runs within the string may still be rendered RTL | 51 // Note that individual runs within the string may still be rendered RTL |
51 // (which will be the case for RTL text under non-RTL locales, since under RTL | 52 // (which will be the case for RTL text under non-RTL locales, since under RTL |
52 // locales it will be handled by the if statement above). | 53 // locales it will be handled by the if statement above). |
53 return false; | 54 return false; |
54 } | 55 } |
| 56 #endif // defined(OS_WIN) |
55 | 57 |
56 // Checks each pixel immediately adjacent to the given pixel in the bitmap. If | 58 // Checks each pixel immediately adjacent to the given pixel in the bitmap. If |
57 // any of them are not the halo color, returns true. This defines the halo of | 59 // any of them are not the halo color, returns true. This defines the halo of |
58 // pixels that will appear around the text. Note that we have to check each | 60 // pixels that will appear around the text. Note that we have to check each |
59 // pixel against both the halo color and transparent since | 61 // pixel against both the halo color and transparent since |
60 // |DrawStringRectWithHalo| will modify the bitmap as it goes, and cleared | 62 // |DrawStringRectWithHalo| will modify the bitmap as it goes, and cleared |
61 // pixels shouldn't count as changed. | 63 // pixels shouldn't count as changed. |
62 bool PixelShouldGetHalo(const SkBitmap& bitmap, | 64 bool PixelShouldGetHalo(const SkBitmap& bitmap, |
63 int x, int y, | 65 int x, int y, |
64 SkColor halo_color) { | 66 SkColor halo_color) { |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 rect.set_height(line_height); | 424 rect.set_height(line_height); |
423 render_text->SetDisplayRect(rect); | 425 render_text->SetDisplayRect(rect); |
424 | 426 |
425 canvas_->save(SkCanvas::kClip_SaveFlag); | 427 canvas_->save(SkCanvas::kClip_SaveFlag); |
426 ClipRect(display_rect); | 428 ClipRect(display_rect); |
427 render_text->Draw(this); | 429 render_text->Draw(this); |
428 canvas_->restore(); | 430 canvas_->restore(); |
429 } | 431 } |
430 | 432 |
431 } // namespace gfx | 433 } // namespace gfx |
OLD | NEW |