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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 canvas_skia_->restore(); | 206 canvas_skia_->restore(); |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 void SkiaTextRenderer::SetDrawLooper(SkDrawLooper* draw_looper) { | 210 void SkiaTextRenderer::SetDrawLooper(SkDrawLooper* draw_looper) { |
211 paint_.setLooper(draw_looper); | 211 paint_.setLooper(draw_looper); |
212 } | 212 } |
213 | 213 |
214 void SkiaTextRenderer::SetFontRenderParams(const FontRenderParams& params, | 214 void SkiaTextRenderer::SetFontRenderParams(const FontRenderParams& params, |
215 bool background_is_transparent) { | 215 bool background_is_transparent) { |
216 paint_.setAntiAlias(params.antialiasing); | 216 ApplyRenderParams(params, background_is_transparent, &paint_); |
217 paint_.setLCDRenderText(!background_is_transparent && | |
218 params.subpixel_rendering != FontRenderParams::SUBPIXEL_RENDERING_NONE); | |
219 paint_.setSubpixelText(params.subpixel_positioning); | |
220 paint_.setAutohinted(params.autohinter); | |
221 paint_.setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); | |
222 } | 217 } |
223 | 218 |
224 void SkiaTextRenderer::SetTypeface(SkTypeface* typeface) { | 219 void SkiaTextRenderer::SetTypeface(SkTypeface* typeface) { |
225 paint_.setTypeface(typeface); | 220 paint_.setTypeface(typeface); |
226 } | 221 } |
227 | 222 |
228 void SkiaTextRenderer::SetTextSize(SkScalar size) { | 223 void SkiaTextRenderer::SetTextSize(SkScalar size) { |
229 paint_.setTextSize(size); | 224 paint_.setTextSize(size); |
230 } | 225 } |
231 | 226 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 Line::Line() : preceding_heights(0), baseline(0) {} | 404 Line::Line() : preceding_heights(0), baseline(0) {} |
410 | 405 |
411 Line::~Line() {} | 406 Line::~Line() {} |
412 | 407 |
413 skia::RefPtr<SkTypeface> CreateSkiaTypeface(const std::string& family, | 408 skia::RefPtr<SkTypeface> CreateSkiaTypeface(const std::string& family, |
414 int style) { | 409 int style) { |
415 SkTypeface::Style skia_style = ConvertFontStyleToSkiaTypefaceStyle(style); | 410 SkTypeface::Style skia_style = ConvertFontStyleToSkiaTypefaceStyle(style); |
416 return skia::AdoptRef(SkTypeface::CreateFromName(family.c_str(), skia_style)); | 411 return skia::AdoptRef(SkTypeface::CreateFromName(family.c_str(), skia_style)); |
417 } | 412 } |
418 | 413 |
| 414 void ApplyRenderParams(const FontRenderParams& params, |
| 415 bool background_is_transparent, |
| 416 SkPaint* paint) { |
| 417 paint->setAntiAlias(params.antialiasing); |
| 418 paint->setLCDRenderText(!background_is_transparent && |
| 419 params.subpixel_rendering != FontRenderParams::SUBPIXEL_RENDERING_NONE); |
| 420 paint->setSubpixelText(params.subpixel_positioning); |
| 421 paint->setAutohinted(params.autohinter); |
| 422 paint->setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); |
| 423 } |
| 424 |
419 } // namespace internal | 425 } // namespace internal |
420 | 426 |
421 RenderText::~RenderText() { | 427 RenderText::~RenderText() { |
422 } | 428 } |
423 | 429 |
424 RenderText* RenderText::CreateInstance() { | 430 RenderText* RenderText::CreateInstance() { |
425 #if defined(OS_MACOSX) && defined(TOOLKIT_VIEWS) | 431 #if defined(OS_MACOSX) && defined(TOOLKIT_VIEWS) |
426 // Use the more complete HarfBuzz implementation for Views controls on Mac. | 432 // Use the more complete HarfBuzz implementation for Views controls on Mac. |
427 return new RenderTextHarfBuzz; | 433 return new RenderTextHarfBuzz; |
428 #else | 434 #else |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 SetDisplayOffset(display_offset_.x() + delta_x); | 1431 SetDisplayOffset(display_offset_.x() + delta_x); |
1426 } | 1432 } |
1427 | 1433 |
1428 void RenderText::DrawSelection(Canvas* canvas) { | 1434 void RenderText::DrawSelection(Canvas* canvas) { |
1429 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1435 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
1430 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1436 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
1431 canvas->FillRect(*i, selection_background_focused_color_); | 1437 canvas->FillRect(*i, selection_background_focused_color_); |
1432 } | 1438 } |
1433 | 1439 |
1434 } // namespace gfx | 1440 } // namespace gfx |
OLD | NEW |