Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: ui/gfx/render_text.cc

Issue 1831883002: Use sk_sp-based shader creation APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/render_text.h ('k') | ui/gfx/skia_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text.cc
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index cbe4a5a86ffe20d5f30e4f9260054b48a9fd83bc..56fa14d1b8cd0a9bd77002c451277a653f482f4d 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -139,11 +139,11 @@ void AddFadeEffect(const Rect& text_rect,
// Creates a SkShader to fade the text, with |left_part| specifying the left
// fade effect, if any, and |right_part| specifying the right fade effect.
-skia::RefPtr<SkShader> CreateFadeShader(const FontList& font_list,
- const Rect& text_rect,
- const Rect& left_part,
- const Rect& right_part,
- SkColor color) {
+sk_sp<SkShader> CreateFadeShader(const FontList& font_list,
+ const Rect& text_rect,
+ const Rect& left_part,
+ const Rect& right_part,
+ SkColor color) {
// The shader should only specify transparency of the fade itself, not the
// original transparency, which will be applied by the actual renderer.
DCHECK_EQ(SkColorGetA(color), static_cast<uint8_t>(0xff));
@@ -178,9 +178,9 @@ skia::RefPtr<SkShader> CreateFadeShader(const FontList& font_list,
const SkPoint points[2] = { PointToSkPoint(text_rect.origin()),
PointToSkPoint(text_rect.top_right()) };
- return skia::AdoptRef(
- SkGradientShader::CreateLinear(&points[0], &colors[0], &positions[0],
- colors.size(), SkShader::kClamp_TileMode));
+ return
+ SkGradientShader::MakeLinear(&points[0], &colors[0], &positions[0],
+ colors.size(), SkShader::kClamp_TileMode);
}
// Converts a FontRenderParams::Hinting value to the corresponding
@@ -273,8 +273,8 @@ void SkiaTextRenderer::SetForegroundColor(SkColor foreground) {
paint_.setColor(foreground);
}
-void SkiaTextRenderer::SetShader(SkShader* shader) {
- paint_.setShader(shader);
+void SkiaTextRenderer::SetShader(sk_sp<SkShader> shader) {
+ paint_.setShader(std::move(shader));
}
void SkiaTextRenderer::SetUnderlineMetrics(SkScalar thickness,
@@ -1235,11 +1235,9 @@ void RenderText::ApplyFadeEffects(internal::SkiaTextRenderer* renderer) {
text_rect.Inset(GetAlignmentOffset(0).x(), 0, 0, 0);
// TODO(msw): Use the actual text colors corresponding to each faded part.
- skia::RefPtr<SkShader> shader =
+ renderer->SetShader(
CreateFadeShader(font_list(), text_rect, left_part, right_part,
- SkColorSetA(colors_.breaks().front().second, 0xff));
- if (shader)
- renderer->SetShader(shader.get());
+ SkColorSetA(colors_.breaks().front().second, 0xff)));
}
void RenderText::ApplyTextShadows(internal::SkiaTextRenderer* renderer) {
« no previous file with comments | « ui/gfx/render_text.h ('k') | ui/gfx/skia_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698