Diff
Modified: trunk/Source/WebCore/ChangeLog (211852 => 211853)
--- trunk/Source/WebCore/ChangeLog 2017-02-08 01:47:31 UTC (rev 211852)
+++ trunk/Source/WebCore/ChangeLog 2017-02-08 06:41:12 UTC (rev 211853)
@@ -1,3 +1,32 @@
+2017-02-07 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] Handle extended colors in cairo and texture mapper backends
+ https://bugs.webkit.org/show_bug.cgi?id=167943
+
+ Reviewed by Michael Catanzaro.
+
+ Fixes: css3/color/backgrounds-and-borders.html
+ css3/color/box-shadows.html
+ css3/color/canvas.html
+ css3/color/composited-solid-backgrounds.html
+ css3/color/text.html
+
+ * platform/graphics/Color.cpp:
+ (WebCore::premultipliedARGBFromColor): Handle the case of color being extended.
+ * platform/graphics/cairo/CairoUtilities.cpp:
+ (WebCore::setSourceRGBAFromColor): Ditto.
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::fillRectWithColor): Use isVisible() instead of alpha().
+ (WebCore::GraphicsContext::drawEllipse): Ditto.
+ * platform/graphics/gtk/ColorGtk.cpp:
+ (WebCore::Color::operator GdkRGBA): Handle the case of color being extended.
+ * platform/graphics/texmap/TextureMapperGL.cpp:
+ (WebCore::TextureMapperGL::drawNumber): Ditto.
+ * platform/graphics/texmap/TextureMapperLayer.cpp:
+ (WebCore::blendWithOpacity): Ditto.
+ (WebCore::TextureMapperLayer::paintSelf): Use isVisible() instead of alpha().
+ (WebCore::TextureMapperLayer::computeOverlapRegions): Ditto.
+
2017-02-07 Wenson Hsieh <wenson_hs...@apple.com>
WebItemProviderPasteboard should use -registerLoadHandlersToItemProvider: when creating a new UIItemProvider
Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (211852 => 211853)
--- trunk/Source/WebCore/platform/graphics/Color.cpp 2017-02-08 01:47:31 UTC (rev 211852)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp 2017-02-08 06:41:12 UTC (rev 211853)
@@ -616,15 +616,16 @@
RGBA32 premultipliedARGBFromColor(const Color& color)
{
- unsigned pixelColor;
+ if (color.isOpaque()) {
+ if (color.isExtended())
+ return makeRGB(color.asExtended().red() * 255, color.asExtended().green() * 255, color.asExtended().blue() * 255);
+ return color.rgb();
+ }
- unsigned alpha = color.alpha();
- if (alpha < 255)
- pixelColor = makePremultipliedRGBA(color.red(), color.green(), color.blue(), alpha);
- else
- pixelColor = color.rgb();
+ if (color.isExtended())
+ return makePremultipliedRGBA(color.asExtended().red() * 255, color.asExtended().green() * 255, color.asExtended().blue() * 255, color.asExtended().alpha() * 255);
- return pixelColor;
+ return makePremultipliedRGBA(color.red(), color.green(), color.blue(), color.alpha());
}
Color blend(const Color& from, const Color& to, double progress, bool blendPremultiplied)
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp (211852 => 211853)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2017-02-08 01:47:31 UTC (rev 211852)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2017-02-08 06:41:12 UTC (rev 211853)
@@ -66,9 +66,13 @@
void setSourceRGBAFromColor(cairo_t* context, const Color& color)
{
- float red, green, blue, alpha;
- color.getRGBA(red, green, blue, alpha);
- cairo_set_source_rgba(context, red, green, blue, alpha);
+ if (color.isExtended())
+ cairo_set_source_rgba(context, color.asExtended().red(), color.asExtended().green(), color.asExtended().blue(), color.asExtended().alpha());
+ else {
+ float red, green, blue, alpha;
+ color.getRGBA(red, green, blue, alpha);
+ cairo_set_source_rgba(context, red, green, blue, alpha);
+ }
}
void appendPathToCairoContext(cairo_t* to, cairo_t* from)
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (211852 => 211853)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2017-02-08 01:47:31 UTC (rev 211852)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2017-02-08 06:41:12 UTC (rev 211853)
@@ -70,8 +70,9 @@
// A helper which quickly fills a rectangle with a simple color fill.
static inline void fillRectWithColor(cairo_t* cr, const FloatRect& rect, const Color& color)
{
- if (!color.alpha() && cairo_get_operator(cr) == CAIRO_OPERATOR_OVER)
+ if (!color.isVisible() && cairo_get_operator(cr) == CAIRO_OPERATOR_OVER)
return;
+
setSourceRGBAFromColor(cr, color);
cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
cairo_fill(cr);
@@ -387,7 +388,7 @@
cairo_arc(cr, 0., 0., 1., 0., 2 * piFloat);
cairo_restore(cr);
- if (fillColor().alpha()) {
+ if (fillColor().isVisible()) {
setSourceRGBAFromColor(cr, fillColor());
cairo_fill_preserve(cr);
}
Modified: trunk/Source/WebCore/platform/graphics/gtk/ColorGtk.cpp (211852 => 211853)
--- trunk/Source/WebCore/platform/graphics/gtk/ColorGtk.cpp 2017-02-08 01:47:31 UTC (rev 211852)
+++ trunk/Source/WebCore/platform/graphics/gtk/ColorGtk.cpp 2017-02-08 06:41:12 UTC (rev 211853)
@@ -41,10 +41,12 @@
Color::operator GdkRGBA() const
{
+ if (isExtended())
+ return { asExtended().red(), asExtended().green(), asExtended().blue(), asExtended().alpha() };
+
double red, green, blue, alpha;
getRGBA(red, green, blue, alpha);
- GdkRGBA rgba = { red, green, blue, alpha };
- return rgba;
+ return { red, green, blue, alpha };
}
#endif
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (211852 => 211853)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2017-02-08 01:47:31 UTC (rev 211852)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2017-02-08 06:41:12 UTC (rev 211853)
@@ -246,9 +246,15 @@
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t* cr = cairo_create(surface);
- float r, g, b, a;
- color.getRGBA(r, g, b, a);
- cairo_set_source_rgba(cr, b, g, r, a); // Since we won't swap R+B when uploading a texture, paint with the swapped R+B color.
+ // Since we won't swap R+B when uploading a texture, paint with the swapped R+B color.
+ if (color.isExtended())
+ cairo_set_source_rgba(cr, color.asExtended().blue(), color.asExtended().green(), color.asExtended().red(), color.asExtended().alpha());
+ else {
+ float r, g, b, a;
+ color.getRGBA(r, g, b, a);
+ cairo_set_source_rgba(cr, b, g, r, a);
+ }
+
cairo_rectangle(cr, 0, 0, width, height);
cairo_fill(cr);
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (211852 => 211853)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp 2017-02-08 01:47:31 UTC (rev 211852)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp 2017-02-08 06:41:12 UTC (rev 211853)
@@ -85,11 +85,10 @@
static Color blendWithOpacity(const Color& color, float opacity)
{
- RGBA32 rgba = color.rgb();
- // See Color::getRGBA() to know how to extract alpha from color.
- float alpha = alphaChannel(rgba) / 255.;
- float effectiveAlpha = alpha * opacity;
- return Color(colorWithOverrideAlpha(rgba, effectiveAlpha));
+ if (color.isOpaque() && opacity == 1.)
+ return color;
+
+ return color.colorWithAlphaMultipliedBy(opacity);
}
void TextureMapperLayer::computePatternTransformIfNeeded()
@@ -114,7 +113,7 @@
transform.multiply(options.transform);
transform.multiply(m_currentTransform.combined());
- if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty() && m_state.solidColor.alpha()) {
+ if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty() && m_state.solidColor.isVisible()) {
options.textureMapper.drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, options.opacity));
if (m_state.showDebugBorders)
options.textureMapper.drawBorder(m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);
@@ -256,7 +255,7 @@
FloatRect boundingRect;
if (m_backingStore || m_state.masksToBounds || m_state.maskLayer || hasFilters())
boundingRect = layerRect();
- else if (m_contentsLayer || m_state.solidColor.alpha())
+ else if (m_contentsLayer || m_state.solidColor.isVisible())
boundingRect = m_state.contentsRect;
if (m_currentFilters.hasOutsets()) {