| 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_pango.h" | 5 #include "ui/gfx/render_text_pango.h" |
| 6 | 6 |
| 7 #include <pango/pangocairo.h> | 7 #include <pango/pangocairo.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/i18n/break_iterator.h" | 12 #include "base/i18n/break_iterator.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "third_party/skia/include/core/SkTypeface.h" | 14 #include "third_party/skia/include/core/SkTypeface.h" |
| 15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 16 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" |
| 17 #include "ui/gfx/font_render_params_linux.h" | 17 #include "ui/gfx/font_render_params.h" |
| 18 #include "ui/gfx/pango_util.h" | 18 #include "ui/gfx/pango_util.h" |
| 19 #include "ui/gfx/utf16_indexing.h" | 19 #include "ui/gfx/utf16_indexing.h" |
| 20 | 20 |
| 21 namespace gfx { | 21 namespace gfx { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Returns the preceding element in a GSList (O(n)). | 25 // Returns the preceding element in a GSList (O(n)). |
| 26 GSList* GSListPrevious(GSList* head, GSList* item) { | 26 GSList* GSListPrevious(GSList* head, GSList* item) { |
| 27 GSList* prev = NULL; | 27 GSList* prev = NULL; |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 375 |
| 376 std::vector<SkPoint> pos; | 376 std::vector<SkPoint> pos; |
| 377 std::vector<uint16> glyphs; | 377 std::vector<uint16> glyphs; |
| 378 | 378 |
| 379 internal::SkiaTextRenderer renderer(canvas); | 379 internal::SkiaTextRenderer renderer(canvas); |
| 380 ApplyFadeEffects(&renderer); | 380 ApplyFadeEffects(&renderer); |
| 381 ApplyTextShadows(&renderer); | 381 ApplyTextShadows(&renderer); |
| 382 | 382 |
| 383 // TODO(derat): Use font-specific params: http://crbug.com/125235 | 383 // TODO(derat): Use font-specific params: http://crbug.com/125235 |
| 384 const FontRenderParams& render_params = GetDefaultFontRenderParams(); | 384 const FontRenderParams& render_params = GetDefaultFontRenderParams(); |
| 385 const bool use_subpixel_rendering = | 385 renderer.SetFontRenderParams(render_params, background_is_transparent()); |
| 386 render_params.subpixel_rendering != | |
| 387 FontRenderParams::SUBPIXEL_RENDERING_NONE; | |
| 388 renderer.SetFontSmoothingSettings( | |
| 389 render_params.antialiasing, | |
| 390 use_subpixel_rendering && !background_is_transparent(), | |
| 391 render_params.subpixel_positioning); | |
| 392 | 386 |
| 393 SkPaint::Hinting skia_hinting = SkPaint::kNormal_Hinting; | 387 SkPaint::Hinting skia_hinting = SkPaint::kNormal_Hinting; |
| 394 switch (render_params.hinting) { | 388 switch (render_params.hinting) { |
| 395 case FontRenderParams::HINTING_NONE: | 389 case FontRenderParams::HINTING_NONE: |
| 396 skia_hinting = SkPaint::kNo_Hinting; | 390 skia_hinting = SkPaint::kNo_Hinting; |
| 397 break; | 391 break; |
| 398 case FontRenderParams::HINTING_SLIGHT: | 392 case FontRenderParams::HINTING_SLIGHT: |
| 399 skia_hinting = SkPaint::kSlight_Hinting; | 393 skia_hinting = SkPaint::kSlight_Hinting; |
| 400 break; | 394 break; |
| 401 case FontRenderParams::HINTING_MEDIUM: | 395 case FontRenderParams::HINTING_MEDIUM: |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 int glyph_index) const { | 509 int glyph_index) const { |
| 516 return LayoutIndexToTextIndex(run->item->offset + | 510 return LayoutIndexToTextIndex(run->item->offset + |
| 517 run->glyphs->log_clusters[glyph_index]); | 511 run->glyphs->log_clusters[glyph_index]); |
| 518 } | 512 } |
| 519 | 513 |
| 520 RenderText* RenderText::CreateNativeInstance() { | 514 RenderText* RenderText::CreateNativeInstance() { |
| 521 return new RenderTextPango; | 515 return new RenderTextPango; |
| 522 } | 516 } |
| 523 | 517 |
| 524 } // namespace gfx | 518 } // namespace gfx |
| OLD | NEW |