Title: [218717] trunk/Source/WebCore
- Revision
- 218717
- Author
- [email protected]
- Date
- 2017-06-22 14:06:29 -0700 (Thu, 22 Jun 2017)
Log Message
REGRESSION (r215809): 50% regression 14E305 -> 15A293a in MotionMark Suits test
https://bugs.webkit.org/show_bug.cgi?id=173728
<rdar://problem/32526744>
Reviewed by Tim Horton.
It turns out that CGGradientCreateWithColors is much slower than
CGGradientCreateWithColorComponents, even without colorspace variations.
Update the gradient creation code to only use this slower path
when it has extended colors.
* platform/graphics/Color.h: Add a FIXME about renaming some methods.
* platform/graphics/cg/GradientCG.cpp: Use CGGradientCreateWithColorComponents
if we have stops that are not extended colors.
(WebCore::Gradient::platformGradient):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (218716 => 218717)
--- trunk/Source/WebCore/ChangeLog 2017-06-22 21:06:21 UTC (rev 218716)
+++ trunk/Source/WebCore/ChangeLog 2017-06-22 21:06:29 UTC (rev 218717)
@@ -1,3 +1,21 @@
+2017-06-22 Dean Jackson <[email protected]>
+
+ REGRESSION (r215809): 50% regression 14E305 -> 15A293a in MotionMark Suits test
+ https://bugs.webkit.org/show_bug.cgi?id=173728
+ <rdar://problem/32526744>
+
+ Reviewed by Tim Horton.
+
+ It turns out that CGGradientCreateWithColors is much slower than
+ CGGradientCreateWithColorComponents, even without colorspace variations.
+ Update the gradient creation code to only use this slower path
+ when it has extended colors.
+
+ * platform/graphics/Color.h: Add a FIXME about renaming some methods.
+ * platform/graphics/cg/GradientCG.cpp: Use CGGradientCreateWithColorComponents
+ if we have stops that are not extended colors.
+ (WebCore::Gradient::platformGradient):
+
2017-06-22 Youenn Fablet <[email protected]>
Fix memory leak in LibWebRTCMediaEndpoint
Modified: trunk/Source/WebCore/platform/graphics/Color.h (218716 => 218717)
--- trunk/Source/WebCore/platform/graphics/Color.h 2017-06-22 21:06:21 UTC (rev 218716)
+++ trunk/Source/WebCore/platform/graphics/Color.h 2017-06-22 21:06:29 UTC (rev 218717)
@@ -213,6 +213,8 @@
// should be identical, since the respective pointer will be different.
unsigned hash() const { return WTF::intHash(m_colorData.rgbaAndFlags); }
+ // FIXME: ExtendedColor - these should be renamed (to be clear about their parameter types, or
+ // replaced with alternative accessors.
WEBCORE_EXPORT void getRGBA(float& r, float& g, float& b, float& a) const;
WEBCORE_EXPORT void getRGBA(double& r, double& g, double& b, double& a) const;
WEBCORE_EXPORT void getHSL(double& h, double& s, double& l) const;
Modified: trunk/Source/WebCore/platform/graphics/cg/GradientCG.cpp (218716 => 218717)
--- trunk/Source/WebCore/platform/graphics/cg/GradientCG.cpp 2017-06-22 21:06:21 UTC (rev 218716)
+++ trunk/Source/WebCore/platform/graphics/cg/GradientCG.cpp 2017-06-22 21:06:29 UTC (rev 218717)
@@ -49,17 +49,45 @@
sortStopsIfNecessary();
auto colorsArray = adoptCF(CFArrayCreateMutable(0, m_stops.size(), &kCFTypeArrayCallBacks));
+ unsigned numStops = m_stops.size();
const int reservedStops = 3;
Vector<CGFloat, reservedStops> locations;
- locations.reserveInitialCapacity(m_stops.size());
+ locations.reserveInitialCapacity(numStops);
+ Vector<CGFloat, 4 * reservedStops> colorComponents;
+ colorComponents.reserveInitialCapacity(numStops * 4);
+
+ bool hasExtendedColors = false;
for (const auto& stop : m_stops) {
+
+ // If all the stops are sRGB, it is faster to create a gradient using
+ // components than CGColors.
+ // FIXME: Rather than just check for extended colors, we should check the actual
+ // color space, and whether or not the components are outside [0-1].
+ // <rdar://problem/32926606>
+
+ if (stop.color.isExtended())
+ hasExtendedColors = true;
+
+ float r;
+ float g;
+ float b;
+ float a;
+ stop.color.getRGBA(r, g, b, a);
+ colorComponents.uncheckedAppend(r);
+ colorComponents.uncheckedAppend(g);
+ colorComponents.uncheckedAppend(b);
+ colorComponents.uncheckedAppend(a);
+
CFArrayAppendValue(colorsArray.get(), cachedCGColor(stop.color));
locations.uncheckedAppend(stop.offset);
}
- m_gradient = CGGradientCreateWithColors(extendedSRGBColorSpaceRef(), colorsArray.get(), locations.data());
+ if (hasExtendedColors)
+ m_gradient = CGGradientCreateWithColors(extendedSRGBColorSpaceRef(), colorsArray.get(), locations.data());
+ else
+ m_gradient = CGGradientCreateWithColorComponents(sRGBColorSpaceRef(), colorComponents.data(), locations.data(), numStops);
return m_gradient;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes