Chromium Code Reviews| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 | 149 |
| 150 SkPoint points[2]; | 150 SkPoint points[2]; |
| 151 points[0].iset(text_rect.x(), text_rect.y()); | 151 points[0].iset(text_rect.x(), text_rect.y()); |
| 152 points[1].iset(text_rect.right(), text_rect.y()); | 152 points[1].iset(text_rect.right(), text_rect.y()); |
| 153 | 153 |
| 154 return skia::AdoptRef( | 154 return skia::AdoptRef( |
| 155 SkGradientShader::CreateLinear(&points[0], &colors[0], &positions[0], | 155 SkGradientShader::CreateLinear(&points[0], &colors[0], &positions[0], |
| 156 colors.size(), SkShader::kClamp_TileMode)); | 156 colors.size(), SkShader::kClamp_TileMode)); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Converts a FontRenderParams::Hinting value to the corresponding | |
| 160 // SkPaint::Hinting value. | |
| 161 SkPaint::Hinting FontRenderParamsHintingToSkPaintHinting( | |
|
msw
2014/07/11 04:40:57
You'll need a return statement after the switch.
Daniel Erat
2014/07/11 13:13:45
whoops, of course. done.
| |
| 162 FontRenderParams::Hinting params_hinting) { | |
| 163 switch (params_hinting) { | |
| 164 case FontRenderParams::HINTING_NONE: return SkPaint::kNo_Hinting; | |
| 165 case FontRenderParams::HINTING_SLIGHT: return SkPaint::kSlight_Hinting; | |
| 166 case FontRenderParams::HINTING_MEDIUM: return SkPaint::kNormal_Hinting; | |
| 167 case FontRenderParams::HINTING_FULL: return SkPaint::kFull_Hinting; | |
| 168 } | |
| 169 } | |
| 170 | |
| 159 } // namespace | 171 } // namespace |
| 160 | 172 |
| 161 namespace internal { | 173 namespace internal { |
| 162 | 174 |
| 163 // Value of |underline_thickness_| that indicates that underline metrics have | 175 // Value of |underline_thickness_| that indicates that underline metrics have |
| 164 // not been set explicitly. | 176 // not been set explicitly. |
| 165 const SkScalar kUnderlineMetricsNotSet = -1.0f; | 177 const SkScalar kUnderlineMetricsNotSet = -1.0f; |
| 166 | 178 |
| 167 SkiaTextRenderer::SkiaTextRenderer(Canvas* canvas) | 179 SkiaTextRenderer::SkiaTextRenderer(Canvas* canvas) |
| 168 : canvas_(canvas), | 180 : canvas_(canvas), |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 198 void SkiaTextRenderer::SetDrawLooper(SkDrawLooper* draw_looper) { | 210 void SkiaTextRenderer::SetDrawLooper(SkDrawLooper* draw_looper) { |
| 199 paint_.setLooper(draw_looper); | 211 paint_.setLooper(draw_looper); |
| 200 } | 212 } |
| 201 | 213 |
| 202 void SkiaTextRenderer::SetFontRenderParams(const FontRenderParams& params, | 214 void SkiaTextRenderer::SetFontRenderParams(const FontRenderParams& params, |
| 203 bool background_is_transparent) { | 215 bool background_is_transparent) { |
| 204 paint_.setAntiAlias(params.antialiasing); | 216 paint_.setAntiAlias(params.antialiasing); |
| 205 paint_.setLCDRenderText(!background_is_transparent && | 217 paint_.setLCDRenderText(!background_is_transparent && |
| 206 params.subpixel_rendering != FontRenderParams::SUBPIXEL_RENDERING_NONE); | 218 params.subpixel_rendering != FontRenderParams::SUBPIXEL_RENDERING_NONE); |
| 207 paint_.setSubpixelText(params.subpixel_positioning); | 219 paint_.setSubpixelText(params.subpixel_positioning); |
| 208 } | 220 paint_.setAutohinted(params.autohinter); |
| 209 | 221 paint_.setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); |
| 210 void SkiaTextRenderer::SetFontHinting(SkPaint::Hinting hinting) { | |
| 211 paint_.setHinting(hinting); | |
| 212 } | 222 } |
| 213 | 223 |
| 214 void SkiaTextRenderer::SetTypeface(SkTypeface* typeface) { | 224 void SkiaTextRenderer::SetTypeface(SkTypeface* typeface) { |
| 215 paint_.setTypeface(typeface); | 225 paint_.setTypeface(typeface); |
| 216 } | 226 } |
| 217 | 227 |
| 218 void SkiaTextRenderer::SetTextSize(SkScalar size) { | 228 void SkiaTextRenderer::SetTextSize(SkScalar size) { |
| 219 paint_.setTextSize(size); | 229 paint_.setTextSize(size); |
| 220 } | 230 } |
| 221 | 231 |
| (...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1353 cursor_bounds_ += delta_offset; | 1363 cursor_bounds_ += delta_offset; |
| 1354 } | 1364 } |
| 1355 | 1365 |
| 1356 void RenderText::DrawSelection(Canvas* canvas) { | 1366 void RenderText::DrawSelection(Canvas* canvas) { |
| 1357 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1367 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
| 1358 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1368 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
| 1359 canvas->FillRect(*i, selection_background_focused_color_); | 1369 canvas->FillRect(*i, selection_background_focused_color_); |
| 1360 } | 1370 } |
| 1361 | 1371 |
| 1362 } // namespace gfx | 1372 } // namespace gfx |
| OLD | NEW |