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 |