Qt 4.8
Classes | Macros | Functions
qbrush.cpp File Reference
#include "qbrush.h"
#include "qpixmap.h"
#include "qbitmap.h"
#include "qpixmapcache.h"
#include "qdatastream.h"
#include "qvariant.h"
#include "qline.h"
#include "qdebug.h"
#include <QtCore/qcoreapplication.h>
#include "private/qstylehelper_p.h"
#include <QtCore/qnumeric.h>

Go to the source code of this file.

Classes

struct  QBrushDataPointerDeleter
 
class  QBrushPatternImageCache
 
class  QGlobalStaticDeleter< QBrushData >
 
struct  QGradientBrushData
 
struct  QTexturedBrushData
 

Macros

#define Q_DUMMY_ACCESSOR   union {void *p; uint i;}; p = dummy;
 

Functions

QDebug operator<< (QDebug dbg, const QBrush &b)
 
QDataStreamoperator<< (QDataStream &s, const QBrush &b)
 
QDataStreamoperator>> (QDataStream &s, QBrush &b)
 
 Q_GLOBAL_STATIC_WITH_INITIALIZER (QBrushPatternImageCache, qt_brushPatternImageCache, { qAddPostRoutine(qt_cleanup_brush_pattern_image_cache);}) static void qt_cleanup_brush_pattern_image_cache()
 
 Q_GLOBAL_STATIC_WITH_INITIALIZER (QBrushData, nullBrushInstance, { x->ref=1;x->style=Qt::BrushStyle(0);x->color=Qt::black;}) static bool qbrush_check_type(Qt
 
bool Q_GUI_EXPORT qHasPixmapTexture (const QBrush &brush)
 
static void qt_cleanup_brush_pattern_image_cache ()
 
Q_GUI_EXPORT QImage qt_imageForBrush (int brushStyle, bool invert)
 
Q_GUI_EXPORT bool qt_isExtendedRadialGradient (const QBrush &brush)
 
const ucharqt_patternForBrush (int brushStyle, bool invert)
 
QPixmap qt_pixmapForBrush (int brushStyle, bool invert)
 
static QPointF qt_radial_gradient_adapt_focal_point (const QPointF &center, qreal radius, const QPointF &focalPoint)
 

Macro Definition Documentation

◆ Q_DUMMY_ACCESSOR

#define Q_DUMMY_ACCESSOR   union {void *p; uint i;}; p = dummy;

Function Documentation

◆ operator<<() [1/2]

QDebug operator<< ( QDebug  dbg,
const QBrush b 
)
Warning
This function is not part of the public interface.

Definition at line 1058 of file qbrush.cpp.

1059 {
1060 #ifndef Q_BROKEN_DEBUG_STREAM
1061  static const char *BRUSH_STYLES[] = {
1062  "NoBrush",
1063  "SolidPattern",
1064  "Dense1Pattern",
1065  "Dense2Pattern",
1066  "Dense3Pattern",
1067  "Dense4Pattern",
1068  "Dense5Pattern",
1069  "Dense6Pattern",
1070  "Dense7Pattern",
1071  "HorPattern",
1072  "VerPattern",
1073  "CrossPattern",
1074  "BDiagPattern",
1075  "FDiagPattern",
1076  "DiagCrossPattern",
1077  "LinearGradientPattern",
1078  "RadialGradientPattern",
1079  "ConicalGradientPattern",
1080  0, 0, 0, 0, 0, 0,
1081  "TexturePattern" // 24
1082  };
1083 
1084  dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')';
1085  return dbg.space();
1086 #else
1087  qWarning("This compiler doesn't support streaming QBrush to QDebug");
1088  return dbg;
1089  Q_UNUSED(b);
1090 #endif
1091 }
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
Q_CORE_EXPORT void qWarning(const char *,...)
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ operator<<() [2/2]

QDataStream& operator<< ( QDataStream s,
const QBrush b 
)
related

Definition at line 1111 of file qbrush.cpp.

Referenced by QBrush::setColor().

1112 {
1113  quint8 style = (quint8) b.style();
1114  bool gradient_style = false;
1115 
1116  if (style == Qt::LinearGradientPattern || style == Qt::RadialGradientPattern
1117  || style == Qt::ConicalGradientPattern)
1118  gradient_style = true;
1119 
1120  if (s.version() < QDataStream::Qt_4_0 && gradient_style)
1121  style = Qt::NoBrush;
1122 
1123  s << style << b.color();
1124  if (b.style() == Qt::TexturePattern) {
1125  s << b.texture();
1126  } else if (s.version() >= QDataStream::Qt_4_0 && gradient_style) {
1127  const QGradient *gradient = b.gradient();
1128  int type_as_int = int(gradient->type());
1129  s << type_as_int;
1130  if (s.version() >= QDataStream::Qt_4_3) {
1131  s << int(gradient->spread());
1132  s << int(gradient->coordinateMode());
1133  }
1134 
1135  if (s.version() >= QDataStream::Qt_4_5)
1136  s << int(gradient->interpolationMode());
1137 
1138  if (sizeof(qreal) == sizeof(double)) {
1139  s << gradient->stops();
1140  } else {
1141  // ensure that we write doubles here instead of streaming the stops
1142  // directly; otherwise, platforms that redefine qreal might generate
1143  // data that cannot be read on other platforms.
1144  QVector<QGradientStop> stops = gradient->stops();
1145  s << quint32(stops.size());
1146  for (int i = 0; i < stops.size(); ++i) {
1147  const QGradientStop &stop = stops.at(i);
1148  s << QPair<double, QColor>(double(stop.first), stop.second);
1149  }
1150  }
1151 
1152  if (gradient->type() == QGradient::LinearGradient) {
1153  s << static_cast<const QLinearGradient *>(gradient)->start();
1154  s << static_cast<const QLinearGradient *>(gradient)->finalStop();
1155  } else if (gradient->type() == QGradient::RadialGradient) {
1156  s << static_cast<const QRadialGradient *>(gradient)->center();
1157  s << static_cast<const QRadialGradient *>(gradient)->focalPoint();
1158  s << (double) static_cast<const QRadialGradient *>(gradient)->radius();
1159  } else { // type == Conical
1160  s << static_cast<const QConicalGradient *>(gradient)->center();
1161  s << (double) static_cast<const QConicalGradient *>(gradient)->angle();
1162  }
1163  }
1164  if (s.version() >= QDataStream::Qt_4_3)
1165  s << b.transform();
1166  return s;
1167 }
double qreal
Definition: qglobal.h:1193
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
const QGradient * gradient() const
Returns the gradient describing this brush.
Definition: qbrush.cpp:871
CoordinateMode coordinateMode() const
Returns the coordinate mode of this gradient.
Definition: qbrush.cpp:1563
T1 first
Definition: qpair.h:65
T2 second
Definition: qpair.h:66
unsigned char quint8
Definition: qglobal.h:934
QTransform transform() const
Returns the current transformation matrix for the brush.
Definition: qbrush.h:185
InterpolationMode interpolationMode() const
Returns the interpolation mode of this gradient.
Definition: qbrush.cpp:1607
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream...
QGradientStops stops() const
Returns the stop points for this gradient.
Definition: qbrush.cpp:1520
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
Definition: qbrush.cpp:785
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int version() const
Returns the version number of the data serialization format.
Definition: qdatastream.h:212
qreal angle(const QPointF &p1, const QPointF &p2)
Type type() const
Returns the type of gradient.
Definition: qbrush.h:232
The QGradient class is used in combination with QBrush to specify gradient fills. ...
Definition: qbrush.h:201
unsigned int quint32
Definition: qglobal.h:938
Spread spread() const
Returns the spread method use by this gradient.
Definition: qbrush.h:235
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ operator>>()

QDataStream& operator>> ( QDataStream s,
QBrush b 
)
related

Definition at line 1182 of file qbrush.cpp.

Referenced by QBrush::setColor().

1183 {
1184  quint8 style;
1185  QColor color;
1186  s >> style;
1187  s >> color;
1188  if (style == Qt::TexturePattern) {
1189  QPixmap pm;
1190  s >> pm;
1191  b = QBrush(color, pm);
1192  } else if (style == Qt::LinearGradientPattern
1193  || style == Qt::RadialGradientPattern
1194  || style == Qt::ConicalGradientPattern) {
1195 
1196  int type_as_int;
1198  QGradientStops stops;
1202 
1203  s >> type_as_int;
1204  type = QGradient::Type(type_as_int);
1205  if (s.version() >= QDataStream::Qt_4_3) {
1206  s >> type_as_int;
1207  spread = QGradient::Spread(type_as_int);
1208  s >> type_as_int;
1209  cmode = QGradient::CoordinateMode(type_as_int);
1210  }
1211 
1212  if (s.version() >= QDataStream::Qt_4_5) {
1213  s >> type_as_int;
1214  imode = QGradient::InterpolationMode(type_as_int);
1215  }
1216 
1217  if (sizeof(qreal) == sizeof(double)) {
1218  s >> stops;
1219  } else {
1220  quint32 numStops;
1221  double n;
1222  QColor c;
1223 
1224  s >> numStops;
1225  for (quint32 i = 0; i < numStops; ++i) {
1226  s >> n >> c;
1227  stops << QPair<qreal, QColor>(n, c);
1228  }
1229  }
1230 
1231  if (type == QGradient::LinearGradient) {
1232  QPointF p1, p2;
1233  s >> p1;
1234  s >> p2;
1235  QLinearGradient lg(p1, p2);
1236  lg.setStops(stops);
1237  lg.setSpread(spread);
1238  lg.setCoordinateMode(cmode);
1239  lg.setInterpolationMode(imode);
1240  b = QBrush(lg);
1241  } else if (type == QGradient::RadialGradient) {
1242  QPointF center, focal;
1243  double radius;
1244  s >> center;
1245  s >> focal;
1246  s >> radius;
1247  QRadialGradient rg(center, radius, focal);
1248  rg.setStops(stops);
1249  rg.setSpread(spread);
1250  rg.setCoordinateMode(cmode);
1251  rg.setInterpolationMode(imode);
1252  b = QBrush(rg);
1253  } else { // type == QGradient::ConicalGradient
1254  QPointF center;
1255  double angle;
1256  s >> center;
1257  s >> angle;
1258  QConicalGradient cg(center, angle);
1259  cg.setStops(stops);
1260  cg.setSpread(spread);
1261  cg.setCoordinateMode(cmode);
1262  cg.setInterpolationMode(imode);
1263  b = QBrush(cg);
1264  }
1265  } else {
1266  b = QBrush(color, (Qt::BrushStyle)style);
1267  }
1268  if (s.version() >= QDataStream::Qt_4_3) {
1269  QTransform transform;
1270  s >> transform;
1271  b.setTransform(transform);
1272  }
1273  return s;
1274 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
BrushStyle
Definition: qnamespace.h:1162
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
unsigned char c[8]
Definition: qnumeric_p.h:62
void setTransform(const QTransform &)
Sets matrix as an explicit transformation matrix on the current brush.
Definition: qbrush.cpp:968
The QConicalGradient class is used in combination with QBrush to specify a conical gradient brush...
Definition: qbrush.h:329
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
CoordinateMode
This enum specifies how gradient coordinates map to the paint device on which the gradient is used...
Definition: qbrush.h:219
unsigned char quint8
Definition: qglobal.h:934
The QRadialGradient class is used in combination with QBrush to specify a radial gradient brush...
Definition: qbrush.h:297
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream...
Type
Specifies the type of gradient.
Definition: qbrush.h:206
Spread
Specifies how the area outside the gradient area should be filled.
Definition: qbrush.h:213
int version() const
Returns the version number of the data serialization format.
Definition: qdatastream.h:212
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
qreal angle(const QPointF &p1, const QPointF &p2)
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
InterpolationMode
Definition: qbrush.h:225
unsigned int quint32
Definition: qglobal.h:938
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ Q_GLOBAL_STATIC_WITH_INITIALIZER() [1/2]

Q_GLOBAL_STATIC_WITH_INITIALIZER ( QBrushPatternImageCache  ,
qt_brushPatternImageCache  ,
{ qAddPostRoutine(qt_cleanup_brush_pattern_image_cache);}   
)

Definition at line 157 of file qbrush.cpp.

158  {
160  })
161 
163 {
164  qt_brushPatternImageCache()->cleanup();
165 }
static void qt_cleanup_brush_pattern_image_cache()
void qAddPostRoutine(QtCleanUpFunction ptr)
Adds a global routine that will be called from the QApplication destructor.

◆ Q_GLOBAL_STATIC_WITH_INITIALIZER() [2/2]

Q_GLOBAL_STATIC_WITH_INITIALIZER ( QBrushData  ,
nullBrushInstance  ,
{ x->ref=1;x->style=Qt::BrushStyle(0);x->color=Qt::black;}   
)

Definition at line 365 of file qbrush.cpp.

366  {
367  x->ref = 1;
368  x->style = Qt::BrushStyle(0);
369  x->color = Qt::black;
370  })
371 
372 static bool qbrush_check_type(Qt::BrushStyle style) {
373  switch (style) {
374  case Qt::TexturePattern:
375  qWarning("QBrush: Incorrect use of TexturePattern");
376  break;
380  qWarning("QBrush: Wrong use of a gradient pattern");
381  break;
382  default:
383  return true;
384  }
385  return false;
386 }
BrushStyle
Definition: qnamespace.h:1162
Q_CORE_EXPORT void qWarning(const char *,...)

◆ qHasPixmapTexture()

bool Q_GUI_EXPORT qHasPixmapTexture ( const QBrush brush)

Definition at line 223 of file qbrush.cpp.

Referenced by check_gradient(), QTextHtmlExporter::emitBackgroundAttribute(), QTextHtmlExporter::emitBlock(), is_brush_transparent(), QGL2PaintEngineExPrivate::setBrush(), QSpanData::setup(), QGL2PaintEngineExPrivate::updateBrushUniforms(), and QPainterPrivate::updateEmulationSpecifier().

224 {
225  if (brush.style() != Qt::TexturePattern)
226  return false;
227  QTexturedBrushData *tx_data = static_cast<QTexturedBrushData *>(brush.d.data());
228  return tx_data->m_has_pixmap_texture;
229 }
T * data() const
Returns the value of the pointer referenced by this object.
QScopedPointer< QBrushData, QBrushDataPointerDeleter > d
Definition: qbrush.h:146
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
bool m_has_pixmap_texture
Definition: qbrush.cpp:218

◆ qt_cleanup_brush_pattern_image_cache()

static void qt_cleanup_brush_pattern_image_cache ( )
static

◆ qt_imageForBrush()

Q_GUI_EXPORT QImage qt_imageForBrush ( int  brushStyle,
bool  invert 
)

Definition at line 167 of file qbrush.cpp.

Referenced by QOpenGLPaintEnginePrivate::composite(), QVGPaintEnginePrivate::roundedRectPath(), QVGPaintEnginePrivate::setBrush(), QSpanData::setup(), and QGL2PaintEngineExPrivate::updateBrushTexture().

168 {
169  return qt_brushPatternImageCache()->getImage(brushStyle, invert);
170 }

◆ qt_isExtendedRadialGradient()

Q_GUI_EXPORT bool qt_isExtendedRadialGradient ( const QBrush brush)

Definition at line 881 of file qbrush.cpp.

Referenced by QOpenGLPaintEngine::fill(), QOpenGLPaintEnginePrivate::fillPath(), QBrush::isOpaque(), QVGPaintEnginePrivate::needsEmulation(), QPainterPrivate::updateEmulationSpecifier(), QPainterPrivate::updateInvMatrix(), and QOpenGLPaintEnginePrivate::updateUseEmulation().

882 {
883  if (brush.style() == Qt::RadialGradientPattern) {
884  const QGradient *g = brush.gradient();
885  const QRadialGradient *rg = static_cast<const QRadialGradient *>(g);
886 
887  if (!qFuzzyIsNull(rg->focalRadius()))
888  return true;
889 
890  QPointF delta = rg->focalPoint() - rg->center();
891  if (delta.x() * delta.x() + delta.y() * delta.y() > rg->radius() * rg->radius())
892  return true;
893  }
894 
895  return false;
896 }
qreal focalRadius() const
Returns the focal radius of this radial gradient in logical coordinates.
Definition: qbrush.cpp:2211
QPointF focalPoint() const
Returns the focal point of this radial gradient in logical coordinates.
Definition: qbrush.cpp:2251
const QGradient * gradient() const
Returns the gradient describing this brush.
Definition: qbrush.cpp:871
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QRadialGradient class is used in combination with QBrush to specify a radial gradient brush...
Definition: qbrush.h:297
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
The QGradient class is used in combination with QBrush to specify gradient fills. ...
Definition: qbrush.h:201
qreal radius() const
Returns the radius of this radial gradient in logical coordinates.
Definition: qbrush.cpp:2150
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QPointF center() const
Returns the center of this radial gradient in logical coordinates.
Definition: qbrush.cpp:2102
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
Definition: qglobal.h:2043

◆ qt_patternForBrush()

const uchar* qt_patternForBrush ( int  brushStyle,
bool  invert 
)

Definition at line 56 of file qbrush.cpp.

Referenced by QBrushPatternImageCache::init(), and qt_pixmapForBrush().

57 {
58  Q_ASSERT(brushStyle > Qt::SolidPattern && brushStyle < Qt::LinearGradientPattern);
59  if(invert) {
60  static const uchar dense1_pat[] = { 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff };
61  static const uchar dense2_pat[] = { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff };
62  static const uchar dense3_pat[] = { 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55, 0xee };
63  static const uchar dense4_pat[] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 };
64  static const uchar dense5_pat[] = { 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11 };
65  static const uchar dense6_pat[] = { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 };
66  static const uchar dense7_pat[] = { 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00 };
67  static const uchar hor_pat[] = { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 };
68  static const uchar ver_pat[] = { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 };
69  static const uchar cross_pat[] = { 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0x10 };
70  static const uchar bdiag_pat[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
71  static const uchar fdiag_pat[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
72  static const uchar dcross_pat[] = { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 };
73  static const uchar *const pat_tbl[] = {
74  dense1_pat, dense2_pat, dense3_pat, dense4_pat, dense5_pat,
75  dense6_pat, dense7_pat,
76  hor_pat, ver_pat, cross_pat, bdiag_pat, fdiag_pat, dcross_pat };
77  return pat_tbl[brushStyle - Qt::Dense1Pattern];
78  }
79  static const uchar dense1_pat[] = { 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00 };
80  static const uchar dense2_pat[] = { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 };
81  static const uchar dense3_pat[] = { 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11 };
82  static const uchar dense4_pat[] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
83  static const uchar dense5_pat[] = { 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55, 0xee };
84  static const uchar dense6_pat[] = { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff };
85  static const uchar dense7_pat[] = { 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff };
86  static const uchar hor_pat[] = { 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff };
87  static const uchar ver_pat[] = { 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef };
88  static const uchar cross_pat[] = { 0xef, 0xef, 0xef, 0x00, 0xef, 0xef, 0xef, 0xef };
89  static const uchar bdiag_pat[] = { 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe };
90  static const uchar fdiag_pat[] = { 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f };
91  static const uchar dcross_pat[] = { 0x7e, 0xbd, 0xdb, 0xe7, 0xe7, 0xdb, 0xbd, 0x7e };
92  static const uchar *const pat_tbl[] = {
93  dense1_pat, dense2_pat, dense3_pat, dense4_pat, dense5_pat,
94  dense6_pat, dense7_pat,
95  hor_pat, ver_pat, cross_pat, bdiag_pat, fdiag_pat, dcross_pat };
96  return pat_tbl[brushStyle - Qt::Dense1Pattern];
97 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
unsigned char uchar
Definition: qglobal.h:994

◆ qt_pixmapForBrush()

QPixmap qt_pixmapForBrush ( int  brushStyle,
bool  invert 
)

Definition at line 99 of file qbrush.cpp.

Referenced by getPatternFill(), and QX11PaintEngine::updateBrush().

100 {
101 
102  QPixmap pm;
103  QString key = QLatin1Literal("$qt-brush$")
104  % HexString<uint>(brushStyle)
105  % QLatin1Char(invert ? '1' : '0');
106  if (!QPixmapCache::find(key, pm)) {
107  pm = QBitmap::fromData(QSize(8, 8), qt_patternForBrush(brushStyle, invert),
109  QPixmapCache::insert(key, pm);
110  }
111 
112  return pm;
113 }
The QLatin1Literal class provides a thin wrapper around string literals used in source code...
static QBitmap fromData(const QSize &size, const uchar *bits, QImage::Format monoFormat=QImage::Format_MonoLSB)
Constructs a bitmap with the given size, and sets the contents to the bits supplied.
Definition: qbitmap.cpp:318
const uchar * qt_patternForBrush(int brushStyle, bool invert)
Definition: qbrush.cpp:56
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
int key
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ qt_radial_gradient_adapt_focal_point()

static QPointF qt_radial_gradient_adapt_focal_point ( const QPointF center,
qreal  radius,
const QPointF focalPoint 
)
static

Definition at line 1933 of file qbrush.cpp.

Referenced by QRadialGradient::QRadialGradient().

1936 {
1937  // We have a one pixel buffer zone to avoid numerical instability on the
1938  // circle border
1939  //### this is hacky because technically we should adjust based on current matrix
1940  const qreal compensated_radius = radius - radius * qreal(0.001);
1941  QLineF line(center, focalPoint);
1942  if (line.length() > (compensated_radius))
1943  line.setLength(compensated_radius);
1944  return line.p2();
1945 }
double qreal
Definition: qglobal.h:1193
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212