| 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/render_text_win.h" | 5 #include "ui/gfx/render_text_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/break_iterator.h" | 9 #include "base/i18n/break_iterator.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "ui/gfx/font_smoothing_win.h" |
| 14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/canvas_skia.h" | 16 #include "ui/gfx/canvas_skia.h" |
| 16 #include "ui/gfx/platform_font.h" | 17 #include "ui/gfx/platform_font.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 // The maximum supported number of Uniscribe runs; a SCRIPT_ITEM is 8 bytes. | 21 // The maximum supported number of Uniscribe runs; a SCRIPT_ITEM is 8 bytes. |
| 21 // TODO(msw): Review memory use/failure? Max string length? Alternate approach? | 22 // TODO(msw): Review memory use/failure? Max string length? Alternate approach? |
| 22 const int kGuessItems = 100; | 23 const int kGuessItems = 100; |
| 23 const int kMaxItems = 10000; | 24 const int kMaxItems = 10000; |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 435 |
| 435 Point offset(GetOriginForSkiaDrawing()); | 436 Point offset(GetOriginForSkiaDrawing()); |
| 436 SkScalar x = SkIntToScalar(offset.x()); | 437 SkScalar x = SkIntToScalar(offset.x()); |
| 437 SkScalar y = SkIntToScalar(offset.y()); | 438 SkScalar y = SkIntToScalar(offset.y()); |
| 438 | 439 |
| 439 std::vector<SkPoint> pos; | 440 std::vector<SkPoint> pos; |
| 440 | 441 |
| 441 internal::SkiaTextRenderer renderer(canvas); | 442 internal::SkiaTextRenderer renderer(canvas); |
| 442 ApplyFadeEffects(&renderer); | 443 ApplyFadeEffects(&renderer); |
| 443 | 444 |
| 445 bool smoothing_enabled; |
| 446 bool cleartype_enabled; |
| 447 GetCachedFontSmoothingSettings(&smoothing_enabled, &cleartype_enabled); |
| 448 // Note that |cleartype_enabled| corresponds to Skia's |enable_lcd_text|. |
| 449 renderer.SetFontSmoothingSettings(smoothing_enabled, cleartype_enabled); |
| 450 |
| 444 for (size_t i = 0; i < runs_.size(); ++i) { | 451 for (size_t i = 0; i < runs_.size(); ++i) { |
| 445 // Get the run specified by the visual-to-logical map. | 452 // Get the run specified by the visual-to-logical map. |
| 446 internal::TextRun* run = runs_[visual_to_logical_[i]]; | 453 internal::TextRun* run = runs_[visual_to_logical_[i]]; |
| 447 | 454 |
| 448 if (run->glyph_count == 0) | 455 if (run->glyph_count == 0) |
| 449 continue; | 456 continue; |
| 450 | 457 |
| 451 // Based on WebCore::skiaDrawText. | 458 // Based on WebCore::skiaDrawText. |
| 452 pos.resize(run->glyph_count); | 459 pos.resize(run->glyph_count); |
| 453 SkScalar glyph_x = x; | 460 SkScalar glyph_x = x; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 internal::TextRun* run) { | 735 internal::TextRun* run) { |
| 729 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD); | 736 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD); |
| 730 return SelectionModel(caret, caret, SelectionModel::LEADING); | 737 return SelectionModel(caret, caret, SelectionModel::LEADING); |
| 731 } | 738 } |
| 732 | 739 |
| 733 RenderText* RenderText::CreateRenderText() { | 740 RenderText* RenderText::CreateRenderText() { |
| 734 return new RenderTextWin; | 741 return new RenderTextWin; |
| 735 } | 742 } |
| 736 | 743 |
| 737 } // namespace gfx | 744 } // namespace gfx |
| OLD | NEW |