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> |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 SkScalar y = SkIntToScalar(offset.y()); | 374 SkScalar y = SkIntToScalar(offset.y()); |
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(); |
msw
2014/07/11 00:29:10
optional nit: inline |render_params| here, like ot
Daniel Erat
2014/07/11 03:15:01
Done.
| |
385 renderer.SetFontRenderParams(render_params, background_is_transparent()); | 385 renderer.SetFontRenderParams(render_params, background_is_transparent()); |
386 | 386 |
387 SkPaint::Hinting skia_hinting = SkPaint::kNormal_Hinting; | |
388 switch (render_params.hinting) { | |
389 case FontRenderParams::HINTING_NONE: | |
390 skia_hinting = SkPaint::kNo_Hinting; | |
391 break; | |
392 case FontRenderParams::HINTING_SLIGHT: | |
393 skia_hinting = SkPaint::kSlight_Hinting; | |
394 break; | |
395 case FontRenderParams::HINTING_MEDIUM: | |
396 skia_hinting = SkPaint::kNormal_Hinting; | |
397 break; | |
398 case FontRenderParams::HINTING_FULL: | |
399 skia_hinting = SkPaint::kFull_Hinting; | |
400 break; | |
401 } | |
402 renderer.SetFontHinting(skia_hinting); | |
403 | |
404 // Temporarily apply composition underlines and selection colors. | 387 // Temporarily apply composition underlines and selection colors. |
405 ApplyCompositionAndSelectionStyles(); | 388 ApplyCompositionAndSelectionStyles(); |
406 | 389 |
407 internal::StyleIterator style(colors(), styles()); | 390 internal::StyleIterator style(colors(), styles()); |
408 for (GSList* it = current_line_->runs; it; it = it->next) { | 391 for (GSList* it = current_line_->runs; it; it = it->next) { |
409 PangoLayoutRun* run = reinterpret_cast<PangoLayoutRun*>(it->data); | 392 PangoLayoutRun* run = reinterpret_cast<PangoLayoutRun*>(it->data); |
410 int glyph_count = run->glyphs->num_glyphs; | 393 int glyph_count = run->glyphs->num_glyphs; |
411 // TODO(msw): Skip painting runs outside the display rect area, like Win. | 394 // TODO(msw): Skip painting runs outside the display rect area, like Win. |
412 if (glyph_count == 0) | 395 if (glyph_count == 0) |
413 continue; | 396 continue; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 int glyph_index) const { | 492 int glyph_index) const { |
510 return LayoutIndexToTextIndex(run->item->offset + | 493 return LayoutIndexToTextIndex(run->item->offset + |
511 run->glyphs->log_clusters[glyph_index]); | 494 run->glyphs->log_clusters[glyph_index]); |
512 } | 495 } |
513 | 496 |
514 RenderText* RenderText::CreateNativeInstance() { | 497 RenderText* RenderText::CreateNativeInstance() { |
515 return new RenderTextPango; | 498 return new RenderTextPango; |
516 } | 499 } |
517 | 500 |
518 } // namespace gfx | 501 } // namespace gfx |
OLD | NEW |