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

Unified Diff: ui/gfx/render_text.cc

Issue 1842693002: Avoid applying alpha twice in RenderText. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cherry pick the correct patch... 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 | « no previous file | no next file » | 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 e6e7398cafff6187c393c7752ec90282ae0e69a4..cbe4a5a86ffe20d5f30e4f9260054b48a9fd83bc 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -144,6 +144,10 @@ skia::RefPtr<SkShader> CreateFadeShader(const FontList& font_list,
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));
+
// In general, fade down to 0 alpha. But when the available width is less
// than four characters, linearly ramp up the fade target alpha to as high as
// 20% at zero width. This allows the user to see the last faded characters a
@@ -1233,7 +1237,7 @@ void RenderText::ApplyFadeEffects(internal::SkiaTextRenderer* renderer) {
// TODO(msw): Use the actual text colors corresponding to each faded part.
skia::RefPtr<SkShader> shader =
CreateFadeShader(font_list(), text_rect, left_part, right_part,
- colors_.breaks().front().second);
+ SkColorSetA(colors_.breaks().front().second, 0xff));
if (shader)
renderer->SetShader(shader.get());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698