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

Unified Diff: Source/platform/graphics/skia/SkiaUtils.cpp

Issue 900463002: Make SVG painting independent of GraphicsContext's alpha state (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address reviewer comments Created 5 years, 10 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 | « Source/platform/graphics/skia/SkiaUtils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/skia/SkiaUtils.cpp
diff --git a/Source/platform/graphics/skia/SkiaUtils.cpp b/Source/platform/graphics/skia/SkiaUtils.cpp
index e5447e28418438ed192a2df2d851d13bab6d90c8..8864e32885dded31ef06567a81b9a0b0c9341069 100644
--- a/Source/platform/graphics/skia/SkiaUtils.cpp
+++ b/Source/platform/graphics/skia/SkiaUtils.cpp
@@ -360,4 +360,25 @@ bool shouldDrawAntiAliased(const GraphicsContext* context, const SkRect& destRec
return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fabs(heightExpansion) < 1;
}
+int clampedAlphaForBlending(float alpha)
+{
+ if (alpha < 0)
+ return 0;
+ int roundedAlpha = roundf(alpha * 256);
+ if (roundedAlpha > 256)
+ roundedAlpha = 256;
+ return roundedAlpha;
+}
+
+SkColor multiplyAlpha(SkColor color, float alpha)
+{
+ return multiplyAlpha(color, clampedAlphaForBlending(alpha));
+}
+
+SkColor multiplyAlpha(SkColor color, int alpha)
+{
+ int a = (SkColorGetA(color) * alpha) >> 8;
+ return (color & 0x00FFFFFF) | (a << 24);
+}
+
} // namespace blink
« no previous file with comments | « Source/platform/graphics/skia/SkiaUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698