return 0;
}
-static bool qt_isExtendedRadialGradient(const QBrush &brush)
-{
- if (brush.style() == Qt::RadialGradientPattern) {
- const QGradient *g = brush.gradient();
- const QRadialGradient *rg = static_cast<const QRadialGradient *>(g);
-
- if (!qFuzzyIsNull(rg->focalRadius()))
- return true;
-
- QPointF delta = rg->focalPoint() - rg->center();
- if (delta.x() * delta.x() + delta.y() * delta.y() > rg->radius() * rg->radius())
- return true;
- }
-
- return false;
-}
-
/*!
Returns true if the brush is fully opaque otherwise false. A brush
is considered opaque if:
bool QBrush::isOpaque() const
{
- bool opaqueColor = d->color.alpha() == 255;
+ // Test awfully simple case first, opaque color
+ if (d->style == Qt::SolidPattern) {
+ return (d->color.alpha() == 255);
+ } else if (d->style == Qt::RadialGradientPattern) {
+ const QRadialGradient *rg = static_cast<const QRadialGradient *>(gradient());
- // Test awfully simple case first
- if (d->style == Qt::SolidPattern)
- return opaqueColor;
+ if (!qFuzzyIsNull(rg->focalRadius()))
+ return false;
- if (qt_isExtendedRadialGradient(*this))
- return false;
+ QPointF delta = rg->focalPoint() - rg->center();
+ if (delta.x() * delta.x() + delta.y() * delta.y() > rg->radius() * rg->radius())
+ return false;
+ }
if (d->style == Qt::LinearGradientPattern
|| d->style == Qt::RadialGradientPattern
|| d->style == Qt::ConicalGradientPattern) {
- QGradientStops stops = gradient()->stops();
- for (int i=0; i<stops.size(); ++i)
- if (stops.at(i).second.alpha() != 255)
+ foreach (const QGradientStop &stop, gradient()->stops()) {
+ if (stop.second.alpha() != 255)
return false;
+ }
return true;
} else if (d->style == Qt::TexturePattern) {
return qHasPixmapTexture(*this)