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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 void SkiaTextRenderer::SetDrawLooper(SkDrawLooper* draw_looper) { | 198 void SkiaTextRenderer::SetDrawLooper(SkDrawLooper* draw_looper) { |
199 paint_.setLooper(draw_looper); | 199 paint_.setLooper(draw_looper); |
200 } | 200 } |
201 | 201 |
202 void SkiaTextRenderer::SetFontRenderParams(const FontRenderParams& params, | 202 void SkiaTextRenderer::SetFontRenderParams(const FontRenderParams& params, |
203 bool background_is_transparent) { | 203 bool background_is_transparent) { |
204 paint_.setAntiAlias(params.antialiasing); | 204 paint_.setAntiAlias(params.antialiasing); |
205 paint_.setLCDRenderText(!background_is_transparent && | 205 paint_.setLCDRenderText(!background_is_transparent && |
206 params.subpixel_rendering != FontRenderParams::SUBPIXEL_RENDERING_NONE); | 206 params.subpixel_rendering != FontRenderParams::SUBPIXEL_RENDERING_NONE); |
207 paint_.setSubpixelText(params.subpixel_positioning); | 207 paint_.setSubpixelText(params.subpixel_positioning); |
208 } | 208 paint_.setAutohinted(params.autohinter); |
209 | 209 |
210 void SkiaTextRenderer::SetFontHinting(SkPaint::Hinting hinting) { | 210 SkPaint::Hinting skia_hinting = SkPaint::kNormal_Hinting; |
211 paint_.setHinting(hinting); | 211 switch (params.hinting) { |
msw
2014/07/11 00:29:10
optional nit: add a helper to convert the enum (ca
Daniel Erat
2014/07/11 03:15:01
sure, added the helper.
this makes me sad too. do
msw
2014/07/11 04:40:57
That seems reasonable.
| |
212 case FontRenderParams::HINTING_NONE: | |
213 skia_hinting = SkPaint::kNo_Hinting; | |
214 break; | |
215 case FontRenderParams::HINTING_SLIGHT: | |
216 skia_hinting = SkPaint::kSlight_Hinting; | |
217 break; | |
218 case FontRenderParams::HINTING_MEDIUM: | |
219 skia_hinting = SkPaint::kNormal_Hinting; | |
220 break; | |
221 case FontRenderParams::HINTING_FULL: | |
222 skia_hinting = SkPaint::kFull_Hinting; | |
223 break; | |
224 } | |
225 paint_.setHinting(skia_hinting); | |
212 } | 226 } |
213 | 227 |
214 void SkiaTextRenderer::SetTypeface(SkTypeface* typeface) { | 228 void SkiaTextRenderer::SetTypeface(SkTypeface* typeface) { |
215 paint_.setTypeface(typeface); | 229 paint_.setTypeface(typeface); |
216 } | 230 } |
217 | 231 |
218 void SkiaTextRenderer::SetTextSize(SkScalar size) { | 232 void SkiaTextRenderer::SetTextSize(SkScalar size) { |
219 paint_.setTextSize(size); | 233 paint_.setTextSize(size); |
220 } | 234 } |
221 | 235 |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1353 cursor_bounds_ += delta_offset; | 1367 cursor_bounds_ += delta_offset; |
1354 } | 1368 } |
1355 | 1369 |
1356 void RenderText::DrawSelection(Canvas* canvas) { | 1370 void RenderText::DrawSelection(Canvas* canvas) { |
1357 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1371 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
1358 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1372 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
1359 canvas->FillRect(*i, selection_background_focused_color_); | 1373 canvas->FillRect(*i, selection_background_focused_color_); |
1360 } | 1374 } |
1361 | 1375 |
1362 } // namespace gfx | 1376 } // namespace gfx |
OLD | NEW |