\internal
*/
QGradient::QGradient()
- : m_type(NoGradient), dummy(0)
+ : m_type(NoGradient), m_spread(PadSpread), m_coordinate(LogicalMode),
+ m_interpolation(ColorInterpolation), m_focal(0)
{
}
return m_stops;
}
-#define Q_DUMMY_ACCESSOR union {void *p; uint i;}; p = dummy;
-
/*!
\enum QGradient::CoordinateMode
\since 4.4
*/
QGradient::CoordinateMode QGradient::coordinateMode() const
{
- Q_DUMMY_ACCESSOR
- return CoordinateMode(i & 0x03);
+ return m_coordinate;
}
/*!
*/
void QGradient::setCoordinateMode(CoordinateMode mode)
{
- Q_DUMMY_ACCESSOR
- i &= ~0x03;
- i |= uint(mode);
- dummy = p;
+ m_coordinate = mode;
}
/*!
*/
QGradient::InterpolationMode QGradient::interpolationMode() const
{
- Q_DUMMY_ACCESSOR
- return InterpolationMode((i >> 2) & 0x01);
+ return m_interpolation;
}
/*!
*/
void QGradient::setInterpolationMode(InterpolationMode mode)
{
- Q_DUMMY_ACCESSOR
- i &= ~(1 << 2);
- i |= (uint(mode) << 2);
- dummy = p;
+ m_interpolation = mode;
}
/*!
{
if (gradient.m_type != m_type
|| gradient.m_spread != m_spread
- || gradient.dummy != dummy) return false;
+ || gradient.m_coordinate != m_coordinate
+ || gradient.m_interpolation != m_interpolation
+ || !qFuzzyCompare(gradient.m_focal, m_focal)) return false;
if (m_type == LinearGradient) {
if (m_data.linear.x1 != gradient.m_data.linear.x1
QLinearGradient::QLinearGradient()
{
m_type = LinearGradient;
- m_spread = PadSpread;
m_data.linear.x1 = 0;
m_data.linear.y1 = 0;
m_data.linear.x2 = 1;
QLinearGradient::QLinearGradient(const QPointF &start, const QPointF &finalStop)
{
m_type = LinearGradient;
- m_spread = PadSpread;
m_data.linear.x1 = start.x();
m_data.linear.y1 = start.y();
m_data.linear.x2 = finalStop.x();
QLinearGradient::QLinearGradient(qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop)
{
m_type = LinearGradient;
- m_spread = PadSpread;
m_data.linear.x1 = xStart;
m_data.linear.y1 = yStart;
m_data.linear.x2 = xFinalStop;
QRadialGradient::QRadialGradient(const QPointF ¢er, qreal radius, const QPointF &focalPoint)
{
m_type = RadialGradient;
- m_spread = PadSpread;
m_data.radial.cx = center.x();
m_data.radial.cy = center.y();
m_data.radial.cradius = radius;
QRadialGradient::QRadialGradient(const QPointF ¢er, qreal radius)
{
m_type = RadialGradient;
- m_spread = PadSpread;
m_data.radial.cx = center.x();
m_data.radial.cy = center.y();
m_data.radial.cradius = radius;
QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qreal fy)
{
m_type = RadialGradient;
- m_spread = PadSpread;
m_data.radial.cx = cx;
m_data.radial.cy = cy;
m_data.radial.cradius = radius;
QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius)
{
m_type = RadialGradient;
- m_spread = PadSpread;
m_data.radial.cx = cx;
m_data.radial.cy = cy;
m_data.radial.cradius = radius;
QRadialGradient::QRadialGradient()
{
m_type = RadialGradient;
- m_spread = PadSpread;
m_data.radial.cx = 0;
m_data.radial.cy = 0;
m_data.radial.cradius = 1;
QRadialGradient::QRadialGradient(const QPointF ¢er, qreal centerRadius, const QPointF &focalPoint, qreal focalRadius)
{
m_type = RadialGradient;
- m_spread = PadSpread;
m_data.radial.cx = center.x();
m_data.radial.cy = center.y();
m_data.radial.cradius = centerRadius;
QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal centerRadius, qreal fx, qreal fy, qreal focalRadius)
{
m_type = RadialGradient;
- m_spread = PadSpread;
m_data.radial.cx = cx;
m_data.radial.cy = cy;
m_data.radial.cradius = centerRadius;
qreal QRadialGradient::focalRadius() const
{
Q_ASSERT(m_type == RadialGradient);
- Q_DUMMY_ACCESSOR
-
- // mask away low three bits
- union { float f; quint32 i; } u;
- u.i = i & ~0x07;
- return u.f;
+ return m_focal;
}
/*!
void QRadialGradient::setFocalRadius(qreal radius)
{
Q_ASSERT(m_type == RadialGradient);
- Q_DUMMY_ACCESSOR
-
- // Since there's no QGradientData, we only have the dummy void * to
- // store additional data in. The three lowest bits are already
- // taken, thus we cut the three lowest bits from the significand
- // and store the radius as a float.
- union { float f; quint32 i; } u;
- u.f = float(radius);
- // add 0x04 to round up when we drop the three lowest bits
- i |= (u.i + 0x04) & ~0x07;
- dummy = p;
+ m_focal = radius;
}
/*!
QConicalGradient::QConicalGradient(const QPointF ¢er, qreal angle)
{
m_type = ConicalGradient;
- m_spread = PadSpread;
m_data.conical.cx = center.x();
m_data.conical.cy = center.y();
m_data.conical.angle = angle;
QConicalGradient::QConicalGradient(qreal cx, qreal cy, qreal angle)
{
m_type = ConicalGradient;
- m_spread = PadSpread;
m_data.conical.cx = cx;
m_data.conical.cy = cy;
m_data.conical.angle = angle;
QConicalGradient::QConicalGradient()
{
m_type = ConicalGradient;
- m_spread = PadSpread;
m_data.conical.cx = 0;
m_data.conical.cy = 0;
m_data.conical.angle = 0;
\sa setTransform()
*/
-#undef Q_DUMMY_ACCESSOR
-
QT_END_NAMESPACE