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.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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 namespace internal { | 173 namespace internal { |
174 | 174 |
175 // Value of |underline_thickness_| that indicates that underline metrics have | 175 // Value of |underline_thickness_| that indicates that underline metrics have |
176 // not been set explicitly. | 176 // not been set explicitly. |
177 const SkScalar kUnderlineMetricsNotSet = -1.0f; | 177 const SkScalar kUnderlineMetricsNotSet = -1.0f; |
178 | 178 |
179 SkiaTextRenderer::SkiaTextRenderer(Canvas* canvas) | 179 SkiaTextRenderer::SkiaTextRenderer(Canvas* canvas) |
180 : canvas_(canvas), | 180 : canvas_(canvas), |
181 canvas_skia_(canvas->sk_canvas()), | 181 canvas_skia_(canvas->sk_canvas()), |
182 started_drawing_(false), | |
183 underline_thickness_(kUnderlineMetricsNotSet), | 182 underline_thickness_(kUnderlineMetricsNotSet), |
184 underline_position_(0.0f) { | 183 underline_position_(0.0f) { |
185 DCHECK(canvas_skia_); | 184 DCHECK(canvas_skia_); |
186 paint_.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 185 paint_.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
187 paint_.setStyle(SkPaint::kFill_Style); | 186 paint_.setStyle(SkPaint::kFill_Style); |
188 paint_.setAntiAlias(true); | 187 paint_.setAntiAlias(true); |
189 paint_.setSubpixelText(true); | 188 paint_.setSubpixelText(true); |
190 paint_.setLCDRenderText(true); | 189 paint_.setLCDRenderText(true); |
191 paint_.setHinting(SkPaint::kNormal_Hinting); | 190 paint_.setHinting(SkPaint::kNormal_Hinting); |
192 } | 191 } |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 SetDisplayOffset(display_offset_.x() + delta_x); | 1396 SetDisplayOffset(display_offset_.x() + delta_x); |
1398 } | 1397 } |
1399 | 1398 |
1400 void RenderText::DrawSelection(Canvas* canvas) { | 1399 void RenderText::DrawSelection(Canvas* canvas) { |
1401 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1400 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
1402 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1401 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
1403 canvas->FillRect(*i, selection_background_focused_color_); | 1402 canvas->FillRect(*i, selection_background_focused_color_); |
1404 } | 1403 } |
1405 | 1404 |
1406 } // namespace gfx | 1405 } // namespace gfx |
OLD | NEW |