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

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

Issue 8910004: Optimize setting the font when drawing in RenderTextLinux. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years 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
« no previous file with comments | « ui/gfx/render_text.h ('k') | ui/gfx/render_text_linux.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/i18n/break_iterator.h" 10 #include "base/i18n/break_iterator.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 paint_.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 89 paint_.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
90 paint_.setStyle(SkPaint::kFill_Style); 90 paint_.setStyle(SkPaint::kFill_Style);
91 paint_.setAntiAlias(true); 91 paint_.setAntiAlias(true);
92 paint_.setSubpixelText(true); 92 paint_.setSubpixelText(true);
93 paint_.setLCDRenderText(true); 93 paint_.setLCDRenderText(true);
94 } 94 }
95 95
96 SkiaTextRenderer::~SkiaTextRenderer() { 96 SkiaTextRenderer::~SkiaTextRenderer() {
97 } 97 }
98 98
99 void SkiaTextRenderer::SetTypeface(SkTypeface* typeface) {
100 paint_.setTypeface(typeface);
101 }
102
103 void SkiaTextRenderer::SetTextSize(int size) {
104 paint_.setTextSize(size);
105 }
106
99 void SkiaTextRenderer::SetFont(const gfx::Font& font) { 107 void SkiaTextRenderer::SetFont(const gfx::Font& font) {
100 SkAutoTUnref<SkTypeface> typeface( 108 SkAutoTUnref<SkTypeface> typeface(
101 SkTypeface::CreateFromName(font.GetFontName().c_str(), 109 SkTypeface::CreateFromName(font.GetFontName().c_str(),
102 SkTypeface::kNormal)); 110 SkTypeface::kNormal));
103 if (typeface.get()) { 111 if (typeface.get()) {
104 // |paint_| adds its own ref. So don't |release()| it from the ref ptr here. 112 // |paint_| adds its own ref. So don't |release()| it from the ref ptr here.
105 paint_.setTypeface(typeface.get()); 113 SetTypeface(typeface.get());
106 } 114 }
107 paint_.setTextSize(font.GetFontSize()); 115 SetTextSize(font.GetFontSize());
108 } 116 }
109 117
110 void SkiaTextRenderer::SetForegroundColor(SkColor foreground) { 118 void SkiaTextRenderer::SetForegroundColor(SkColor foreground) {
111 paint_.setColor(foreground); 119 paint_.setColor(foreground);
112 } 120 }
113 121
114 void SkiaTextRenderer::DrawPosText(const SkPoint* pos, 122 void SkiaTextRenderer::DrawPosText(const SkPoint* pos,
115 const uint16* glyphs, 123 const uint16* glyphs,
116 size_t glyph_count) { 124 size_t glyph_count) {
117 size_t byte_length = glyph_count * sizeof(glyphs[0]); 125 size_t byte_length = glyph_count * sizeof(glyphs[0]);
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 TRACE_EVENT0("gfx", "RenderText::DrawCursor"); 712 TRACE_EVENT0("gfx", "RenderText::DrawCursor");
705 // Paint cursor. Replace cursor is drawn as rectangle for now. 713 // Paint cursor. Replace cursor is drawn as rectangle for now.
706 // TODO(msw): Draw a better cursor with a better indication of association. 714 // TODO(msw): Draw a better cursor with a better indication of association.
707 if (cursor_visible() && focused()) { 715 if (cursor_visible() && focused()) {
708 Rect r(GetUpdatedCursorBounds()); 716 Rect r(GetUpdatedCursorBounds());
709 canvas->DrawRectInt(kCursorColor, r.x(), r.y(), r.width(), r.height()); 717 canvas->DrawRectInt(kCursorColor, r.x(), r.y(), r.width(), r.height());
710 } 718 }
711 } 719 }
712 720
713 } // namespace gfx 721 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/render_text.h ('k') | ui/gfx/render_text_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698