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

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

Issue 634983002: chromeos: Enable RenderTextHarfBuzz. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | 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.h" 5 #include "ui/gfx/render_text.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <climits> 8 #include <climits>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 } // namespace internal 390 } // namespace internal
391 391
392 RenderText::~RenderText() { 392 RenderText::~RenderText() {
393 } 393 }
394 394
395 RenderText* RenderText::CreateInstance() { 395 RenderText* RenderText::CreateInstance() {
396 #if defined(OS_MACOSX) && defined(TOOLKIT_VIEWS) 396 #if defined(OS_MACOSX) && defined(TOOLKIT_VIEWS)
397 // Use the more complete HarfBuzz implementation for Views controls on Mac. 397 // Use the more complete HarfBuzz implementation for Views controls on Mac.
398 return new RenderTextHarfBuzz; 398 return new RenderTextHarfBuzz;
399 #endif
400
401 #if defined(OS_LINUX)
msw 2014/10/07 18:29:01 nit: elif?
Daniel Erat 2014/10/08 02:03:43 sure, done
402 // RenderTextPango has severe performance issues (http://crbug.com/376077), so
403 // default to RenderTextHarfBuzz on Linux (and Chrome OS).
404 if (!CommandLine::ForCurrentProcess()->HasSwitch(
405 switches::kDisableHarfBuzzRenderText)) {
406 return new RenderTextHarfBuzz;
407 }
399 #else 408 #else
400 if (CommandLine::ForCurrentProcess()->HasSwitch( 409 if (CommandLine::ForCurrentProcess()->HasSwitch(
401 switches::kEnableHarfBuzzRenderText)) { 410 switches::kEnableHarfBuzzRenderText)) {
402 return new RenderTextHarfBuzz; 411 return new RenderTextHarfBuzz;
403 } 412 }
413 #endif
404 return CreateNativeInstance(); 414 return CreateNativeInstance();
msw 2014/10/07 18:29:01 nit q: will this trigger unreachable code warnings
Daniel Erat 2014/10/08 02:03:43 good point. i think that nested ifdefs are pretty
405 #endif
406 } 415 }
407 416
408 void RenderText::SetText(const base::string16& text) { 417 void RenderText::SetText(const base::string16& text) {
409 DCHECK(!composition_range_.IsValid()); 418 DCHECK(!composition_range_.IsValid());
410 if (text_ == text) 419 if (text_ == text)
411 return; 420 return;
412 text_ = text; 421 text_ = text;
413 422
414 // Adjust ranged styles and colors to accommodate a new text length. 423 // Adjust ranged styles and colors to accommodate a new text length.
415 // Clear style ranges as they might break new text graphemes and apply 424 // Clear style ranges as they might break new text graphemes and apply
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 SetDisplayOffset(display_offset_.x() + delta_x); 1387 SetDisplayOffset(display_offset_.x() + delta_x);
1379 } 1388 }
1380 1389
1381 void RenderText::DrawSelection(Canvas* canvas) { 1390 void RenderText::DrawSelection(Canvas* canvas) {
1382 const std::vector<Rect> sel = GetSubstringBounds(selection()); 1391 const std::vector<Rect> sel = GetSubstringBounds(selection());
1383 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) 1392 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i)
1384 canvas->FillRect(*i, selection_background_focused_color_); 1393 canvas->FillRect(*i, selection_background_focused_color_);
1385 } 1394 }
1386 1395
1387 } // namespace gfx 1396 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698