Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: ui/gfx/render_text_pango.cc

Issue 387743002: Apply hinting in SkiaTextRenderer::SetFontRenderParams(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: apply review feedback Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« ui/gfx/render_text.cc ('K') | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 renderer.SetFontRenderParams(GetDefaultFontRenderParams(),
385 renderer.SetFontRenderParams(render_params, background_is_transparent()); 385 background_is_transparent());
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 386
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)
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« ui/gfx/render_text.cc ('K') | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698