45 #include <qpa/qplatformpixmap.h>
50 #include <QtCore/qjsondocument.h>
51 #include <QtCore/qjsonarray.h>
52 #include <QtCore/qcoreapplication.h>
53 #include "private/qhexstring_p.h"
54 #include <QtCore/qnumeric.h>
55 #include <QtCore/qfile.h>
56 #include <QtCore/qmutex.h>
60 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
68 static const uchar pat_tbl[][2][8] = {
70 { 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00 },
71 { 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff },
73 { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 },
74 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff },
76 { 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11 },
77 { 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55, 0xee },
79 { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa },
80 { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 },
82 { 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55, 0xee },
83 { 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11 },
85 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff },
86 { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 },
88 { 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff },
89 { 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00 },
91 { 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff },
92 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 },
94 { 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef },
95 { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 },
97 { 0xef, 0xef, 0xef, 0x00, 0xef, 0xef, 0xef, 0xef },
98 { 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0x10 },
100 { 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe },
101 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 },
103 { 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f },
104 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 },
106 { 0x7e, 0xbd, 0xdb, 0xe7, 0xe7, 0xdb, 0xbd, 0x7e },
107 { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 },
129 static void qt_cleanup_brush_pattern_image_cache();
134 : m_initialized(
false)
147 m_initialized =
true;
164 m_initialized =
false;
174 static void qt_cleanup_brush_pattern_image_cache()
176 qt_brushPatternImageCache()->cleanup();
181 return qt_brushPatternImageCache()->getImage(brushStyle,
invert);
266 if (
d && !
d->ref.deref())
357 brush->ref.storeRelaxed(1);
363 if (!
brush->ref.deref())
372 return nullBrushInstance_holder()->brush;
378 qWarning(
"QBrush: Incorrect use of TexturePattern");
383 qWarning(
"QBrush: Wrong use of a gradient pattern");
400 d.reset(nullBrushInstance());
416 d->ref.storeRelaxed(1);
427 :
d(nullBrushInstance())
479 if (qbrush_check_type(
style))
482 d.reset(nullBrushInstance());
551 d.reset(nullBrushInstance());
585 if (use_same_brushdata(newStyle, d->style) && d->ref.loadRelaxed() == 1) {
596 if (
data->m_has_pixmap_texture)
625 x->ref.storeRelaxed(1);
628 x->transform = d->transform;
690 if (d->style ==
style)
693 if (qbrush_check_type(
style)) {
811 if (!
image.isNull()) {
844 if (delta.
x() * delta.
x() + delta.
y() * delta.
y() > rg->
radius() * rg->
radius())
865 bool opaqueColor = d->color.alpha() == 255;
878 for (
int i=0;
i<stops.
size(); ++
i)
879 if (stops.
at(
i).second.alpha() != 255)
935 if (
b.d->style != d->style ||
b.d->color != d->color ||
b.d->transform != d->transform)
944 const QPixmap *us =
nullptr, *them =
nullptr;
945 qint64 cacheKey1, cacheKey2;
954 cacheKey2 = them->cacheKey();
958 if (cacheKey1 != cacheKey2)
975 return d1->gradient ==
d2->gradient;
982 #ifndef QT_NO_DEBUG_STREAM
988 static const char BRUSH_STYLES[][24] = {
1004 "LinearGradientPattern",
1005 "RadialGradientPattern",
1006 "ConicalGradientPattern",
1007 "",
"",
"",
"",
"",
"",
1012 dbg.
nospace() <<
"QBrush(" <<
b.color() <<
',' << BRUSH_STYLES[
b.style()] <<
')';
1020 #ifndef QT_NO_DATASTREAM
1034 bool gradient_style =
false;
1038 gradient_style =
true;
1046 s <<
b.textureImage();
1051 int type_as_int = int(gradient->
type());
1064 if (
sizeof(
qreal) ==
sizeof(
double)) {
1072 for (
int i = 0;
i < stops.
size(); ++
i) {
1118 b.setTextureImage(std::move(
img));
1122 b.setTexture(std::move(pm));
1149 if (
sizeof(
qreal) ==
sizeof(
double)) {
1160 stops << QPair<qreal, QColor>(
n,
c);
1177 double focalRadius = 0;
1317 : m_type(NoGradient)
1511 : m_type(LinearGradient)
1512 , m_stops(qt_preset_gradient_stops(preset))
1513 , m_data(qt_preset_gradient_data[preset - 1])
1514 , m_coordinateMode(ObjectMode)
1599 qWarning(
"QGradient::setColorAt: Color position must be specified in the range 0 to 1");
1615 return stop.first >= 0 && stop.first <= 1;
1624 const bool sorted = stop.first > lastPos;
1627 lastPos = stop.first;
1707 return m_coordinateMode;
1718 m_coordinateMode =
mode;
1741 return m_interpolationMode;
1753 m_interpolationMode =
mode;
1774 if (gradient.m_type != m_type
1775 || gradient.m_spread != m_spread
1776 || gradient.m_coordinateMode != m_coordinateMode
1777 || gradient.m_interpolationMode != m_interpolationMode)
return false;
1856 m_data.linear.x1 = 0;
1857 m_data.linear.y1 = 0;
1858 m_data.linear.x2 = 1;
1859 m_data.linear.y2 = 1;
1875 m_data.linear.x1 =
start.x();
1876 m_data.linear.y1 =
start.y();
1912 return QPointF(m_data.linear.x1, m_data.linear.y1);
1938 m_data.linear.x1 =
start.x();
1939 m_data.linear.y1 =
start.y();
1963 return QPointF(m_data.linear.x2, m_data.linear.y2);
1979 m_data.linear.x2 = stop.
x();
1980 m_data.linear.y2 = stop.
y();
2039 const qreal compensated_radius = radius - radius *
qreal(0.001);
2042 line.setLength(compensated_radius);
2062 m_data.radial.cx =
center.
x();
2063 m_data.radial.cy =
center.
y();
2064 m_data.radial.cradius =
radius;
2065 m_data.radial.fradius = 0;
2068 m_data.radial.fx = adapted_focal.
x();
2069 m_data.radial.fy = adapted_focal.
y();
2082 m_data.radial.cx =
center.
x();
2083 m_data.radial.cy =
center.
y();
2084 m_data.radial.cradius =
radius;
2085 m_data.radial.fradius = 0;
2086 m_data.radial.fx =
center.
x();
2087 m_data.radial.fy =
center.
y();
2128 m_data.radial.cx = 0;
2129 m_data.radial.cy = 0;
2130 m_data.radial.cradius = 1;
2131 m_data.radial.fradius = 0;
2132 m_data.radial.fx = 0;
2133 m_data.radial.fy = 0;
2146 m_data.radial.cx =
center.
x();
2147 m_data.radial.cy =
center.
y();
2149 m_data.radial.fradius = 0;
2167 m_data.radial.cx = cx;
2168 m_data.radial.cy = cy;
2170 m_data.radial.fradius = 0;
2172 m_data.radial.fx = fx;
2173 m_data.radial.fy = fy;
2193 return QPointF(m_data.radial.cx, m_data.radial.cy);
2219 m_data.radial.cx =
center.
x();
2220 m_data.radial.cy =
center.
y();
2235 return m_data.radial.cradius;
2250 m_data.radial.cradius =
radius;
2264 return m_data.radial.cradius;
2276 m_data.radial.cradius =
radius;
2290 return m_data.radial.fradius;
2302 m_data.radial.fradius =
radius;
2315 return QPointF(m_data.radial.fx, m_data.radial.fy);
2396 m_data.conical.cx =
center.
x();
2397 m_data.conical.cy =
center.
y();
2398 m_data.conical.angle =
angle;
2434 m_data.conical.cx = 0;
2435 m_data.conical.cy = 0;
2436 m_data.conical.angle = 0;
2450 return QPointF(m_data.conical.cx, m_data.conical.cy);
2475 m_data.conical.cx =
center.
x();
2476 m_data.conical.cy =
center.
y();
2489 return m_data.conical.angle;
2505 m_data.conical.angle =
angle;
2549 #include "moc_qbrush.cpp"
small capitals from c petite p scientific i
[1]
static QBitmap fromData(const QSize &size, const uchar *bits, QImage::Format monoFormat=QImage::Format_MonoLSB)
The QBrush class defines the fill pattern of shapes drawn by QPainter.
void setColor(const QColor &color)
void setStyle(Qt::BrushStyle)
void setTransform(const QTransform &)
QBrush & operator=(const QBrush &brush)
void setTextureImage(const QImage &image)
bool operator==(const QBrush &b) const
friend bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush &brush)
const QGradient * gradient() const
void setTexture(const QPixmap &pixmap)
QImage textureImage() const
const QColor & color() const
std::unique_ptr< QBrushData, QBrushDataPointerDeleter > DataPtr
Qt::BrushStyle style() const
QBrushPatternImageCache()
QImage getImage(int brushStyle, bool invert) const
The QColor class provides colors based on RGB, HSV or CMYK values.
The QConicalGradient class is used in combination with QBrush to specify a conical gradient brush.
void setCenter(const QPointF ¢er)
void setAngle(qreal angle)
The QDataStream class provides serialization of binary data to a QIODevice.
operator>>(QDataStream &ds, qfloat16 &f)
operator<<(QDataStream &ds, qfloat16 f)
The QDebug class provides an output stream for debugging information.
Convenience class for custom QDebug operators.
The QGradient class is used in combination with QBrush to specify gradient fills.
void setSpread(Spread spread)
void setCoordinateMode(CoordinateMode mode)
CoordinateMode coordinateMode() const
void setStops(const QGradientStops &stops)
void setColorAt(qreal pos, const QColor &color)
InterpolationMode interpolationMode() const
void setInterpolationMode(InterpolationMode mode)
QGradientStops stops() const
bool operator==(const QGradient &gradient) const
The QImage class provides a hardware-independent image representation that allows direct access to th...
bool hasAlphaChannel() const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QLineF class provides a two-dimensional vector using floating point precision.
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush.
QPointF finalStop() const
void setFinalStop(const QPointF &stop)
void setStart(const QPointF &start)
qsizetype size() const noexcept
bool isEmpty() const noexcept
iterator insert(qsizetype i, parameter_type t)
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
static QList< QGradientStop > fromReadOnlyData(const QGradientStop(&t)[N]) noexcept
static bool find(const QString &key, QPixmap *pixmap)
static bool insert(const QString &key, const QPixmap &pixmap)
The QPixmap class is an off-screen image representation that can be used as a paint device.
QPlatformPixmap * handle() const
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
bool hasAlphaChannel() const
The QPointF class defines a point in the plane using floating point precision.
constexpr qreal x() const noexcept
constexpr qreal y() const noexcept
The QRadialGradient class is used in combination with QBrush to specify a radial gradient brush.
void setCenter(const QPointF ¢er)
qreal focalRadius() const
void setFocalPoint(const QPointF &focalPoint)
void setCenterRadius(qreal radius)
QPointF focalPoint() const
qreal centerRadius() const
void setFocalRadius(qreal radius)
void setRadius(qreal radius)
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
The QSize class defines the size of a two-dimensional object using integer point precision.
The QString class provides a Unicode character string.
The QVariant class acts like a union for the most common Qt data types.
static auto fromValue(const T &value) -> std::enable_if_t< std::is_copy_constructible_v< T >, QVariant >
QTextStream & center(QTextStream &stream)
Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert)
Q_GUI_EXPORT QPixmap qt_pixmapForBrush(int brushStyle, bool invert)
bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush &brush)
QT_BEGIN_NAMESPACE const uchar * qt_patternForBrush(int brushStyle, bool invert)
Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush)
QPair< qreal, QColor > QGradientStop
void qAddPostRoutine(QtCleanUpFunction p)
bool qFuzzyIsNull(qfloat16 f) noexcept
bool qIsNaN(qfloat16 f) noexcept
QT_BEGIN_INCLUDE_NAMESPACE typedef unsigned char uchar
QT_END_INCLUDE_NAMESPACE typedef double qreal
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint GLenum GLenum transform
http get(QUrl::toPercentEncoding("/index.html"))
void operator()(QBrushData *d) const noexcept
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void setImage(const QImage &image)
void setPixmap(const QPixmap &pm)
bool m_has_pixmap_texture
struct QGradient::QGradientData::@523 radial
struct QGradient::QGradientData::@524 conical
struct QGradient::QGradientData::@522 linear