48 RecycleBin() =
default;
51 Q_ASSERT(unusedGlyphNodes.isEmpty());
52 Q_ASSERT(unusedRectangleNodes.isEmpty());
53 Q_ASSERT(unusedImageNodes.isEmpty());
54 Q_ASSERT(unusedTextures.isEmpty());
57 QVarLengthArray<QSGGlyphNode *, 8> unusedGlyphNodes;
58 QVarLengthArray<QSGInternalRectangleNode *, 8> unusedRectangleNodes;
59 QVarLengthArray<QSGInternalImageNode *, 8> unusedImageNodes;
60 QList<QSGTexture *> unusedTextures;
63 Q_DISABLE_COPY(RecycleBin)
66 QSGInternalTextNode(QSGRenderContext *renderContext);
67 ~QSGInternalTextNode();
69 static bool isComplexRichText(QTextDocument *);
71 void setColor(QColor color) override
76 QColor color()
const override
81 void setTextStyle(TextStyle textStyle) override
83 m_textStyle = textStyle;
86 TextStyle textStyle() override
91 void setStyleColor(QColor styleColor) override
93 m_styleColor = styleColor;
96 QColor styleColor()
const override
101 void setLinkColor(QColor linkColor) override
103 m_linkColor = linkColor;
106 QColor linkColor()
const override
111 void setSelectionColor(QColor selectionColor) override
113 m_selectionColor = selectionColor;
116 QColor selectionColor()
const override
118 return m_selectionColor;
121 void setSelectionTextColor(QColor selectionTextColor) override
123 m_selectionTextColor = selectionTextColor;
126 QColor selectionTextColor()
const override
128 return m_selectionTextColor;
131 void setRenderTypeQuality(
int renderTypeQuality) override
133 m_renderTypeQuality = renderTypeQuality;
135 int renderTypeQuality()
const override
137 return m_renderTypeQuality;
140 void setRenderType(RenderType renderType) override
142 m_renderType = renderType;
145 RenderType renderType()
const override
150 bool containsUnscalableGlyphs()
const
152 return m_containsUnscalableGlyphs;
155 void setFiltering(QSGTexture::Filtering filtering) override
157 m_filtering = filtering;
160 QSGTexture::Filtering filtering()
const override
165 void setViewport(
const QRectF &viewport) override
167 m_viewport = viewport;
170 QRectF viewport()
const override
175 void setDevicePixelRatio(qreal dpr)
177 m_devicePixelRatio = dpr;
180 void setCursor(
const QRectF &rect,
const QColor &color, RecycleBin *recycleBin);
183 void addRectangleNode(
const QRectF &rect,
const QColor &color, RecycleBin *recycleBin);
184 virtual void addDecorationNode(
const QRectF &rect,
186 QTextCharFormat::UnderlineStyle style,
187 RecycleBin *recycleBin);
188 void addImage(
const QRectF &rect,
const QImage &image, RecycleBin *recycleBin);
189 void clear() override;
190 void recycle(RecycleBin *recycleBin);
191 QSGGlyphNode *addGlyphs(
const QPointF &position,
192 const QGlyphRun &glyphs,
194 RecycleBin *recycleBin,
195 QQuickText::TextStyle style = QQuickText::Normal,
196 const QColor &styleColor = QColor(),
197 QSGNode *parentNode = 0);
199 QSGInternalRectangleNode *cursorNode()
const {
return m_cursorNode; }
200 std::pair<
int,
int> renderedLineRange()
const {
return { m_firstLineInViewport, m_firstLinePastViewport }; }
202 void discardUnusedNodes(RecycleBin *recycleBin);
204 void addTextLayout(QPointF position,
206 RecycleBin *recycleBin,
207 int selectionStart = -1,
208 int selectionCount = -1,
212 doAddTextLayout(position, layout, selectionStart, selectionCount, lineStart, lineCount, recycleBin);
215 void addTextDocument(QPointF position,
216 QTextDocument *document,
217 RecycleBin *recycleBin,
218 int selectionStart = -1,
219 int selectionCount = -1)
221 doAddTextDocument(position, document, selectionStart, selectionCount, recycleBin);
225 void doAddTextLayout(QPointF position,
226 QTextLayout *textLayout,
231 RecycleBin *recycleBin);
233 void doAddTextLayout(QPointF position,
234 QTextLayout *textLayout,
238 int lineCount) override
240 doAddTextLayout(position, textLayout, selectionStart, selectionEnd, lineStart, lineCount,
nullptr);
243 void doAddTextDocument(QPointF position,
244 QTextDocument *textDocument,
247 RecycleBin *recycleBin);
248 void doAddTextDocument(QPointF position,
249 QTextDocument *textDocument,
251 int selectionEnd) override
253 doAddTextDocument(position, textDocument, selectionStart, selectionEnd,
nullptr);
257 QSGInternalImageNode *findOrCreateImageNode(RecycleBin *recycleBin);
258 QSGGlyphNode *findOrCreateGlyphNode(RenderType renderType, RecycleBin *recycleBin);
259 QSGInternalRectangleNode *findOrCreateRectangleNode(RecycleBin *recycleBin);
261 QSGInternalRectangleNode *m_cursorNode =
nullptr;
262 QList<QSGTexture *> m_textures;
263 QSGRenderContext *m_renderContext =
nullptr;
264 RenderType m_renderType = QtRendering;
265 TextStyle m_textStyle = Normal;
267 QColor m_color = QColor(0, 0, 0);
268 QColor m_styleColor = QColor(0, 0, 0);
269 QColor m_linkColor = QColor(0, 0, 255);
270 QColor m_selectionColor = QColor(0, 0, 128);
271 QColor m_selectionTextColor = QColor(255, 255, 255);
272 QSGTexture::Filtering m_filtering = QSGTexture::Nearest;
273 int m_renderTypeQuality = -1;
274 int m_firstLineInViewport = -1;
275 int m_firstLinePastViewport = -1;
276 bool m_containsUnscalableGlyphs =
false;
277 qreal m_devicePixelRatio = 1.0;
279 friend class QQuickTextEdit;
280 friend class QQuickTextEditPrivate;
#define QQUICKTEXT_LARGETEXT_THRESHOLD
static void positionInlineImage(QQuickStyledTextImgTag *image, int textPos, const QTextLine &line)
static void getLinks_helper(const QTextLayout *layout, QList< QQuickTextPrivate::LinkDesc > *links)