15#include <private/qfixed_p.h>
17#include <QElapsedTimer>
18#include <QLoggingCategory>
28#define QT_SVG_TIMING_ENTER \
29 QElapsedTimer qtSvgTimer; qtSvgTimer.start();
31#define QT_SVG_TIMING_EXIT(TYPE) \
32 if (Q_UNLIKELY(lcSvgTiming().isDebugEnabled())) \
33 qCDebug(lcSvgTiming) << "Drawing" << TYPE << "took" << (qtSvgTimer.nsecsElapsed() / 1000000.0f) << "ms";
35#define QT_SVG_DRAW_SHAPE(command) \
36 { qreal oldOpacity = p->opacity(); \
37 QBrush oldBrush = p->brush(); \
38 QPen oldPen = p->pen(); \
39 p->setPen(Qt::NoPen); \
40 p->setOpacity(oldOpacity * states.fillOpacity); \
43 if (oldPen != Qt::NoPen && oldPen.brush() != Qt::NoBrush && oldPen.widthF() != 0) { \
44 p->setOpacity(oldOpacity * states.strokeOpacity); \
45 p->setBrush(Qt::NoBrush); \
47 p->setBrush(oldBrush); \
49 p->setOpacity(oldOpacity); }
51#ifndef QT_SVG_MAX_LAYOUT_SIZE
52#define QT_SVG_MAX_LAYOUT_SIZE (qint64(QFIXED_MAX / 2))
57 qWarning(
"<animation> no implemented");
75 return p->transform().mapRect(m_bounds);
81 path.addEllipse(m_bounds);
106 if (
p->pen().widthF() != 0) {
107 qreal oldOpacity =
p->opacity();
108 p->setOpacity(oldOpacity *
states.strokeOpacity);
110 p->setOpacity(oldOpacity);
122 if (m_bounds.
width() == 0.0)
124 if (m_bounds.
height() == 0.0)
133 p->drawImage(m_bounds, m_image);
151 if (
p->pen().widthF() != 0) {
152 qreal oldOpacity =
p->opacity();
153 p->setOpacity(oldOpacity *
states.strokeOpacity);
155 p->setOpacity(oldOpacity);
187 return qFuzzyIsNull(sw) ?
p->transform().map(m_path).boundingRect()
205 return p->transform().map(m_poly).boundingRect();
208 path.addPolygon(m_poly);
235 qreal oldOpacity =
p->opacity();
237 QPen save =
p->pen();
239 p->setOpacity(oldOpacity *
states.fillOpacity);
240 p->drawPolygon(m_poly,
states.fillRule);
243 if (
p->pen().widthF() != 0) {
244 p->setOpacity(oldOpacity *
states.strokeOpacity);
245 p->drawPolyline(m_poly);
247 p->setOpacity(oldOpacity);
261 return p->transform().mapRect(m_rect);
268 return p->transform().mapRect(m_rect);
271 path.addRect(m_rect);
291QSvgTspan *
const QSvgText::LINEBREAK = 0;
304 for (
int i = 0;
i < m_tspans.
size(); ++
i) {
305 if (m_tspans[
i] != LINEBREAK)
322 for (
int i = 0;
i < m_tspans.
size(); ++
i)
325 QRectF approxMaximumBrect(m_coord.
x(),
329 return p->transform().mapRect(approxMaximumBrect);
340bool QSvgText::precheck(
QPainter *
p)
const
343 qreal originalFontSize =
p->font().pointSizeF();
344 qreal maxFontSize = originalFontSize;
346 numChars +=
span->text().size();
357 qCWarning(lcSvgDraw) <<
"Text element too high to lay out, ignoring";
362 qCWarning(lcSvgDraw) <<
"Text element too wide to lay out, ignoring";
382 qreal oldOpacity =
p->opacity();
383 p->setOpacity(oldOpacity *
states.fillOpacity);
401 px += scaledSize.
width() / 2;
403 px += scaledSize.
width();
410 bool appendSpace =
false;
415 for (
int i = 0;
i < m_tspans.
size(); ++
i) {
416 if (m_tspans[
i] == LINEBREAK) {
418 if (paragraphs.
back().isEmpty()) {
426 formatRanges.back().append(
range);
432 formatRanges.resize(formatRanges.size() + 1);
445 bool prependSpace = !appendSpace && !m_tspans[
i]->isTspan() && (
mode ==
Default) && !paragraphs.
back().isEmpty() && newText.startsWith(
QLatin1Char(
' '));
446 if (appendSpace || prependSpace)
452 newText = newText.simplified();
453 if (newText.isEmpty())
454 appendSpaceNext =
false;
459 range.length = newText.size();
461 range.format.setTextOutline(
p->pen());
462 range.format.setForeground(
p->brush());
465 Q_ASSERT(!formatRanges.back().isEmpty());
466 ++formatRanges.back().back().length;
467 }
else if (prependSpace) {
471 formatRanges.back().append(
range);
473 appendSpace = appendSpaceNext;
474 paragraphs.
back() += newText;
476 m_tspans[
i]->revertStyle(
p,
states);
483 for (
int i = 1;
i < paragraphs.
size(); ++
i) {
490 for (
int i = 0;
i < paragraphs.
size(); ++
i) {
494 tl.setTextOption(op);
495 tl.setFormats(formatRanges[
i]);
502 if (m_size.
width() != 0)
507 bool endOfBoundsReached =
false;
508 for (
int i = 0;
i < tl.lineCount(); ++
i) {
513 x -= 0.5 *
line.naturalTextWidth();
515 x -=
line.naturalTextWidth();
517 if (initial && m_type ==
TEXT)
522 brect |=
line.naturalTextRect();
525 if ((m_size.
width() != 0 &&
line.naturalTextWidth() > scaledSize.
width())
530 endOfBoundsReached =
true;
534 y += 1.1 *
line.height();
539 if (endOfBoundsReached)
550 p->setWorldTransform(oldTransform,
false);
551 p->setOpacity(oldOpacity);
576 if (
states.nestedUseLevel > 3 &&
states.nestedUseCount > (256 +
states.nestedUseLevel * 2)) {
584 p->translate(m_start);
586 if (
states.nestedUseLevel > 0)
593 if (
states.nestedUseLevel == 0)
594 states.nestedUseCount = 0;
597 p->translate(-m_start);
681 p->translate(m_start);
697 return p->transform().map(m_poly).boundingRect();
700 path.addPolygon(m_poly);
713 return qFuzzyIsNull(sw) ?
p->transform().map(m_path).boundingRect()
719 return p->transform().mapRect(m_bounds);
\reentrant \inmodule QtGui
qreal height() const
Returns the height of the font.
qreal averageCharWidth() const
void setPixelSize(int)
Sets the font size to pixelSize pixels, with a maxiumum size of an unsigned 16-bit integer.
qreal pointSizeF() const
Returns the point size of the font.
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
constexpr QPointF p1() const
Returns the line's start point.
constexpr QPointF p2() const
Returns the line's end point.
qsizetype size() const noexcept
void push_back(parameter_type t)
bool endsWith(parameter_type t) const
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
The QPainterPathStroker class is used to generate fillable outlines for a given painter path.
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path.
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
QRectF controlPointRect() const
Returns the rectangle containing all the points and control points in this path.
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision.
The QPainter class performs low-level painting on widgets and other paint devices.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0.0 (ignoring the sign); otherwise returns fa...
The QPolygonF class provides a list of points using floating point precision.
QRectF Q_GUI_EXPORT boundingRect() const
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty.
\inmodule QtCore\reentrant
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr void setBottom(qreal pos) noexcept
Sets the bottom edge of the rectangle to the given finite y coordinate.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr void setWidth(qreal w) noexcept
Sets the width of the rectangle to the given finite width.
constexpr void translate(qreal dx, qreal dy) noexcept
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position.
constexpr void setHeight(qreal h) noexcept
Sets the height of the rectangle to the given finite height.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype size() const
Returns the number of characters in this string.
QString & append(QChar c)
void draw(QPainter *p, QSvgExtraStates &states) override
Type type() const override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QSvgArc(QSvgNode *parent, const QPainterPath &path)
Type type() const override
void draw(QPainter *p, QSvgExtraStates &states) override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
Type type() const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
void draw(QPainter *p, QSvgExtraStates &states) override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QSvgEllipse(QSvgNode *parent, const QRectF &rect)
Type type() const override
const QFont & qfont() const
QSvgImage(QSvgNode *parent, const QImage &image, const QRectF &bounds)
void draw(QPainter *p, QSvgExtraStates &states) override
Type type() const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
QSvgLine(QSvgNode *parent, const QLineF &line)
Type type() const override
void draw(QPainter *p, QSvgExtraStates &states) override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
void revertStyle(QPainter *p, QSvgExtraStates &states) const
static qreal strokeWidth(QPainter *p)
virtual QRectF transformedBounds(QPainter *p, QSvgExtraStates &states) const
bool isDescendantOf(const QSvgNode *parent) const
void applyStyle(QPainter *p, QSvgExtraStates &states) const
virtual void draw(QPainter *p, QSvgExtraStates &states)=0
bool shouldDrawNode(QPainter *p, QSvgExtraStates &states) const
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
void draw(QPainter *p, QSvgExtraStates &states) override
Type type() const override
QSvgPath(QSvgNode *parent, const QPainterPath &qpath)
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
Type type() const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
QSvgPolygon(QSvgNode *parent, const QPolygonF &poly)
void draw(QPainter *p, QSvgExtraStates &states) override
QSvgPolyline(QSvgNode *parent, const QPolygonF &poly)
void draw(QPainter *p, QSvgExtraStates &states) override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
Type type() const override
Type type() const override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
QSvgRect(QSvgNode *paren, const QRectF &rect, int rx=0, int ry=0)
void draw(QPainter *p, QSvgExtraStates &states) override
void addText(const QString &text)
void draw(QPainter *p, QSvgExtraStates &states) override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
QSvgText(QSvgNode *parent, const QPointF &coord)
void setTextArea(const QSizeF &size)
Type type() const override
const QString & text() const
void setWhitespaceMode(QSvgText::WhitespaceMode mode)
void addText(const QString &text)
void draw(QPainter *p, QSvgExtraStates &states) override
QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *link)
Type type() const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
Type type() const override
void draw(QPainter *p, QSvgExtraStates &states) override
void setWrapMode(WrapMode wrap)
Sets the option's text wrap mode to the given mode.
@ WrapAtWordBoundaryOrAnywhere
Combined button and popup list for selecting options.
bool qFuzzyIsNull(qfloat16 f) noexcept
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat GLfloat GLfloat maxY
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat GLfloat GLfloat maxX
GLsizei const GLchar *const * path
GLenum GLenum GLsizei void GLsizei void void * span
GLenum GLenum GLenum GLenum GLenum scale
static const QRectF boundingRect(const QPointF *points, int pointCount)
static QT_BEGIN_NAMESPACE const uint Default
#define qPrintable(string)
#define QT_SVG_DRAW_SHAPE(command)
#define QT_SVG_TIMING_EXIT(TYPE)
#define QT_SVG_TIMING_ENTER
#define QT_SVG_MAX_LAYOUT_SIZE
static QRectF boundsOnStroke(QPainter *p, const QPainterPath &path, qreal width)
\inmodule QtCore \reentrant
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent