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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 paint_.setXfermodeMode(SkXfermode::kDstIn_Mode); | 204 paint_.setXfermodeMode(SkXfermode::kDstIn_Mode); |
| 205 canvas_skia_->drawRect(bounds_, paint_); | 205 canvas_skia_->drawRect(bounds_, paint_); |
| 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(FontRenderParams params, |
|
msw
2014/08/15 19:21:17
Can we remove this function, inline its functional
ckocagil
2014/08/15 22:28:01
We only call this on Win and Linux, so we have to
| |
| 215 bool background_is_transparent) { | 215 bool background_is_transparent) { |
| 216 paint_.setAntiAlias(params.antialiasing); | 216 if (background_is_transparent) |
| 217 paint_.setLCDRenderText(!background_is_transparent && | 217 params.subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE; |
| 218 params.subpixel_rendering != FontRenderParams::SUBPIXEL_RENDERING_NONE); | 218 ApplyRenderParams(params, &paint_); |
| 219 paint_.setSubpixelText(params.subpixel_positioning); | |
| 220 paint_.setAutohinted(params.autohinter); | |
| 221 paint_.setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); | |
| 222 } | 219 } |
| 223 | 220 |
| 224 void SkiaTextRenderer::SetTypeface(SkTypeface* typeface) { | 221 void SkiaTextRenderer::SetTypeface(SkTypeface* typeface) { |
| 225 paint_.setTypeface(typeface); | 222 paint_.setTypeface(typeface); |
| 226 } | 223 } |
| 227 | 224 |
| 228 void SkiaTextRenderer::SetTextSize(SkScalar size) { | 225 void SkiaTextRenderer::SetTextSize(SkScalar size) { |
| 229 paint_.setTextSize(size); | 226 paint_.setTextSize(size); |
| 230 } | 227 } |
| 231 | 228 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 Line::Line() : preceding_heights(0), baseline(0) {} | 406 Line::Line() : preceding_heights(0), baseline(0) {} |
| 410 | 407 |
| 411 Line::~Line() {} | 408 Line::~Line() {} |
| 412 | 409 |
| 413 skia::RefPtr<SkTypeface> CreateSkiaTypeface(const std::string& family, | 410 skia::RefPtr<SkTypeface> CreateSkiaTypeface(const std::string& family, |
| 414 int style) { | 411 int style) { |
| 415 SkTypeface::Style skia_style = ConvertFontStyleToSkiaTypefaceStyle(style); | 412 SkTypeface::Style skia_style = ConvertFontStyleToSkiaTypefaceStyle(style); |
| 416 return skia::AdoptRef(SkTypeface::CreateFromName(family.c_str(), skia_style)); | 413 return skia::AdoptRef(SkTypeface::CreateFromName(family.c_str(), skia_style)); |
| 417 } | 414 } |
| 418 | 415 |
| 416 void ApplyRenderParams(const FontRenderParams& params, SkPaint* paint) { | |
| 417 paint->setAntiAlias(params.antialiasing); | |
| 418 paint->setLCDRenderText( | |
| 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 |