OpenCoverage

qquickcontext2d.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/context2d/qquickcontext2d.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qquickcontext2d_p.h"-
41#include "qquickcontext2dcommandbuffer_p.h"-
42#include "qquickcanvasitem_p.h"-
43#include <private/qtquickglobal_p.h>-
44#include <private/qquickcontext2dtexture_p.h>-
45#include <private/qquickitem_p.h>-
46#if QT_CONFIG(quick_shadereffect)-
47#include <QtQuick/private/qquickshadereffectsource_p.h>-
48#endif-
49#include <qsgrendererinterface.h>-
50-
51#include <QtQuick/private/qsgcontext_p.h>-
52#include <private/qquicksvgparser_p.h>-
53#if QT_CONFIG(quick_path)-
54#include <private/qquickpath_p.h>-
55#endif-
56#include <private/qquickimage_p_p.h>-
57-
58#include <qqmlinfo.h>-
59#include <private/qv8engine_p.h>-
60-
61#include <qqmlengine.h>-
62#include <private/qv4domerrors_p.h>-
63#include <private/qv4engine_p.h>-
64#include <private/qv4object_p.h>-
65#include <private/qv4qobjectwrapper_p.h>-
66#include <private/qquickwindow_p.h>-
67-
68#include <private/qv4value_p.h>-
69#include <private/qv4functionobject_p.h>-
70#include <private/qv4objectproto_p.h>-
71#include <private/qv4scopedvalue_p.h>-
72-
73#include <QtCore/qmath.h>-
74#include <QtCore/qvector.h>-
75#include <QtCore/private/qnumeric_p.h>-
76#include <QtCore/QRunnable>-
77#include <QtGui/qguiapplication.h>-
78#include <QtGui/qopenglframebufferobject.h>-
79#include <private/qguiapplication_p.h>-
80#include <qpa/qplatformintegration.h>-
81-
82#if QT_CONFIG(opengl)-
83# include <private/qsgdefaultrendercontext_p.h>-
84#endif-
85-
86#include <cmath>-
87#if defined(Q_OS_QNX) || defined(Q_OS_ANDROID)-
88#include <ctype.h>-
89#endif-
90-
91QT_BEGIN_NAMESPACE-
92/*!-
93 \qmltype Context2D-
94 \instantiates QQuickContext2D-
95 \inqmlmodule QtQuick-
96 \ingroup qtquick-canvas-
97 \since 5.0-
98 \brief Provides 2D context for shapes on a Canvas item.-
99-
100 The Context2D object can be created by \c Canvas item's \c getContext()-
101 method:-
102 \code-
103 Canvas {-
104 id:canvas-
105 onPaint:{-
106 var ctx = canvas.getContext('2d');-
107 //...-
108 }-
109 }-
110 \endcode-
111 The Context2D API implements the same \l-
112 {http://www.w3.org/TR/2dcontext}{W3C Canvas 2D Context API standard} with-
113 some enhanced features.-
114-
115 The Context2D API provides the rendering \b{context} which defines the-
116 methods and attributes needed to draw on the \c Canvas item. The following-
117 assigns the canvas rendering context to a \c{context} variable:-
118 \code-
119 var context = mycanvas.getContext("2d")-
120 \endcode-
121-
122 The Context2D API renders the canvas as a coordinate system whose origin-
123 (0,0) is at the top left corner, as shown in the figure below. Coordinates-
124 increase along the \c{x} axis from left to right and along the \c{y} axis-
125 from top to bottom of the canvas.-
126 \image qml-item-canvas-context.gif-
127*/-
128-
129-
130-
131Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);-
132-
133#define CHECK_CONTEXT(r) if (!r || !r->d()->context || !r->d()->context->bufferValid()) \-
134 THROW_GENERIC_ERROR("Not a Context2D object");-
135-
136#define CHECK_CONTEXT_SETTER(r) if (!r || !r->d()->context || !r->d()->context->bufferValid()) \-
137 THROW_GENERIC_ERROR("Not a Context2D object");-
138#define qClamp(val, min, max) qMin(qMax(val, min), max)-
139#define CHECK_RGBA(c) (c == '-' || c == '.' || (c >=0 && c <= 9))-
140Q_QUICK_PRIVATE_EXPORT QColor qt_color_from_string(const QV4::Value &name)-
141{-
142 QByteArray str = name.toQString().toUtf8();-
143-
144 char *p = str.data();-
145 int len = str.length();-
146 //rgb/hsl color string has at least 7 characters-
147 if (!p || len > 255 || len <= 7)
!pDescription
TRUEnever evaluated
FALSEnever evaluated
len > 255Description
TRUEnever evaluated
FALSEnever evaluated
len <= 7Description
TRUEnever evaluated
FALSEnever evaluated
0
148 return QColor(p);
never executed: return QColor(p);
0
149 else {-
150 bool isRgb(false), isHsl(false), hasAlpha(false);-
151 Q_UNUSED(isHsl)-
152-
153 while (isspace(*p)) p++;
never executed: p++;
isspace(*p)Description
TRUEnever evaluated
FALSEnever evaluated
0
154 if (strncmp(p, "rgb", 3) == 0)
strncmp(p, "rgb", 3) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
155 isRgb = true;
never executed: isRgb = true;
0
156 else if (strncmp(p, "hsl", 3) == 0)
strncmp(p, "hsl", 3) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
157 isHsl = true;
never executed: isHsl = true;
0
158 else-
159 return QColor(p);
never executed: return QColor(p);
0
160-
161 p+=3; //skip "rgb" or "hsl"-
162 hasAlpha = (*p == 'a') ? true : false;
(*p == 'a')Description
TRUEnever evaluated
FALSEnever evaluated
0
163-
164 ++p; //skip "("-
165-
166 if (hasAlpha) ++p; //skip "a"
never executed: ++p;
hasAlphaDescription
TRUEnever evaluated
FALSEnever evaluated
0
167-
168 int rh, gs, bl, alpha = 255;-
169-
170 //red-
171 while (isspace(*p)) p++;
never executed: p++;
isspace(*p)Description
TRUEnever evaluated
FALSEnever evaluated
0
172 rh = strtol(p, &p, 10);-
173 if (*p == '%') {
*p == '%'Description
TRUEnever evaluated
FALSEnever evaluated
0
174 rh = qRound(rh/100.0 * 255);-
175 ++p;-
176 }
never executed: end of block
0
177 if (*p++ != ',') return QColor();
never executed: return QColor();
*p++ != ','Description
TRUEnever evaluated
FALSEnever evaluated
0
178-
179 //green-
180 while (isspace(*p)) p++;
never executed: p++;
isspace(*p)Description
TRUEnever evaluated
FALSEnever evaluated
0
181 gs = strtol(p, &p, 10);-
182 if (*p == '%') {
*p == '%'Description
TRUEnever evaluated
FALSEnever evaluated
0
183 gs = qRound(gs/100.0 * 255);-
184 ++p;-
185 }
never executed: end of block
0
186 if (*p++ != ',') return QColor();
never executed: return QColor();
*p++ != ','Description
TRUEnever evaluated
FALSEnever evaluated
0
187-
188 //blue-
189 while (isspace(*p)) p++;
never executed: p++;
isspace(*p)Description
TRUEnever evaluated
FALSEnever evaluated
0
190 bl = strtol(p, &p, 10);-
191 if (*p == '%') {
*p == '%'Description
TRUEnever evaluated
FALSEnever evaluated
0
192 bl = qRound(bl/100.0 * 255);-
193 ++p;-
194 }
never executed: end of block
0
195-
196 if (hasAlpha) {
hasAlphaDescription
TRUEnever evaluated
FALSEnever evaluated
0
197 if (*p++!= ',') return QColor();
never executed: return QColor();
*p++!= ','Description
TRUEnever evaluated
FALSEnever evaluated
0
198 while (isspace(*p)) p++;
never executed: p++;
isspace(*p)Description
TRUEnever evaluated
FALSEnever evaluated
0
199 bool ok = false;-
200 alpha = qRound(qstrtod(p, const_cast<const char **>(&p), &ok) * 255);-
201 }
never executed: end of block
0
202-
203 if (*p != ')') return QColor();
never executed: return QColor();
*p != ')'Description
TRUEnever evaluated
FALSEnever evaluated
0
204 if (isRgb)
isRgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
205 return QColor::fromRgba(qRgba(qClamp(rh, 0, 255), qClamp(gs, 0, 255), qClamp(bl, 0, 255), qClamp(alpha, 0, 255)));
never executed: return QColor::fromRgba(qRgba(qMin(qMax(rh, 0), 255), qMin(qMax(gs, 0), 255), qMin(qMax(bl, 0), 255), qMin(qMax(alpha, 0), 255)));
0
206 else if (isHsl)
isHslDescription
TRUEnever evaluated
FALSEnever evaluated
0
207 return QColor::fromHsl(qClamp(rh, 0, 359), qClamp(gs, 0, 255), qClamp(bl, 0, 255), qClamp(alpha, 0, 255));
never executed: return QColor::fromHsl(qMin(qMax(rh, 0), 359), qMin(qMax(gs, 0), 255), qMin(qMax(bl, 0), 255), qMin(qMax(alpha, 0), 255));
0
208 }
never executed: end of block
0
209 return QColor();
never executed: return QColor();
0
210}-
211-
212static int qParseFontSizeFromToken(const QStringRef &fontSizeToken, bool &ok)-
213{-
214 ok = false;-
215 float size = fontSizeToken.trimmed().toFloat(&ok);-
216 if (ok) {
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
217 return int(size);
never executed: return int(size);
0
218 }-
219 qWarning().nospace() << "Context2D: A font size of " << fontSizeToken << " is invalid.";-
220 return 0;
never executed: return 0;
0
221}-
222-
223/*-
224 Attempts to set the font size of \a font to \a fontSizeToken, returning-
225 \c true if successful. If the font size is invalid, \c false is returned-
226 and a warning is printed.-
227*/-
228static bool qSetFontSizeFromToken(QFont &font, const QStringRef &fontSizeToken)-
229{-
230 const QStringRef trimmedToken = fontSizeToken.trimmed();-
231 const QStringRef unitStr = trimmedToken.right(2);-
232 const QStringRef value = trimmedToken.left(trimmedToken.size() - 2);-
233 bool ok = false;-
234 int size = 0;-
235 if (unitStr == QLatin1String("px")) {
unitStr == QLatin1String("px")Description
TRUEnever evaluated
FALSEnever evaluated
0
236 size = qParseFontSizeFromToken(value, ok);-
237 if (ok) {
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
238 font.setPixelSize(size);-
239 return true;
never executed: return true;
0
240 }-
241 } else if (unitStr == QLatin1String("pt")) {
never executed: end of block
unitStr == QLatin1String("pt")Description
TRUEnever evaluated
FALSEnever evaluated
0
242 size = qParseFontSizeFromToken(value, ok);-
243 if (ok) {
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
244 font.setPointSize(size);-
245 return true;
never executed: return true;
0
246 }-
247 } else {
never executed: end of block
0
248 qWarning().nospace() << "Context2D: Invalid font size unit in font string.";-
249 }
never executed: end of block
0
250 return false;
never executed: return false;
0
251}-
252-
253/*-
254 Returns a list of all of the families in \a fontFamiliesString, where-
255 each family is separated by spaces. Families with spaces in their name-
256 must be quoted.-
257*/-
258static QStringList qExtractFontFamiliesFromString(const QStringRef &fontFamiliesString)-
259{-
260 QStringList extractedFamilies;-
261 int quoteIndex = -1;-
262 QString currentFamily;-
263 for (int index = 0; index < fontFamiliesString.size(); ++index) {
index < fontFa...sString.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
264 const QChar ch = fontFamiliesString.at(index);-
265 if (ch == '"' || ch == '\'') {
ch == '"'Description
TRUEnever evaluated
FALSEnever evaluated
ch == '\''Description
TRUEnever evaluated
FALSEnever evaluated
0
266 if (quoteIndex == -1) {
quoteIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
267 quoteIndex = index;-
268 } else {
never executed: end of block
0
269 if (ch == fontFamiliesString.at(quoteIndex)) {
ch == fontFami...at(quoteIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
270 // Found the matching quote. +1/-1 because we don't want the quote as part of the name.-
271 const QString family = fontFamiliesString.mid(quoteIndex + 1, index - quoteIndex - 1).toString();-
272 extractedFamilies.push_back(family);-
273 currentFamily.clear();-
274 quoteIndex = -1;-
275 } else {
never executed: end of block
0
276 qWarning().nospace() << "Context2D: Mismatched quote in font string.";-
277 return QStringList();
never executed: return QStringList();
0
278 }-
279 }-
280 } else if (ch == ' ' && quoteIndex == -1) {
ch == ' 'Description
TRUEnever evaluated
FALSEnever evaluated
quoteIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
281 // This is a space that's not within quotes...-
282 if (!currentFamily.isEmpty()) {
!currentFamily.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
283 // and there is a current family; consider it the end of the current family.-
284 extractedFamilies.push_back(currentFamily);-
285 currentFamily.clear();-
286 } // else: ignore the space
never executed: end of block
0
287 } else {
never executed: end of block
0
288 currentFamily.push_back(ch);-
289 }
never executed: end of block
0
290 }-
291 if (!currentFamily.isEmpty()) {
!currentFamily.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
292 if (quoteIndex == -1) {
quoteIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
293 // This is the end of the string, so add this family to our list.-
294 extractedFamilies.push_back(currentFamily);-
295 } else {
never executed: end of block
0
296 qWarning().nospace() << "Context2D: Unclosed quote in font string.";-
297 return QStringList();
never executed: return QStringList();
0
298 }-
299 }-
300 if (extractedFamilies.isEmpty()) {
extractedFamilies.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
301 qWarning().nospace() << "Context2D: Missing or misplaced font family in font string"-
302 << " (it must come after the font size).";-
303 }
never executed: end of block
0
304 return extractedFamilies;
never executed: return extractedFamilies;
0
305}-
306-
307/*-
308 Tries to set a family on \a font using the families provided in \a fontFamilyTokens.-
309-
310 The list is ordered by preference, with the first family having the highest preference.-
311 If the first family is invalid, the next family in the list is evaluated.-
312 This process is repeated until a valid font is found (at which point the function-
313 will return \c true and the family set on \a font) or there are no more-
314 families left, at which point a warning is printed and \c false is returned.-
315*/-
316static bool qSetFontFamilyFromTokens(QFont &font, const QStringList &fontFamilyTokens)-
317{-
318 for (const QString &fontFamilyToken : fontFamilyTokens) {-
319 QFontDatabase fontDatabase;-
320 if (fontDatabase.hasFamily(fontFamilyToken)) {
fontDatabase.h...ntFamilyToken)Description
TRUEnever evaluated
FALSEnever evaluated
0
321 font.setFamily(fontFamilyToken);-
322 return true;
never executed: return true;
0
323 } else {-
324 // Can't find a family matching this name; if it's a generic family,-
325 // try searching for the default family for it by using style hints.-
326 int styleHint = -1;-
327 if (fontFamilyToken.compare(QLatin1String("serif")) == 0) {
fontFamilyToke..."serif")) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
328 styleHint = QFont::Serif;-
329 } else if (fontFamilyToken.compare(QLatin1String("sans-serif")) == 0) {
never executed: end of block
fontFamilyToke...-serif")) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
330 styleHint = QFont::SansSerif;-
331 } else if (fontFamilyToken.compare(QLatin1String("cursive")) == 0) {
never executed: end of block
fontFamilyToke...ursive")) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
332 styleHint = QFont::Cursive;-
333 } else if (fontFamilyToken.compare(QLatin1String("monospace")) == 0) {
never executed: end of block
fontFamilyToke...ospace")) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
334 styleHint = QFont::Monospace;-
335 } else if (fontFamilyToken.compare(QLatin1String("fantasy")) == 0) {
never executed: end of block
fontFamilyToke...antasy")) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
336 styleHint = QFont::Fantasy;-
337 }
never executed: end of block
0
338 if (styleHint != -1) {
styleHint != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
339 QFont tmp;-
340 tmp.setStyleHint(static_cast<QFont::StyleHint>(styleHint));-
341 font.setFamily(tmp.defaultFamily());-
342 return true;
never executed: return true;
0
343 }-
344 }
never executed: end of block
0
345 }-
346 qWarning("Context2D: The font families specified are invalid: %s", qPrintable(fontFamilyTokens.join(QString()).trimmed()));-
347 return false;
never executed: return false;
0
348}-
349-
350enum FontToken-
351{-
352 NoTokens = 0x00,-
353 FontStyle = 0x01,-
354 FontVariant = 0x02,-
355 FontWeight = 0x04-
356};-
357-
358#define Q_TRY_SET_TOKEN(token, value, setStatement) \-
359if (!(usedTokens & token)) { \-
360 usedTokens |= token; \-
361 setStatement; \-
362} else { \-
363 qWarning().nospace() << "Context2D: Duplicate token " << QLatin1String(value) << " found in font string."; \-
364 return currentFont; \-
365}-
366-
367/*-
368 Parses a font string based on the CSS shorthand font property.-
369-
370 See: http://www.w3.org/TR/css3-fonts/#font-prop-
371*/-
372static QFont qt_font_from_string(const QString& fontString, const QFont &currentFont) {-
373 if (fontString.isEmpty()) {
fontString.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
374 qWarning().nospace() << "Context2D: Font string is empty.";-
375 return currentFont;
never executed: return currentFont;
0
376 }-
377-
378 // We know that font-size must be specified and it must be before font-family-
379 // (which could potentially have "px" or "pt" in its name), so extract it now.-
380 int fontSizeEnd = fontString.indexOf(QLatin1String("px"));-
381 if (fontSizeEnd == -1)
fontSizeEnd == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
382 fontSizeEnd = fontString.indexOf(QLatin1String("pt"));
never executed: fontSizeEnd = fontString.indexOf(QLatin1String("pt"));
0
383 if (fontSizeEnd == -1) {
fontSizeEnd == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
384 qWarning().nospace() << "Context2D: Invalid font size unit in font string.";-
385 return currentFont;
never executed: return currentFont;
0
386 }-
387-
388 int fontSizeStart = fontString.lastIndexOf(' ', fontSizeEnd);-
389 if (fontSizeStart == -1) {
fontSizeStart == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
390 // The font size might be the first token in the font string, which is OK.-
391 // Regardless, we'll find out if the font is invalid with qSetFontSizeFromToken().-
392 fontSizeStart = 0;-
393 } else {
never executed: end of block
0
394 // Don't want to take the leading space.-
395 ++fontSizeStart;-
396 }
never executed: end of block
0
397-
398 // + 2 for the unit, +1 for the space that we require.-
399 fontSizeEnd += 3;-
400-
401 QFont newFont;-
402 if (!qSetFontSizeFromToken(newFont, fontString.midRef(fontSizeStart, fontSizeEnd - fontSizeStart)))
!qSetFontSizeF...ontSizeStart))Description
TRUEnever evaluated
FALSEnever evaluated
0
403 return currentFont;
never executed: return currentFont;
0
404-
405 // We don't want to parse the size twice, so remove it now.-
406 QString remainingFontString = fontString;-
407 remainingFontString.remove(fontSizeStart, fontSizeEnd - fontSizeStart);-
408 QStringRef remainingFontStringRef(&remainingFontString);-
409-
410 // Next, we have to take any font families out, as QString::split() will ruin quoted family names.-
411 const QStringRef fontFamiliesString = remainingFontStringRef.mid(fontSizeStart);-
412 remainingFontStringRef.truncate(fontSizeStart);-
413 QStringList fontFamilies = qExtractFontFamiliesFromString(fontFamiliesString);-
414 if (fontFamilies.isEmpty()) {
fontFamilies.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
415 return currentFont;
never executed: return currentFont;
0
416 }-
417 if (!qSetFontFamilyFromTokens(newFont, fontFamilies))
!qSetFontFamil... fontFamilies)Description
TRUEnever evaluated
FALSEnever evaluated
0
418 return currentFont;
never executed: return currentFont;
0
419-
420 // Now that we've removed the messy parts, we can split the font string on spaces.-
421 const QStringRef trimmedTokensStr = remainingFontStringRef.trimmed();-
422 if (trimmedTokensStr.isEmpty()) {
trimmedTokensStr.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
423 // No optional properties.-
424 return newFont;
never executed: return newFont;
0
425 }-
426 const auto tokens = trimmedTokensStr.split(QLatin1Char(' '));-
427-
428 int usedTokens = NoTokens;-
429 // Optional properties can be in any order, but font-size and font-family must be last.-
430 for (const QStringRef &token : tokens) {-
431 if (token.compare(QLatin1String("normal")) == 0) {
token.compare(...normal")) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
432 if (!(usedTokens & FontStyle) || !(usedTokens & FontVariant) || !(usedTokens & FontWeight)) {
!(usedTokens & FontStyle)Description
TRUEnever evaluated
FALSEnever evaluated
!(usedTokens & FontVariant)Description
TRUEnever evaluated
FALSEnever evaluated
!(usedTokens & FontWeight)Description
TRUEnever evaluated
FALSEnever evaluated
0
433 // Could be font-style, font-variant or font-weight.-
434 if (!(usedTokens & FontStyle)) {
!(usedTokens & FontStyle)Description
TRUEnever evaluated
FALSEnever evaluated
0
435 // QFont::StyleNormal is the default for QFont::style.-
436 usedTokens = usedTokens | FontStyle;-
437 } else if (!(usedTokens & FontVariant)) {
never executed: end of block
!(usedTokens & FontVariant)Description
TRUEnever evaluated
FALSEnever evaluated
0
438 // QFont::MixedCase is the default for QFont::capitalization.-
439 usedTokens |= FontVariant;-
440 } else if (!(usedTokens & FontWeight)) {
never executed: end of block
!(usedTokens & FontWeight)Description
TRUEnever evaluated
FALSEnever evaluated
0
441 // QFont::Normal is the default for QFont::weight.-
442 usedTokens |= FontWeight;-
443 }
never executed: end of block
0
444 } else {
never executed: end of block
0
445 qWarning().nospace() << "Context2D: Duplicate token \"normal\" found in font string.";-
446 return currentFont;
never executed: return currentFont;
0
447 }-
448 } else if (token.compare(QLatin1String("bold")) == 0) {
token.compare(...("bold")) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
449 Q_TRY_SET_TOKEN(FontWeight, "bold", newFont.setBold(true))
never executed: end of block
never executed: return currentFont;
!(usedTokens & FontWeight)Description
TRUEnever evaluated
FALSEnever evaluated
0
450 } else if (token.compare(QLatin1String("italic")) == 0) {
token.compare(...italic")) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
451 Q_TRY_SET_TOKEN(FontStyle, "italic", newFont.setStyle(QFont::StyleItalic))
never executed: end of block
never executed: return currentFont;
!(usedTokens & FontStyle)Description
TRUEnever evaluated
FALSEnever evaluated
0
452 } else if (token.compare(QLatin1String("oblique")) == 0) {
token.compare(...blique")) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
453 Q_TRY_SET_TOKEN(FontStyle, "oblique", newFont.setStyle(QFont::StyleOblique))
never executed: end of block
never executed: return currentFont;
!(usedTokens & FontStyle)Description
TRUEnever evaluated
FALSEnever evaluated
0
454 } else if (token.compare(QLatin1String("small-caps")) == 0) {
token.compare(...l-caps")) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
455 Q_TRY_SET_TOKEN(FontVariant, "small-caps", newFont.setCapitalization(QFont::SmallCaps))
never executed: end of block
never executed: return currentFont;
!(usedTokens & FontVariant)Description
TRUEnever evaluated
FALSEnever evaluated
0
456 } else {-
457 bool conversionOk = false;-
458 int weight = token.toInt(&conversionOk);-
459 if (conversionOk) {
conversionOkDescription
TRUEnever evaluated
FALSEnever evaluated
0
460 if (weight >= 0 && weight <= 99) {
weight >= 0Description
TRUEnever evaluated
FALSEnever evaluated
weight <= 99Description
TRUEnever evaluated
FALSEnever evaluated
0
461 Q_TRY_SET_TOKEN(FontWeight, "<font-weight>", newFont.setWeight(weight))
never executed: end of block
never executed: return currentFont;
!(usedTokens & FontWeight)Description
TRUEnever evaluated
FALSEnever evaluated
0
462 continue;
never executed: continue;
0
463 } else {-
464 qWarning().nospace() << "Context2D: Invalid font weight " << weight << " found in font string; "-
465 << "must be between 0 and 99, inclusive.";-
466 return currentFont;
never executed: return currentFont;
0
467 }-
468 }-
469 // The token is invalid or in the wrong place/order in the font string.-
470 qWarning().nospace() << "Context2D: Invalid or misplaced token " << token << " found in font string.";-
471 return currentFont;
never executed: return currentFont;
0
472 }-
473 }-
474 return newFont;
never executed: return newFont;
0
475}-
476-
477class QQuickContext2DEngineData : public QV8Engine::Deletable-
478{-
479public:-
480 QQuickContext2DEngineData(QV4::ExecutionEngine *engine);-
481 ~QQuickContext2DEngineData();-
482-
483 QV4::PersistentValue contextPrototype;-
484 QV4::PersistentValue gradientProto;-
485 QV4::PersistentValue pixelArrayProto;-
486};-
487-
488V4_DEFINE_EXTENSION(QQuickContext2DEngineData, engineData)
never executed: extensionId = QV8Engine::registerExtension();
never executed: end of block
never executed: end of block
never executed: return rv;
extensionId == -1Description
TRUEnever evaluated
FALSEnever evaluated
extensionId == -1Description
TRUEnever evaluated
FALSEnever evaluated
!rvDescription
TRUEnever evaluated
FALSEnever evaluated
0
489-
490namespace QV4 {-
491namespace Heap {-
492-
493struct QQuickJSContext2D : Object {-
494 void init() { Object::init(); }
never executed: end of block
0
495 QQuickContext2D* context;-
496};-
497-
498struct QQuickJSContext2DPrototype : Object {-
499 void init() { Object::init(); }
never executed: end of block
0
500};-
501-
502struct QQuickContext2DStyle : Object {-
503 void init()-
504 {-
505 brush = new QBrush;-
506 patternRepeatX = false;-
507 patternRepeatY = false;-
508 }
never executed: end of block
0
509 void destroy() {-
510 delete brush;-
511 Object::destroy();-
512 }
never executed: end of block
0
513-
514 QBrush *brush;-
515 bool patternRepeatX:1;-
516 bool patternRepeatY:1;-
517};-
518-
519struct QQuickJSContext2DPixelData : Object {-
520 void init();-
521 void destroy() {-
522 delete image;-
523 Object::destroy();-
524 }
never executed: end of block
0
525-
526 QImage *image;-
527};-
528-
529struct QQuickJSContext2DImageData : Object {-
530 void init();-
531-
532 static void markObjects(QV4::Heap::Base *that, QV4::MarkStack *markStack) {-
533 static_cast<QQuickJSContext2DImageData *>(that)->pixelData.mark(markStack);-
534 Object::markObjects(that, markStack);-
535 }
never executed: end of block
0
536-
537 QV4::Value pixelData;-
538};-
539-
540}-
541}-
542-
543struct QQuickJSContext2D : public QV4::Object-
544{-
545 V4_OBJECT2(QQuickJSContext2D, QV4::Object)
never executed: end of block
never executed: end of block
never executed: return &static_vtbl;
never executed: return static_cast<QV4::Heap::QQuickJSContext2D *>(m());
never executed: return dptr;
0
546-
547 static QV4::ReturnedValue method_get_globalAlpha(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
548 static QV4::ReturnedValue method_set_globalAlpha(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
549 static QV4::ReturnedValue method_get_globalCompositeOperation(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
550 static QV4::ReturnedValue method_set_globalCompositeOperation(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
551 static QV4::ReturnedValue method_get_fillStyle(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
552 static QV4::ReturnedValue method_set_fillStyle(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
553 static QV4::ReturnedValue method_get_fillRule(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
554 static QV4::ReturnedValue method_set_fillRule(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
555 static QV4::ReturnedValue method_get_strokeStyle(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
556 static QV4::ReturnedValue method_set_strokeStyle(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
557-
558 static QV4::ReturnedValue method_get_lineCap(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
559 static QV4::ReturnedValue method_set_lineCap(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
560 static QV4::ReturnedValue method_get_lineJoin(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
561 static QV4::ReturnedValue method_set_lineJoin(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
562 static QV4::ReturnedValue method_get_lineWidth(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
563 static QV4::ReturnedValue method_set_lineWidth(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
564 static QV4::ReturnedValue method_get_miterLimit(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
565 static QV4::ReturnedValue method_set_miterLimit(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
566-
567 static QV4::ReturnedValue method_get_shadowBlur(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
568 static QV4::ReturnedValue method_set_shadowBlur(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
569 static QV4::ReturnedValue method_get_shadowColor(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
570 static QV4::ReturnedValue method_set_shadowColor(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
571 static QV4::ReturnedValue method_get_shadowOffsetX(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
572 static QV4::ReturnedValue method_set_shadowOffsetX(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
573 static QV4::ReturnedValue method_get_shadowOffsetY(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
574 static QV4::ReturnedValue method_set_shadowOffsetY(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
575-
576 // should these two be on the proto?-
577#if QT_CONFIG(quick_path)-
578 static QV4::ReturnedValue method_get_path(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
579 static QV4::ReturnedValue method_set_path(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
580#endif-
581 static QV4::ReturnedValue method_get_font(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
582 static QV4::ReturnedValue method_set_font(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
583 static QV4::ReturnedValue method_get_textAlign(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
584 static QV4::ReturnedValue method_set_textAlign(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
585 static QV4::ReturnedValue method_get_textBaseline(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
586 static QV4::ReturnedValue method_set_textBaseline(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
587};-
588-
589DEFINE_OBJECT_VTABLE(QQuickJSContext2D);-
590-
591-
592struct QQuickJSContext2DPrototype : public QV4::Object-
593{-
594 V4_OBJECT2(QQuickJSContext2DPrototype, QV4::Object)
never executed: end of block
never executed: end of block
never executed: return &static_vtbl;
never executed: return static_cast<QV4::Heap::QQuickJSContext2DPrototype *>(m());
never executed: return dptr;
0
595public:-
596 static QV4::Heap::QQuickJSContext2DPrototype *create(QV4::ExecutionEngine *engine)-
597 {-
598 QV4::Scope scope(engine);-
599 QV4::Scoped<QQuickJSContext2DPrototype> o(scope, engine->memoryManager->allocate<QQuickJSContext2DPrototype>());-
600-
601 o->defineDefaultProperty(QStringLiteral("quadraticCurveTo"), method_quadraticCurveTo, 0);
never executed: return qstring_literal_temp;
0
602 o->defineDefaultProperty(QStringLiteral("restore"), method_restore, 0);
never executed: return qstring_literal_temp;
0
603 o->defineDefaultProperty(QStringLiteral("moveTo"), method_moveTo, 0);
never executed: return qstring_literal_temp;
0
604 o->defineDefaultProperty(QStringLiteral("lineTo"), method_lineTo, 0);
never executed: return qstring_literal_temp;
0
605 o->defineDefaultProperty(QStringLiteral("caretBlinkRate"), method_caretBlinkRate, 0);
never executed: return qstring_literal_temp;
0
606 o->defineDefaultProperty(QStringLiteral("clip"), method_clip, 0);
never executed: return qstring_literal_temp;
0
607 o->defineDefaultProperty(QStringLiteral("setTransform"), method_setTransform, 0);
never executed: return qstring_literal_temp;
0
608 o->defineDefaultProperty(QStringLiteral("text"), method_text, 0);
never executed: return qstring_literal_temp;
0
609 o->defineDefaultProperty(QStringLiteral("roundedRect"), method_roundedRect, 0);
never executed: return qstring_literal_temp;
0
610 o->defineDefaultProperty(QStringLiteral("createPattern"), method_createPattern, 0);
never executed: return qstring_literal_temp;
0
611 o->defineDefaultProperty(QStringLiteral("stroke"), method_stroke, 0);
never executed: return qstring_literal_temp;
0
612 o->defineDefaultProperty(QStringLiteral("arc"), method_arc, 0);
never executed: return qstring_literal_temp;
0
613 o->defineDefaultProperty(QStringLiteral("createImageData"), method_createImageData, 0);
never executed: return qstring_literal_temp;
0
614 o->defineDefaultProperty(QStringLiteral("measureText"), method_measureText, 0);
never executed: return qstring_literal_temp;
0
615 o->defineDefaultProperty(QStringLiteral("ellipse"), method_ellipse, 0);
never executed: return qstring_literal_temp;
0
616 o->defineDefaultProperty(QStringLiteral("fill"), method_fill, 0);
never executed: return qstring_literal_temp;
0
617 o->defineDefaultProperty(QStringLiteral("save"), method_save, 0);
never executed: return qstring_literal_temp;
0
618 o->defineDefaultProperty(QStringLiteral("scale"), method_scale, 0);
never executed: return qstring_literal_temp;
0
619 o->defineDefaultProperty(QStringLiteral("drawImage"), method_drawImage, 0);
never executed: return qstring_literal_temp;
0
620 o->defineDefaultProperty(QStringLiteral("transform"), method_transform, 0);
never executed: return qstring_literal_temp;
0
621 o->defineDefaultProperty(QStringLiteral("fillText"), method_fillText, 0);
never executed: return qstring_literal_temp;
0
622 o->defineDefaultProperty(QStringLiteral("strokeText"), method_strokeText, 0);
never executed: return qstring_literal_temp;
0
623 o->defineDefaultProperty(QStringLiteral("translate"), method_translate, 0);
never executed: return qstring_literal_temp;
0
624 o->defineDefaultProperty(QStringLiteral("createRadialGradient"), method_createRadialGradient, 0);
never executed: return qstring_literal_temp;
0
625 o->defineDefaultProperty(QStringLiteral("shear"), method_shear, 0);
never executed: return qstring_literal_temp;
0
626 o->defineDefaultProperty(QStringLiteral("isPointInPath"), method_isPointInPath, 0);
never executed: return qstring_literal_temp;
0
627 o->defineDefaultProperty(QStringLiteral("bezierCurveTo"), method_bezierCurveTo, 0);
never executed: return qstring_literal_temp;
0
628 o->defineDefaultProperty(QStringLiteral("resetTransform"), method_resetTransform, 0);
never executed: return qstring_literal_temp;
0
629 o->defineDefaultProperty(QStringLiteral("arcTo"), method_arcTo, 0);
never executed: return qstring_literal_temp;
0
630 o->defineDefaultProperty(QStringLiteral("fillRect"), method_fillRect, 0);
never executed: return qstring_literal_temp;
0
631 o->defineDefaultProperty(QStringLiteral("createConicalGradient"), method_createConicalGradient, 0);
never executed: return qstring_literal_temp;
0
632 o->defineDefaultProperty(QStringLiteral("drawFocusRing"), method_drawFocusRing, 0);
never executed: return qstring_literal_temp;
0
633 o->defineDefaultProperty(QStringLiteral("beginPath"), method_beginPath, 0);
never executed: return qstring_literal_temp;
0
634 o->defineDefaultProperty(QStringLiteral("clearRect"), method_clearRect, 0);
never executed: return qstring_literal_temp;
0
635 o->defineDefaultProperty(QStringLiteral("rect"), method_rect, 0);
never executed: return qstring_literal_temp;
0
636 o->defineDefaultProperty(QStringLiteral("reset"), method_reset, 0);
never executed: return qstring_literal_temp;
0
637 o->defineDefaultProperty(QStringLiteral("rotate"), method_rotate, 0);
never executed: return qstring_literal_temp;
0
638 o->defineDefaultProperty(QStringLiteral("setCaretSelectionRect"), method_setCaretSelectionRect, 0);
never executed: return qstring_literal_temp;
0
639 o->defineDefaultProperty(QStringLiteral("putImageData"), method_putImageData, 0);
never executed: return qstring_literal_temp;
0
640 o->defineDefaultProperty(QStringLiteral("getImageData"), method_getImageData, 0);
never executed: return qstring_literal_temp;
0
641 o->defineDefaultProperty(QStringLiteral("createLinearGradient"), method_createLinearGradient, 0);
never executed: return qstring_literal_temp;
0
642 o->defineDefaultProperty(QStringLiteral("strokeRect"), method_strokeRect, 0);
never executed: return qstring_literal_temp;
0
643 o->defineDefaultProperty(QStringLiteral("closePath"), method_closePath, 0);
never executed: return qstring_literal_temp;
0
644 o->defineAccessorProperty(QStringLiteral("canvas"), QQuickJSContext2DPrototype::method_get_canvas, nullptr);
never executed: return qstring_literal_temp;
0
645-
646 return o->d();
never executed: return o->d();
0
647 }-
648-
649 static QV4::ReturnedValue method_get_canvas(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
650 static QV4::ReturnedValue method_restore(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
651 static QV4::ReturnedValue method_reset(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
652 static QV4::ReturnedValue method_save(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
653 static QV4::ReturnedValue method_rotate(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
654 static QV4::ReturnedValue method_scale(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
655 static QV4::ReturnedValue method_translate(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
656 static QV4::ReturnedValue method_setTransform(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
657 static QV4::ReturnedValue method_transform(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
658 static QV4::ReturnedValue method_resetTransform(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
659 static QV4::ReturnedValue method_shear(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
660 static QV4::ReturnedValue method_createLinearGradient(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
661 static QV4::ReturnedValue method_createRadialGradient(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
662 static QV4::ReturnedValue method_createConicalGradient(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
663 static QV4::ReturnedValue method_createPattern(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
664 static QV4::ReturnedValue method_clearRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
665 static QV4::ReturnedValue method_fillRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
666 static QV4::ReturnedValue method_strokeRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
667 static QV4::ReturnedValue method_arc(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
668 static QV4::ReturnedValue method_arcTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
669 static QV4::ReturnedValue method_beginPath(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
670 static QV4::ReturnedValue method_bezierCurveTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
671 static QV4::ReturnedValue method_clip(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
672 static QV4::ReturnedValue method_closePath(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
673 static QV4::ReturnedValue method_fill(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
674 static QV4::ReturnedValue method_lineTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
675 static QV4::ReturnedValue method_moveTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
676 static QV4::ReturnedValue method_quadraticCurveTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
677 static QV4::ReturnedValue method_rect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
678 static QV4::ReturnedValue method_roundedRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
679 static QV4::ReturnedValue method_ellipse(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
680 static QV4::ReturnedValue method_text(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
681 static QV4::ReturnedValue method_stroke(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
682 static QV4::ReturnedValue method_isPointInPath(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
683 static QV4::ReturnedValue method_drawFocusRing(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
684 static QV4::ReturnedValue method_setCaretSelectionRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
685 static QV4::ReturnedValue method_caretBlinkRate(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
686 static QV4::ReturnedValue method_fillText(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
687 static QV4::ReturnedValue method_strokeText(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
688 static QV4::ReturnedValue method_measureText(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
689 static QV4::ReturnedValue method_drawImage(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
690 static QV4::ReturnedValue method_createImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
691 static QV4::ReturnedValue method_getImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
692 static QV4::ReturnedValue method_putImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
693-
694};-
695-
696DEFINE_OBJECT_VTABLE(QQuickJSContext2DPrototype);-
697-
698-
699struct QQuickContext2DStyle : public QV4::Object-
700{-
701 V4_OBJECT2(QQuickContext2DStyle, QV4::Object)
never executed: end of block
never executed: end of block
never executed: return &static_vtbl;
never executed: return static_cast<QV4::Heap::QQuickContext2DStyle *>(m());
never executed: return dptr;
0
702 V4_NEEDS_DESTROY
never executed: end of block
0
703-
704 static QV4::ReturnedValue gradient_proto_addColorStop(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
705};-
706-
707-
708-
709DEFINE_OBJECT_VTABLE(QQuickContext2DStyle);-
710-
711QImage qt_image_convolute_filter(const QImage& src, const QVector<qreal>& weights, int radius = 0)-
712{-
713 // weights 3x3 => delta 1-
714 int delta = radius ? radius : qFloor(qSqrt(weights.size()) / qreal(2));
radiusDescription
TRUEnever evaluated
FALSEnever evaluated
0
715 int filterDim = 2 * delta + 1;-
716-
717 QImage dst = QImage(src.size(), src.format());-
718-
719 int w = src.width();-
720 int h = src.height();-
721-
722 const QRgb *sr = (const QRgb *)(src.constBits());-
723 int srcStride = src.bytesPerLine() / 4;-
724-
725 QRgb *dr = (QRgb*)dst.bits();-
726 int dstStride = dst.bytesPerLine() / 4;-
727-
728 for (int y = 0; y < h; ++y) {
y < hDescription
TRUEnever evaluated
FALSEnever evaluated
0
729 for (int x = 0; x < w; ++x) {
x < wDescription
TRUEnever evaluated
FALSEnever evaluated
0
730 int red = 0;-
731 int green = 0;-
732 int blue = 0;-
733 int alpha = 0;-
734-
735 qreal redF = 0;-
736 qreal greenF = 0;-
737 qreal blueF = 0;-
738 qreal alphaF = 0;-
739-
740 int sy = y;-
741 int sx = x;-
742-
743 for (int cy = 0; cy < filterDim; ++cy) {
cy < filterDimDescription
TRUEnever evaluated
FALSEnever evaluated
0
744 int scy = sy + cy - delta;-
745-
746 if (scy < 0 || scy >= h)
scy < 0Description
TRUEnever evaluated
FALSEnever evaluated
scy >= hDescription
TRUEnever evaluated
FALSEnever evaluated
0
747 continue;
never executed: continue;
0
748-
749 const QRgb *sry = sr + scy * srcStride;-
750-
751 for (int cx = 0; cx < filterDim; ++cx) {
cx < filterDimDescription
TRUEnever evaluated
FALSEnever evaluated
0
752 int scx = sx + cx - delta;-
753-
754 if (scx < 0 || scx >= w)
scx < 0Description
TRUEnever evaluated
FALSEnever evaluated
scx >= wDescription
TRUEnever evaluated
FALSEnever evaluated
0
755 continue;
never executed: continue;
0
756-
757 const QRgb col = sry[scx];-
758-
759 if (radius) {
radiusDescription
TRUEnever evaluated
FALSEnever evaluated
0
760 red += qRed(col);-
761 green += qGreen(col);-
762 blue += qBlue(col);-
763 alpha += qAlpha(col);-
764 } else {
never executed: end of block
0
765 qreal wt = weights[cy * filterDim + cx];-
766-
767 redF += qRed(col) * wt;-
768 greenF += qGreen(col) * wt;-
769 blueF += qBlue(col) * wt;-
770 alphaF += qAlpha(col) * wt;-
771 }
never executed: end of block
0
772 }-
773 }
never executed: end of block
0
774-
775 if (radius)
radiusDescription
TRUEnever evaluated
FALSEnever evaluated
0
776 dr[x] = qRgba(qRound(red * weights[0]), qRound(green * weights[0]), qRound(blue * weights[0]), qRound(alpha * weights[0]));
never executed: dr[x] = qRgba(qRound(red * weights[0]), qRound(green * weights[0]), qRound(blue * weights[0]), qRound(alpha * weights[0]));
0
777 else-
778 dr[x] = qRgba(qRound(redF), qRound(greenF), qRound(blueF), qRound(alphaF));
never executed: dr[x] = qRgba(qRound(redF), qRound(greenF), qRound(blueF), qRound(alphaF));
0
779 }-
780-
781 dr += dstStride;-
782 }
never executed: end of block
0
783-
784 return dst;
never executed: return dst;
0
785}-
786-
787void qt_image_boxblur(QImage& image, int radius, bool quality)-
788{-
789 int passes = quality? 3: 1;
qualityDescription
TRUEnever evaluated
FALSEnever evaluated
0
790 int filterSize = 2 * radius + 1;-
791 for (int i = 0; i < passes; ++i)
i < passesDescription
TRUEnever evaluated
FALSEnever evaluated
0
792 image = qt_image_convolute_filter(image, QVector<qreal>() << 1.0 / (filterSize * filterSize), radius);
never executed: image = qt_image_convolute_filter(image, QVector<qreal>() << 1.0 / (filterSize * filterSize), radius);
0
793}
never executed: end of block
0
794-
795static QPainter::CompositionMode qt_composite_mode_from_string(const QString &compositeOperator)-
796{-
797 if (compositeOperator == QLatin1String("source-over")) {
compositeOpera..."source-over")Description
TRUEnever evaluated
FALSEnever evaluated
0
798 return QPainter::CompositionMode_SourceOver;
never executed: return QPainter::CompositionMode_SourceOver;
0
799 } else if (compositeOperator == QLatin1String("source-out")) {
compositeOpera...("source-out")Description
TRUEnever evaluated
FALSEnever evaluated
0
800 return QPainter::CompositionMode_SourceOut;
never executed: return QPainter::CompositionMode_SourceOut;
0
801 } else if (compositeOperator == QLatin1String("source-in")) {
compositeOpera...g("source-in")Description
TRUEnever evaluated
FALSEnever evaluated
0
802 return QPainter::CompositionMode_SourceIn;
never executed: return QPainter::CompositionMode_SourceIn;
0
803 } else if (compositeOperator == QLatin1String("source-atop")) {
compositeOpera..."source-atop")Description
TRUEnever evaluated
FALSEnever evaluated
0
804 return QPainter::CompositionMode_SourceAtop;
never executed: return QPainter::CompositionMode_SourceAtop;
0
805 } else if (compositeOperator == QLatin1String("destination-atop")) {
compositeOpera...ination-atop")Description
TRUEnever evaluated
FALSEnever evaluated
0
806 return QPainter::CompositionMode_DestinationAtop;
never executed: return QPainter::CompositionMode_DestinationAtop;
0
807 } else if (compositeOperator == QLatin1String("destination-in")) {
compositeOpera...stination-in")Description
TRUEnever evaluated
FALSEnever evaluated
0
808 return QPainter::CompositionMode_DestinationIn;
never executed: return QPainter::CompositionMode_DestinationIn;
0
809 } else if (compositeOperator == QLatin1String("destination-out")) {
compositeOpera...tination-out")Description
TRUEnever evaluated
FALSEnever evaluated
0
810 return QPainter::CompositionMode_DestinationOut;
never executed: return QPainter::CompositionMode_DestinationOut;
0
811 } else if (compositeOperator == QLatin1String("destination-over")) {
compositeOpera...ination-over")Description
TRUEnever evaluated
FALSEnever evaluated
0
812 return QPainter::CompositionMode_DestinationOver;
never executed: return QPainter::CompositionMode_DestinationOver;
0
813 } else if (compositeOperator == QLatin1String("lighter")) {
compositeOpera...ing("lighter")Description
TRUEnever evaluated
FALSEnever evaluated
0
814 return QPainter::CompositionMode_Plus;
never executed: return QPainter::CompositionMode_Plus;
0
815 } else if (compositeOperator == QLatin1String("copy")) {
compositeOpera...String("copy")Description
TRUEnever evaluated
FALSEnever evaluated
0
816 return QPainter::CompositionMode_Source;
never executed: return QPainter::CompositionMode_Source;
0
817 } else if (compositeOperator == QLatin1String("xor")) {
compositeOpera...1String("xor")Description
TRUEnever evaluated
FALSEnever evaluated
0
818 return QPainter::CompositionMode_Xor;
never executed: return QPainter::CompositionMode_Xor;
0
819 } else if (compositeOperator == QLatin1String("qt-clear")) {
compositeOpera...ng("qt-clear")Description
TRUEnever evaluated
FALSEnever evaluated
0
820 return QPainter::CompositionMode_Clear;
never executed: return QPainter::CompositionMode_Clear;
0
821 } else if (compositeOperator == QLatin1String("qt-destination")) {
compositeOpera...-destination")Description
TRUEnever evaluated
FALSEnever evaluated
0
822 return QPainter::CompositionMode_Destination;
never executed: return QPainter::CompositionMode_Destination;
0
823 } else if (compositeOperator == QLatin1String("qt-multiply")) {
compositeOpera..."qt-multiply")Description
TRUEnever evaluated
FALSEnever evaluated
0
824 return QPainter::CompositionMode_Multiply;
never executed: return QPainter::CompositionMode_Multiply;
0
825 } else if (compositeOperator == QLatin1String("qt-screen")) {
compositeOpera...g("qt-screen")Description
TRUEnever evaluated
FALSEnever evaluated
0
826 return QPainter::CompositionMode_Screen;
never executed: return QPainter::CompositionMode_Screen;
0
827 } else if (compositeOperator == QLatin1String("qt-overlay")) {
compositeOpera...("qt-overlay")Description
TRUEnever evaluated
FALSEnever evaluated
0
828 return QPainter::CompositionMode_Overlay;
never executed: return QPainter::CompositionMode_Overlay;
0
829 } else if (compositeOperator == QLatin1String("qt-darken")) {
compositeOpera...g("qt-darken")Description
TRUEnever evaluated
FALSEnever evaluated
0
830 return QPainter::CompositionMode_Darken;
never executed: return QPainter::CompositionMode_Darken;
0
831 } else if (compositeOperator == QLatin1String("qt-lighten")) {
compositeOpera...("qt-lighten")Description
TRUEnever evaluated
FALSEnever evaluated
0
832 return QPainter::CompositionMode_Lighten;
never executed: return QPainter::CompositionMode_Lighten;
0
833 } else if (compositeOperator == QLatin1String("qt-color-dodge")) {
compositeOpera...-color-dodge")Description
TRUEnever evaluated
FALSEnever evaluated
0
834 return QPainter::CompositionMode_ColorDodge;
never executed: return QPainter::CompositionMode_ColorDodge;
0
835 } else if (compositeOperator == QLatin1String("qt-color-burn")) {
compositeOpera...t-color-burn")Description
TRUEnever evaluated
FALSEnever evaluated
0
836 return QPainter::CompositionMode_ColorBurn;
never executed: return QPainter::CompositionMode_ColorBurn;
0
837 } else if (compositeOperator == QLatin1String("qt-hard-light")) {
compositeOpera...t-hard-light")Description
TRUEnever evaluated
FALSEnever evaluated
0
838 return QPainter::CompositionMode_HardLight;
never executed: return QPainter::CompositionMode_HardLight;
0
839 } else if (compositeOperator == QLatin1String("qt-soft-light")) {
compositeOpera...t-soft-light")Description
TRUEnever evaluated
FALSEnever evaluated
0
840 return QPainter::CompositionMode_SoftLight;
never executed: return QPainter::CompositionMode_SoftLight;
0
841 } else if (compositeOperator == QLatin1String("qt-difference")) {
compositeOpera...t-difference")Description
TRUEnever evaluated
FALSEnever evaluated
0
842 return QPainter::CompositionMode_Difference;
never executed: return QPainter::CompositionMode_Difference;
0
843 } else if (compositeOperator == QLatin1String("qt-exclusion")) {
compositeOpera...qt-exclusion")Description
TRUEnever evaluated
FALSEnever evaluated
0
844 return QPainter::CompositionMode_Exclusion;
never executed: return QPainter::CompositionMode_Exclusion;
0
845 }-
846 return QPainter::CompositionMode_SourceOver;
never executed: return QPainter::CompositionMode_SourceOver;
0
847}-
848-
849static QString qt_composite_mode_to_string(QPainter::CompositionMode op)-
850{-
851 switch (op) {-
852 case QPainter::CompositionMode_SourceOver:
never executed: case QPainter::CompositionMode_SourceOver:
0
853 return QStringLiteral("source-over");-
854 case QPainter::CompositionMode_DestinationOver:
code before this statement never executed: case QPainter::CompositionMode_DestinationOver:
never executed: case QPainter::CompositionMode_DestinationOver:
0
855 return QStringLiteral("destination-over");-
856 case QPainter::CompositionMode_Clear:
code before this statement never executed: case QPainter::CompositionMode_Clear:
never executed: case QPainter::CompositionMode_Clear:
0
857 return QStringLiteral("qt-clear");-
858 case QPainter::CompositionMode_Source:
code before this statement never executed: case QPainter::CompositionMode_Source:
never executed: case QPainter::CompositionMode_Source:
0
859 return QStringLiteral("copy");-
860 case QPainter::CompositionMode_Destination:
code before this statement never executed: case QPainter::CompositionMode_Destination:
never executed: case QPainter::CompositionMode_Destination:
0
861 return QStringLiteral("qt-destination");-
862 case QPainter::CompositionMode_SourceIn:
code before this statement never executed: case QPainter::CompositionMode_SourceIn:
never executed: case QPainter::CompositionMode_SourceIn:
0
863 return QStringLiteral("source-in");-
864 case QPainter::CompositionMode_DestinationIn:
code before this statement never executed: case QPainter::CompositionMode_DestinationIn:
never executed: case QPainter::CompositionMode_DestinationIn:
0
865 return QStringLiteral("destination-in");-
866 case QPainter::CompositionMode_SourceOut:
code before this statement never executed: case QPainter::CompositionMode_SourceOut:
never executed: case QPainter::CompositionMode_SourceOut:
0
867 return QStringLiteral("source-out");-
868 case QPainter::CompositionMode_DestinationOut:
code before this statement never executed: case QPainter::CompositionMode_DestinationOut:
never executed: case QPainter::CompositionMode_DestinationOut:
0
869 return QStringLiteral("destination-out");-
870 case QPainter::CompositionMode_SourceAtop:
code before this statement never executed: case QPainter::CompositionMode_SourceAtop:
never executed: case QPainter::CompositionMode_SourceAtop:
0
871 return QStringLiteral("source-atop");-
872 case QPainter::CompositionMode_DestinationAtop:
code before this statement never executed: case QPainter::CompositionMode_DestinationAtop:
never executed: case QPainter::CompositionMode_DestinationAtop:
0
873 return QStringLiteral("destination-atop");-
874 case QPainter::CompositionMode_Xor:
code before this statement never executed: case QPainter::CompositionMode_Xor:
never executed: case QPainter::CompositionMode_Xor:
0
875 return QStringLiteral("xor");-
876 case QPainter::CompositionMode_Plus:
code before this statement never executed: case QPainter::CompositionMode_Plus:
never executed: case QPainter::CompositionMode_Plus:
0
877 return QStringLiteral("lighter");-
878 case QPainter::CompositionMode_Multiply:
code before this statement never executed: case QPainter::CompositionMode_Multiply:
never executed: case QPainter::CompositionMode_Multiply:
0
879 return QStringLiteral("qt-multiply");-
880 case QPainter::CompositionMode_Screen:
code before this statement never executed: case QPainter::CompositionMode_Screen:
never executed: case QPainter::CompositionMode_Screen:
0
881 return QStringLiteral("qt-screen");-
882 case QPainter::CompositionMode_Overlay:
code before this statement never executed: case QPainter::CompositionMode_Overlay:
never executed: case QPainter::CompositionMode_Overlay:
0
883 return QStringLiteral("qt-overlay");-
884 case QPainter::CompositionMode_Darken:
code before this statement never executed: case QPainter::CompositionMode_Darken:
never executed: case QPainter::CompositionMode_Darken:
0
885 return QStringLiteral("qt-darken");-
886 case QPainter::CompositionMode_Lighten:
code before this statement never executed: case QPainter::CompositionMode_Lighten:
never executed: case QPainter::CompositionMode_Lighten:
0
887 return QStringLiteral("lighter");-
888 case QPainter::CompositionMode_ColorDodge:
code before this statement never executed: case QPainter::CompositionMode_ColorDodge:
never executed: case QPainter::CompositionMode_ColorDodge:
0
889 return QStringLiteral("qt-color-dodge");-
890 case QPainter::CompositionMode_ColorBurn:
code before this statement never executed: case QPainter::CompositionMode_ColorBurn:
never executed: case QPainter::CompositionMode_ColorBurn:
0
891 return QStringLiteral("qt-color-burn");-
892 case QPainter::CompositionMode_HardLight:
code before this statement never executed: case QPainter::CompositionMode_HardLight:
never executed: case QPainter::CompositionMode_HardLight:
0
893 return QStringLiteral("qt-hard-light");-
894 case QPainter::CompositionMode_SoftLight:
code before this statement never executed: case QPainter::CompositionMode_SoftLight:
never executed: case QPainter::CompositionMode_SoftLight:
0
895 return QStringLiteral("qt-soft-light");-
896 case QPainter::CompositionMode_Difference:
code before this statement never executed: case QPainter::CompositionMode_Difference:
never executed: case QPainter::CompositionMode_Difference:
0
897 return QStringLiteral("qt-difference");-
898 case QPainter::CompositionMode_Exclusion:
code before this statement never executed: case QPainter::CompositionMode_Exclusion:
never executed: case QPainter::CompositionMode_Exclusion:
0
899 return QStringLiteral("qt-exclusion");-
900 default:
code before this statement never executed: default:
never executed: default:
0
901 break;
never executed: break;
0
902 }-
903 return QString();
never executed: return QString();
0
904}-
905-
906struct QQuickJSContext2DPixelData : public QV4::Object-
907{-
908 V4_OBJECT2(QQuickJSContext2DPixelData, QV4::Object)
never executed: end of block
never executed: end of block
never executed: return &static_vtbl;
never executed: return static_cast<QV4::Heap::QQuickJSContext2DPixelData *>(m());
never executed: return dptr;
0
909 V4_NEEDS_DESTROY
never executed: end of block
0
910-
911 static QV4::ReturnedValue virtualGet(const QV4::Managed *m, QV4::PropertyKey id, const QV4::Value *receiver, bool *hasProperty);-
912 static bool virtualPut(QV4::Managed *m, QV4::PropertyKey id, const QV4::Value &value, Value *receiver);-
913-
914 static QV4::ReturnedValue proto_get_length(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
915};-
916-
917void QV4::Heap::QQuickJSContext2DPixelData::init()-
918{-
919 Object::init();-
920 image = new QImage;-
921 QV4::Scope scope(internalClass->engine);-
922 QV4::ScopedObject o(scope, this);-
923 o->setArrayType(QV4::Heap::ArrayData::Custom);-
924}
never executed: end of block
0
925-
926DEFINE_OBJECT_VTABLE(QQuickJSContext2DPixelData);-
927-
928struct QQuickJSContext2DImageData : public QV4::Object-
929{-
930 V4_OBJECT2(QQuickJSContext2DImageData, QV4::Object)
never executed: end of block
never executed: end of block
never executed: return &static_vtbl;
never executed: return static_cast<QV4::Heap::QQuickJSContext2DImageData *>(m());
never executed: return dptr;
0
931-
932 static QV4::ReturnedValue method_get_width(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
933 static QV4::ReturnedValue method_get_height(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
934 static QV4::ReturnedValue method_get_data(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);-
935-
936};-
937-
938void QV4::Heap::QQuickJSContext2DImageData::init()-
939{-
940 Object::init();-
941 pixelData = QV4::Primitive::undefinedValue();-
942-
943 QV4::Scope scope(internalClass->engine);-
944 QV4::ScopedObject o(scope, this);-
945-
946 o->defineAccessorProperty(QStringLiteral("width"), ::QQuickJSContext2DImageData::method_get_width, nullptr);
never executed: return qstring_literal_temp;
0
947 o->defineAccessorProperty(QStringLiteral("height"), ::QQuickJSContext2DImageData::method_get_height, nullptr);
never executed: return qstring_literal_temp;
0
948 o->defineAccessorProperty(QStringLiteral("data"), ::QQuickJSContext2DImageData::method_get_data, nullptr);
never executed: return qstring_literal_temp;
0
949}
never executed: end of block
0
950-
951DEFINE_OBJECT_VTABLE(QQuickJSContext2DImageData);-
952-
953static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV4::ExecutionEngine *v4, const QImage& image)-
954{-
955 QV4::Scope scope(v4);-
956 QQuickContext2DEngineData *ed = engineData(scope.engine);-
957 QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, scope.engine->memoryManager->allocate<QQuickJSContext2DPixelData>());-
958 QV4::ScopedObject p(scope, ed->pixelArrayProto.value());-
959 pixelData->setPrototypeOf(p);-
960-
961 if (image.isNull()) {
image.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
962 *pixelData->d()->image = QImage(w, h, QImage::Format_ARGB32);-
963 pixelData->d()->image->fill(0x00000000);-
964 } else {
never executed: end of block
0
965 Q_ASSERT(image.width()== qRound(w * image.devicePixelRatio()) && image.height() == qRound(h * image.devicePixelRatio()));-
966 *pixelData->d()->image = image.format() == QImage::Format_ARGB32 ? image : image.convertToFormat(QImage::Format_ARGB32);
image.format()...:Format_ARGB32Description
TRUEnever evaluated
FALSEnever evaluated
0
967 }
never executed: end of block
0
968-
969 QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, scope.engine->memoryManager->allocate<QQuickJSContext2DImageData>());-
970 imageData->d()->pixelData = pixelData.asReturnedValue();-
971 return imageData.asReturnedValue();
never executed: return imageData.asReturnedValue();
0
972}-
973-
974//static script functions-
975-
976/*!-
977 \qmlproperty QtQuick::Canvas QtQuick::Context2D::canvas-
978 Holds the canvas item that the context paints on.-
979-
980 This property is read only.-
981*/-
982QV4::ReturnedValue QQuickJSContext2DPrototype::method_get_canvas(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
983{-
984 QV4::Scope scope(b);-
985 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
986 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
987-
988 RETURN_RESULT(QV4::QObjectWrapper::wrap(scope.engine, r->d()->context->canvas()));
never executed: return QV4::Encode(QV4::QObjectWrapper::wrap(scope.engine, r->d()->context->canvas()));
0
989}-
990-
991/*!-
992 \qmlmethod object QtQuick::Context2D::restore()-
993 Pops the top state on the stack, restoring the context to that state.-
994-
995 \sa save()-
996*/-
997QV4::ReturnedValue QQuickJSContext2DPrototype::method_restore(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
998{-
999 QV4::Scope scope(b);-
1000 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1001 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1002-
1003 r->d()->context->popState();-
1004 RETURN_RESULT(thisObject->asReturnedValue());
never executed: return QV4::Encode(thisObject->asReturnedValue());
0
1005}-
1006-
1007/*!-
1008 \qmlmethod object QtQuick::Context2D::reset()-
1009 Resets the context state and properties to the default values.-
1010*/-
1011QV4::ReturnedValue QQuickJSContext2DPrototype::method_reset(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1012{-
1013 QV4::Scope scope(b);-
1014 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1015 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1016-
1017 r->d()->context->reset();-
1018-
1019 RETURN_RESULT(thisObject->asReturnedValue());
never executed: return QV4::Encode(thisObject->asReturnedValue());
0
1020}-
1021-
1022/*!-
1023 \qmlmethod object QtQuick::Context2D::save()-
1024 Pushes the current state onto the state stack.-
1025-
1026 Before changing any state attributes, you should save the current state-
1027 for future reference. The context maintains a stack of drawing states.-
1028 Each state consists of the current transformation matrix, clipping region,-
1029 and values of the following attributes:-
1030 \list-
1031 \li strokeStyle-
1032 \li fillStyle-
1033 \li fillRule-
1034 \li globalAlpha-
1035 \li lineWidth-
1036 \li lineCap-
1037 \li lineJoin-
1038 \li miterLimit-
1039 \li shadowOffsetX-
1040 \li shadowOffsetY-
1041 \li shadowBlur-
1042 \li shadowColor-
1043 \li globalCompositeOperation-
1044 \li \l font-
1045 \li textAlign-
1046 \li textBaseline-
1047 \endlist-
1048-
1049 The current path is NOT part of the drawing state. The path can be reset by-
1050 invoking the beginPath() method.-
1051*/-
1052QV4::ReturnedValue QQuickJSContext2DPrototype::method_save(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1053{-
1054 QV4::Scope scope(b);-
1055 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1056 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1057-
1058 r->d()->context->pushState();-
1059-
1060 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
1061}-
1062-
1063// transformations-
1064/*!-
1065 \qmlmethod object QtQuick::Context2D::rotate(real angle)-
1066 Rotate the canvas around the current origin by \a angle in radians and clockwise direction.-
1067-
1068 \code-
1069 ctx.rotate(Math.PI/2);-
1070 \endcode-
1071-
1072 \image qml-item-canvas-rotate.png-
1073-
1074 The rotation transformation matrix is as follows:-
1075-
1076 \image qml-item-canvas-math-rotate.png-
1077-
1078 where the \a angle of rotation is in radians.-
1079-
1080*/-
1081QV4::ReturnedValue QQuickJSContext2DPrototype::method_rotate(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1082{-
1083 QV4::Scope scope(b);-
1084 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1085 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1086-
1087 if (argc >= 1)
argc >= 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1088 r->d()->context->rotate(argv[0].toNumber());
never executed: r->d()->context->rotate(argv[0].toNumber());
0
1089 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
1090}-
1091-
1092/*!-
1093 \qmlmethod object QtQuick::Context2D::scale(real x, real y)-
1094-
1095 Increases or decreases the size of each unit in the canvas grid by multiplying the scale factors-
1096 to the current tranform matrix.-
1097 \a x is the scale factor in the horizontal direction and \a y is the scale factor in the-
1098 vertical direction.-
1099-
1100 The following code doubles the horizontal size of an object drawn on the canvas and halves its-
1101 vertical size:-
1102-
1103 \code-
1104 ctx.scale(2.0, 0.5);-
1105 \endcode-
1106-
1107 \image qml-item-canvas-scale.png-
1108*/-
1109QV4::ReturnedValue QQuickJSContext2DPrototype::method_scale(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1110{-
1111 QV4::Scope scope(b);-
1112 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1113 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1114-
1115-
1116 if (argc >= 2)
argc >= 2Description
TRUEnever evaluated
FALSEnever evaluated
0
1117 r->d()->context->scale(argv[0].toNumber(), argv[1].toNumber());
never executed: r->d()->context->scale(argv[0].toNumber(), argv[1].toNumber());
0
1118 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
1119-
1120}-
1121-
1122/*!-
1123 \qmlmethod object QtQuick::Context2D::setTransform(real a, real b, real c, real d, real e, real f)-
1124 Changes the transformation matrix to the matrix given by the arguments as described below.-
1125-
1126 Modifying the transformation matrix directly enables you to perform scaling,-
1127 rotating, and translating transformations in a single step.-
1128-
1129 Each point on the canvas is multiplied by the matrix before anything is-
1130 drawn. The \l{http://www.w3.org/TR/2dcontext/#transformations}{HTML Canvas 2D Context specification}-
1131 defines the transformation matrix as:-
1132-
1133 \image qml-item-canvas-math.png-
1134 where:-
1135 \list-
1136 \li \c{a} is the scale factor in the horizontal (x) direction-
1137 \image qml-item-canvas-scalex.png-
1138 \li \c{c} is the skew factor in the x direction-
1139 \image qml-item-canvas-skewx.png-
1140 \li \c{e} is the translation in the x direction-
1141 \image qml-item-canvas-translate.png-
1142 \li \c{b} is the skew factor in the y (vertical) direction-
1143 \image qml-item-canvas-skewy.png-
1144 \li \c{d} is the scale factor in the y direction-
1145 \image qml-item-canvas-scaley.png-
1146 \li \c{f} is the translation in the y direction-
1147 \image qml-item-canvas-translatey.png-
1148 \li the last row remains constant-
1149 \endlist-
1150 The scale factors and skew factors are multiples; \c{e} and \c{f} are-
1151 coordinate space units, just like the units in the translate(x,y)-
1152 method.-
1153-
1154 \sa transform()-
1155*/-
1156QV4::ReturnedValue QQuickJSContext2DPrototype::method_setTransform(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1157{-
1158 QV4::Scope scope(b);-
1159 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1160 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1161-
1162-
1163 if (argc >= 6)
argc >= 6Description
TRUEnever evaluated
FALSEnever evaluated
0
1164 r->d()->context->setTransform( argv[0].toNumber()
never executed: r->d()->context->setTransform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1165 , argv[1].toNumber()
never executed: r->d()->context->setTransform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1166 , argv[2].toNumber()
never executed: r->d()->context->setTransform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1167 , argv[3].toNumber()
never executed: r->d()->context->setTransform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1168 , argv[4].toNumber()
never executed: r->d()->context->setTransform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1169 , argv[5].toNumber());
never executed: r->d()->context->setTransform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1170-
1171 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
1172-
1173}-
1174-
1175/*!-
1176 \qmlmethod object QtQuick::Context2D::transform(real a, real b, real c, real d, real e, real f)-
1177-
1178 This method is very similar to setTransform(), but instead of replacing the old-
1179 transform matrix, this method applies the given tranform matrix to the current matrix by multiplying to it.-
1180-
1181 The setTransform(a, b, c, d, e, f) method actually resets the current transform to the identity matrix,-
1182 and then invokes the transform(a, b, c, d, e, f) method with the same arguments.-
1183-
1184 \sa setTransform()-
1185*/-
1186QV4::ReturnedValue QQuickJSContext2DPrototype::method_transform(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1187{-
1188 QV4::Scope scope(b);-
1189 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1190 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1191-
1192 if (argc >= 6)
argc >= 6Description
TRUEnever evaluated
FALSEnever evaluated
0
1193 r->d()->context->transform( argv[0].toNumber()
never executed: r->d()->context->transform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1194 , argv[1].toNumber()
never executed: r->d()->context->transform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1195 , argv[2].toNumber()
never executed: r->d()->context->transform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1196 , argv[3].toNumber()
never executed: r->d()->context->transform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1197 , argv[4].toNumber()
never executed: r->d()->context->transform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1198 , argv[5].toNumber());
never executed: r->d()->context->transform( argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
1199-
1200 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
1201-
1202}-
1203-
1204/*!-
1205 \qmlmethod object QtQuick::Context2D::translate(real x, real y)-
1206-
1207 Translates the origin of the canvas by a horizontal distance of \a x,-
1208 and a vertical distance of \a y, in coordinate space units.-
1209-
1210 Translating the origin enables you to draw patterns of different objects on the canvas-
1211 without having to measure the coordinates manually for each shape.-
1212*/-
1213QV4::ReturnedValue QQuickJSContext2DPrototype::method_translate(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1214{-
1215 QV4::Scope scope(b);-
1216 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1217 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1218-
1219 if (argc >= 2)
argc >= 2Description
TRUEnever evaluated
FALSEnever evaluated
0
1220 r->d()->context->translate(argv[0].toNumber(), argv[1].toNumber());
never executed: r->d()->context->translate(argv[0].toNumber(), argv[1].toNumber());
0
1221 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
1222-
1223}-
1224-
1225-
1226/*!-
1227 \qmlmethod object QtQuick::Context2D::resetTransform()-
1228-
1229 Reset the transformation matrix to the default value (equivalent to calling-
1230 setTransform(\c 1, \c 0, \c 0, \c 1, \c 0, \c 0)).-
1231-
1232 \sa transform(), setTransform(), reset()-
1233*/-
1234QV4::ReturnedValue QQuickJSContext2DPrototype::method_resetTransform(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1235{-
1236 QV4::Scope scope(b);-
1237 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1238 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1239-
1240 r->d()->context->setTransform(1, 0, 0, 1, 0, 0);-
1241-
1242 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
1243-
1244}-
1245-
1246-
1247/*!-
1248 \qmlmethod object QtQuick::Context2D::shear(real sh, real sv)-
1249-
1250 Shears the transformation matrix by \a sh in the horizontal direction and-
1251 \a sv in the vertical direction.-
1252*/-
1253QV4::ReturnedValue QQuickJSContext2DPrototype::method_shear(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1254{-
1255 QV4::Scope scope(b);-
1256 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1257 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1258-
1259 if (argc >= 2)
argc >= 2Description
TRUEnever evaluated
FALSEnever evaluated
0
1260 r->d()->context->shear(argv[0].toNumber(), argv[1].toNumber());
never executed: r->d()->context->shear(argv[0].toNumber(), argv[1].toNumber());
0
1261-
1262 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
1263-
1264}-
1265// compositing-
1266-
1267/*!-
1268 \qmlproperty real QtQuick::Context2D::globalAlpha-
1269-
1270 Holds the current alpha value applied to rendering operations.-
1271 The value must be in the range from \c 0.0 (fully transparent) to \c 1.0 (fully opaque).-
1272 The default value is \c 1.0.-
1273*/-
1274QV4::ReturnedValue QQuickJSContext2D::method_get_globalAlpha(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1275{-
1276 QV4::Scope scope(b);-
1277 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1278 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1279-
1280 RETURN_RESULT(QV4::Encode(r->d()->context->state.globalAlpha));
never executed: return QV4::Encode(QV4::Encode(r->d()->context->state.globalAlpha));
0
1281}-
1282-
1283QV4::ReturnedValue QQuickJSContext2D::method_set_globalAlpha(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1284{-
1285 QV4::Scope scope(b);-
1286 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1287 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1288-
1289 double globalAlpha = argc ? argv[0].toNumber() : qt_qnan();
argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
1290-
1291-
1292 if (!qt_is_finite(globalAlpha))
!qt_is_finite(globalAlpha)Description
TRUEnever evaluated
FALSEnever evaluated
0
1293 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1294-
1295 if (globalAlpha >= 0.0 && globalAlpha <= 1.0 && r->d()->context->state.globalAlpha != globalAlpha) {
globalAlpha >= 0.0Description
TRUEnever evaluated
FALSEnever evaluated
globalAlpha <= 1.0Description
TRUEnever evaluated
FALSEnever evaluated
r->d()->contex...!= globalAlphaDescription
TRUEnever evaluated
FALSEnever evaluated
0
1296 r->d()->context->state.globalAlpha = globalAlpha;-
1297 r->d()->context->buffer()->setGlobalAlpha(r->d()->context->state.globalAlpha);-
1298 }
never executed: end of block
0
1299 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1300}-
1301-
1302/*!-
1303 \qmlproperty string QtQuick::Context2D::globalCompositeOperation-
1304 Holds the current the current composition operation, from the list below:-
1305 \list-
1306 \li source-atop - A atop B. Display the source image wherever both images are opaque.-
1307 Display the destination image wherever the destination image is opaque but the source image is transparent.-
1308 Display transparency elsewhere.-
1309 \li source-in - A in B. Display the source image wherever both the source image and destination image are opaque.-
1310 Display transparency elsewhere.-
1311 \li source-out - A out B. Display the source image wherever the source image is opaque and the destination image is transparent.-
1312 Display transparency elsewhere.-
1313 \li source-over - (default) A over B. Display the source image wherever the source image is opaque.-
1314 Display the destination image elsewhere.-
1315 \li destination-atop - B atop A. Same as source-atop but using the destination image instead of the source image and vice versa.-
1316 \li destination-in - B in A. Same as source-in but using the destination image instead of the source image and vice versa.-
1317 \li destination-out - B out A. Same as source-out but using the destination image instead of the source image and vice versa.-
1318 \li destination-over - B over A. Same as source-over but using the destination image instead of the source image and vice versa.-
1319 \li lighter - A plus B. Display the sum of the source image and destination image, with color values approaching 255 (100%) as a limit.-
1320 \li copy - A (B is ignored). Display the source image instead of the destination image.-
1321 \li xor - A xor B. Exclusive OR of the source image and destination image.-
1322 \endlist-
1323-
1324 Additionally, this property also accepts the compositon modes listed in QPainter::CompositionMode. According to the W3C standard, these-
1325 extension composition modes are provided as "vendorName-operationName" syntax, for example: QPainter::CompositionMode_Exclusion is provided as-
1326 "qt-exclusion".-
1327*/-
1328QV4::ReturnedValue QQuickJSContext2D::method_get_globalCompositeOperation(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1329{-
1330 QV4::Scope scope(b);-
1331 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1332 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1333-
1334 RETURN_RESULT(scope.engine->newString(qt_composite_mode_to_string(r->d()->context->state.globalCompositeOperation)));
never executed: return QV4::Encode(scope.engine->newString(qt_composite_mode_to_string(r->d()->context->state.globalCompositeOperation)));
0
1335}-
1336-
1337QV4::ReturnedValue QQuickJSContext2D::method_set_globalCompositeOperation(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1338{-
1339 QV4::Scope scope(b);-
1340 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1341 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1342-
1343 if (!argc)
!argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
1344 THROW_TYPE_ERROR();
never executed: return scope.engine->throwTypeError();
0
1345-
1346 QString mode = argv[0].toQString();-
1347 QPainter::CompositionMode cm = qt_composite_mode_from_string(mode);-
1348 if (cm == QPainter::CompositionMode_SourceOver && mode != QLatin1String("source-over"))
cm == QPainter...ode_SourceOverDescription
TRUEnever evaluated
FALSEnever evaluated
mode != QLatin..."source-over")Description
TRUEnever evaluated
FALSEnever evaluated
0
1349 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1350-
1351 if (cm != r->d()->context->state.globalCompositeOperation) {
cm != r->d()->...ositeOperationDescription
TRUEnever evaluated
FALSEnever evaluated
0
1352 r->d()->context->state.globalCompositeOperation = cm;-
1353 r->d()->context->buffer()->setGlobalCompositeOperation(cm);-
1354 }
never executed: end of block
0
1355-
1356 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1357}-
1358-
1359// colors and styles-
1360/*!-
1361 \qmlproperty variant QtQuick::Context2D::fillStyle-
1362 Holds the current style used for filling shapes.-
1363 The style can be either a string containing a CSS color, a CanvasGradient or CanvasPattern object. Invalid values are ignored.-
1364 This property accepts several color syntaxes:-
1365 \list-
1366 \li 'rgb(red, green, blue)' - for example: 'rgb(255, 100, 55)' or 'rgb(100%, 70%, 30%)'-
1367 \li 'rgba(red, green, blue, alpha)' - for example: 'rgb(255, 100, 55, 1.0)' or 'rgb(100%, 70%, 30%, 0.5)'-
1368 \li 'hsl(hue, saturation, lightness)'-
1369 \li 'hsla(hue, saturation, lightness, alpha)'-
1370 \li '#RRGGBB' - for example: '#00FFCC'-
1371 \li Qt.rgba(red, green, blue, alpha) - for example: Qt.rgba(0.3, 0.7, 1, 1.0)-
1372 \endlist-
1373 If the \c fillStyle or \l strokeStyle is assigned many times in a loop, the last Qt.rgba() syntax should be chosen, as it has the-
1374 best performance, because it's already a valid QColor value, does not need to be parsed everytime.-
1375-
1376 The default value is '#000000'.-
1377 \sa createLinearGradient()-
1378 \sa createRadialGradient()-
1379 \sa createPattern()-
1380 \sa strokeStyle-
1381 */-
1382QV4::ReturnedValue QQuickJSContext2D::method_get_fillStyle(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1383{-
1384 QV4::Scope scope(b);-
1385 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1386 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1387-
1388 QColor color = r->d()->context->state.fillStyle.color();-
1389 if (color.isValid()) {
color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1390 if (color.alpha() == 255)
color.alpha() == 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1391 RETURN_RESULT(scope.engine->newString(color.name()));
never executed: return QV4::Encode(scope.engine->newString(color.name()));
0
1392 QString alphaString = QString::number(color.alphaF(), 'f');-
1393 while (alphaString.endsWith(QLatin1Char('0')))
alphaString.en...tin1Char('0'))Description
TRUEnever evaluated
FALSEnever evaluated
0
1394 alphaString.chop(1);
never executed: alphaString.chop(1);
0
1395 if (alphaString.endsWith(QLatin1Char('.')))
alphaString.en...tin1Char('.'))Description
TRUEnever evaluated
FALSEnever evaluated
0
1396 alphaString += QLatin1Char('0');
never executed: alphaString += QLatin1Char('0');
0
1397 QString str = QString::fromLatin1("rgba(%1, %2, %3, %4)").arg(color.red()).arg(color.green()).arg(color.blue()).arg(alphaString);-
1398 RETURN_RESULT(scope.engine->newString(str));
never executed: return QV4::Encode(scope.engine->newString(str));
0
1399 }-
1400 RETURN_RESULT(r->d()->context->m_fillStyle.value());
never executed: return QV4::Encode(r->d()->context->m_fillStyle.value());
0
1401}-
1402-
1403QV4::ReturnedValue QQuickJSContext2D::method_set_fillStyle(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1404{-
1405 QV4::Scope scope(b);-
1406 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1407 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1408-
1409 QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Primitive::undefinedValue());-
1410-
1411 if (value->as<Object>()) {
value->as<Object>()Description
TRUEnever evaluated
FALSEnever evaluated
0
1412 QColor color = scope.engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();-
1413 if (color.isValid()) {
color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1414 r->d()->context->state.fillStyle = color;-
1415 r->d()->context->buffer()->setFillStyle(color);-
1416 r->d()->context->m_fillStyle.set(scope.engine, value);-
1417 } else {
never executed: end of block
0
1418 QV4::Scoped<QQuickContext2DStyle> style(scope, value->as<QQuickContext2DStyle>());-
1419 if (style && *style->d()->brush != r->d()->context->state.fillStyle) {
styleDescription
TRUEnever evaluated
FALSEnever evaluated
*style->d()->b...tate.fillStyleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1420 r->d()->context->state.fillStyle = *style->d()->brush;-
1421 r->d()->context->buffer()->setFillStyle(*style->d()->brush, style->d()->patternRepeatX, style->d()->patternRepeatY);-
1422 r->d()->context->m_fillStyle.set(scope.engine, value);-
1423 r->d()->context->state.fillPatternRepeatX = style->d()->patternRepeatX;-
1424 r->d()->context->state.fillPatternRepeatY = style->d()->patternRepeatY;-
1425 }
never executed: end of block
0
1426 }
never executed: end of block
0
1427 } else if (value->isString()) {
value->isString()Description
TRUEnever evaluated
FALSEnever evaluated
0
1428 QColor color = qt_color_from_string(value);-
1429 if (color.isValid() && r->d()->context->state.fillStyle != QBrush(color)) {
color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
r->d()->contex... QBrush(color)Description
TRUEnever evaluated
FALSEnever evaluated
0
1430 r->d()->context->state.fillStyle = QBrush(color);-
1431 r->d()->context->buffer()->setFillStyle(r->d()->context->state.fillStyle);-
1432 r->d()->context->m_fillStyle.set(scope.engine, value);-
1433 }
never executed: end of block
0
1434 }
never executed: end of block
0
1435 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1436}-
1437/*!-
1438 \qmlproperty enumeration QtQuick::Context2D::fillRule-
1439 Holds the current fill rule used for filling shapes. The following fill rules supported:-
1440 \list-
1441 \li Qt.OddEvenFill-
1442 \li Qt.WindingFill-
1443 \endlist-
1444 Note: Unlike the QPainterPath, the Canvas API uses the winding fill as the default fill rule.-
1445 The fillRule property is part of the context rendering state.-
1446-
1447 \sa fillStyle-
1448 */-
1449QV4::ReturnedValue QQuickJSContext2D::method_get_fillRule(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1450{-
1451 QV4::Scope scope(b);-
1452 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1453 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1454-
1455 RETURN_RESULT(scope.engine->fromVariant(r->d()->context->state.fillRule));
never executed: return QV4::Encode(scope.engine->fromVariant(r->d()->context->state.fillRule));
0
1456}-
1457-
1458QV4::ReturnedValue QQuickJSContext2D::method_set_fillRule(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1459{-
1460 QV4::Scope scope(b);-
1461 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1462 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1463-
1464 QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Primitive::undefinedValue());-
1465-
1466 if ((value->isString() && value->toQString() == QLatin1String("WindingFill"))
value->isString()Description
TRUEnever evaluated
FALSEnever evaluated
value->toQStri..."WindingFill")Description
TRUEnever evaluated
FALSEnever evaluated
0
1467 || (value->isInt32() && value->integerValue() == Qt::WindingFill)) {
value->isInt32()Description
TRUEnever evaluated
FALSEnever evaluated
value->integer...t::WindingFillDescription
TRUEnever evaluated
FALSEnever evaluated
0
1468 r->d()->context->state.fillRule = Qt::WindingFill;-
1469 } else if ((value->isString() && value->toQStringNoThrow() == QLatin1String("OddEvenFill"))
never executed: end of block
value->isString()Description
TRUEnever evaluated
FALSEnever evaluated
value->toQStri..."OddEvenFill")Description
TRUEnever evaluated
FALSEnever evaluated
0
1470 || (value->isInt32() && value->integerValue() == Qt::OddEvenFill)) {
value->isInt32()Description
TRUEnever evaluated
FALSEnever evaluated
value->integer...t::OddEvenFillDescription
TRUEnever evaluated
FALSEnever evaluated
0
1471 r->d()->context->state.fillRule = Qt::OddEvenFill;-
1472 } else {
never executed: end of block
0
1473 //error-
1474 }
never executed: end of block
0
1475 r->d()->context->m_path.setFillRule(r->d()->context->state.fillRule);-
1476 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1477}-
1478/*!-
1479 \qmlproperty variant QtQuick::Context2D::strokeStyle-
1480 Holds the current color or style to use for the lines around shapes,-
1481 The style can be either a string containing a CSS color, a CanvasGradient or CanvasPattern object.-
1482 Invalid values are ignored.-
1483-
1484 The default value is '#000000'.-
1485-
1486 \sa createLinearGradient()-
1487 \sa createRadialGradient()-
1488 \sa createPattern()-
1489 \sa fillStyle-
1490 */-
1491QV4::ReturnedValue QQuickJSContext2D::method_get_strokeStyle(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1492{-
1493 QV4::Scope scope(b);-
1494 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1495 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1496-
1497 QColor color = r->d()->context->state.strokeStyle.color();-
1498 if (color.isValid()) {
color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1499 if (color.alpha() == 255)
color.alpha() == 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1500 RETURN_RESULT(scope.engine->newString(color.name()));
never executed: return QV4::Encode(scope.engine->newString(color.name()));
0
1501 QString alphaString = QString::number(color.alphaF(), 'f');-
1502 while (alphaString.endsWith(QLatin1Char('0')))
alphaString.en...tin1Char('0'))Description
TRUEnever evaluated
FALSEnever evaluated
0
1503 alphaString.chop(1);
never executed: alphaString.chop(1);
0
1504 if (alphaString.endsWith(QLatin1Char('.')))
alphaString.en...tin1Char('.'))Description
TRUEnever evaluated
FALSEnever evaluated
0
1505 alphaString += QLatin1Char('0');
never executed: alphaString += QLatin1Char('0');
0
1506 QString str = QString::fromLatin1("rgba(%1, %2, %3, %4)").arg(color.red()).arg(color.green()).arg(color.blue()).arg(alphaString);-
1507 RETURN_RESULT(scope.engine->newString(str));
never executed: return QV4::Encode(scope.engine->newString(str));
0
1508 }-
1509 RETURN_RESULT(r->d()->context->m_strokeStyle.value());
never executed: return QV4::Encode(r->d()->context->m_strokeStyle.value());
0
1510}-
1511-
1512QV4::ReturnedValue QQuickJSContext2D::method_set_strokeStyle(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1513{-
1514 QV4::Scope scope(b);-
1515 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1516 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1517-
1518 QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Primitive::undefinedValue());-
1519-
1520 if (value->as<Object>()) {
value->as<Object>()Description
TRUEnever evaluated
FALSEnever evaluated
0
1521 QColor color = scope.engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();-
1522 if (color.isValid()) {
color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1523 r->d()->context->state.fillStyle = color;-
1524 r->d()->context->buffer()->setStrokeStyle(color);-
1525 r->d()->context->m_strokeStyle.set(scope.engine, value);-
1526 } else {
never executed: end of block
0
1527 QV4::Scoped<QQuickContext2DStyle> style(scope, value->as<QQuickContext2DStyle>());-
1528 if (style && *style->d()->brush != r->d()->context->state.strokeStyle) {
styleDescription
TRUEnever evaluated
FALSEnever evaluated
*style->d()->b...te.strokeStyleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1529 r->d()->context->state.strokeStyle = *style->d()->brush;-
1530 r->d()->context->buffer()->setStrokeStyle(*style->d()->brush, style->d()->patternRepeatX, style->d()->patternRepeatY);-
1531 r->d()->context->m_strokeStyle.set(scope.engine, value);-
1532 r->d()->context->state.strokePatternRepeatX = style->d()->patternRepeatX;-
1533 r->d()->context->state.strokePatternRepeatY = style->d()->patternRepeatY;-
1534-
1535 }
never executed: end of block
0
1536 }
never executed: end of block
0
1537 } else if (value->isString()) {
value->isString()Description
TRUEnever evaluated
FALSEnever evaluated
0
1538 QColor color = qt_color_from_string(value);-
1539 if (color.isValid() && r->d()->context->state.strokeStyle != QBrush(color)) {
color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
r->d()->contex... QBrush(color)Description
TRUEnever evaluated
FALSEnever evaluated
0
1540 r->d()->context->state.strokeStyle = QBrush(color);-
1541 r->d()->context->buffer()->setStrokeStyle(r->d()->context->state.strokeStyle);-
1542 r->d()->context->m_strokeStyle.set(scope.engine, value);-
1543 }
never executed: end of block
0
1544 }
never executed: end of block
0
1545 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1546}-
1547-
1548/*!-
1549 \qmlmethod object QtQuick::Context2D::createLinearGradient(real x0, real y0, real x1, real y1)-
1550 Returns a CanvasGradient object that represents a linear gradient that transitions the color along a line between-
1551 the start point (\a x0, \a y0) and the end point (\a x1, \a y1).-
1552-
1553 A gradient is a smooth transition between colors. There are two types of gradients: linear and radial.-
1554 Gradients must have two or more color stops, representing color shifts positioned from 0 to 1 between-
1555 to the gradient's starting and end points or circles.-
1556-
1557 \sa CanvasGradient::addColorStop()-
1558 \sa createRadialGradient()-
1559 \sa createConicalGradient()-
1560 \sa createPattern()-
1561 \sa fillStyle-
1562 \sa strokeStyle-
1563 */-
1564-
1565QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1566{-
1567 QV4::Scope scope(b);-
1568 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1569 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1570-
1571 if (argc >= 4) {
argc >= 4Description
TRUEnever evaluated
FALSEnever evaluated
0
1572 qreal x0 = argv[0].toNumber();-
1573 qreal y0 = argv[1].toNumber();-
1574 qreal x1 = argv[2].toNumber();-
1575 qreal y1 = argv[3].toNumber();-
1576-
1577 if (!qt_is_finite(x0)
!qt_is_finite(x0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1578 || !qt_is_finite(y0)
!qt_is_finite(y0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1579 || !qt_is_finite(x1)
!qt_is_finite(x1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1580 || !qt_is_finite(y1)) {
!qt_is_finite(y1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1581 THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createLinearGradient(): Incorrect arguments")
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
1582 }-
1583 QQuickContext2DEngineData *ed = engineData(scope.engine);-
1584-
1585 QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->allocate<QQuickContext2DStyle>());-
1586 QV4::ScopedObject p(scope, ed->gradientProto.value());-
1587 gradient->setPrototypeOf(p);-
1588 *gradient->d()->brush = QLinearGradient(x0, y0, x1, y1);-
1589 RETURN_RESULT(*gradient);
never executed: return QV4::Encode(*gradient);
0
1590 }-
1591-
1592 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
1593-
1594}-
1595-
1596/*!-
1597 \qmlmethod object QtQuick::Context2D::createRadialGradient(real x0, real y0, real r0, real x1, real y1, real r1)-
1598 Returns a CanvasGradient object that represents a radial gradient that paints along the cone given by the start circle with-
1599 origin (x0, y0) and radius r0, and the end circle with origin (x1, y1) and radius r1.-
1600-
1601 \sa CanvasGradient::addColorStop()-
1602 \sa createLinearGradient()-
1603 \sa createConicalGradient()-
1604 \sa createPattern()-
1605 \sa fillStyle-
1606 \sa strokeStyle-
1607 */-
1608-
1609QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1610{-
1611 QV4::Scope scope(b);-
1612 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1613 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1614-
1615 if (argc >= 6) {
argc >= 6Description
TRUEnever evaluated
FALSEnever evaluated
0
1616 qreal x0 = argv[0].toNumber();-
1617 qreal y0 = argv[1].toNumber();-
1618 qreal r0 = argv[2].toNumber();-
1619 qreal x1 = argv[3].toNumber();-
1620 qreal y1 = argv[4].toNumber();-
1621 qreal r1 = argv[5].toNumber();-
1622-
1623 if (!qt_is_finite(x0)
!qt_is_finite(x0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1624 || !qt_is_finite(y0)
!qt_is_finite(y0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1625 || !qt_is_finite(x1)
!qt_is_finite(x1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1626 || !qt_is_finite(r0)
!qt_is_finite(r0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1627 || !qt_is_finite(r1)
!qt_is_finite(r1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1628 || !qt_is_finite(y1)) {
!qt_is_finite(y1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1629 THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createRadialGradient(): Incorrect arguments")
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
1630 }-
1631-
1632 if (r0 < 0 || r1 < 0)
r0 < 0Description
TRUEnever evaluated
FALSEnever evaluated
r1 < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1633 THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createRadialGradient(): Incorrect arguments")
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
1634-
1635 QQuickContext2DEngineData *ed = engineData(scope.engine);-
1636-
1637 QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->allocate<QQuickContext2DStyle>());-
1638 QV4::ScopedObject p(scope, ed->gradientProto.value());-
1639 gradient->setPrototypeOf(p);-
1640 *gradient->d()->brush = QRadialGradient(QPointF(x1, y1), r1, QPointF(x0, y0), r0);-
1641 RETURN_RESULT(*gradient);
never executed: return QV4::Encode(*gradient);
0
1642 }-
1643-
1644 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
1645-
1646}-
1647-
1648/*!-
1649 \qmlmethod object QtQuick::Context2D::createConicalGradient(real x, real y, real angle)-
1650 Returns a CanvasGradient object that represents a conical gradient that interpolate colors counter-clockwise around a center point (\c x, \c y)-
1651 with start angle \c angle in units of radians.-
1652-
1653 \sa CanvasGradient::addColorStop()-
1654 \sa createLinearGradient()-
1655 \sa createRadialGradient()-
1656 \sa createPattern()-
1657 \sa fillStyle-
1658 \sa strokeStyle-
1659 */-
1660-
1661QV4::ReturnedValue QQuickJSContext2DPrototype::method_createConicalGradient(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1662{-
1663 QV4::Scope scope(b);-
1664 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
1665 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1666-
1667 if (argc >= 3) {
argc >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
1668 qreal x = argv[0].toNumber();-
1669 qreal y = argv[1].toNumber();-
1670 qreal angle = qRadiansToDegrees(argv[2].toNumber());-
1671 if (!qt_is_finite(x) || !qt_is_finite(y)) {
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
1672 THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createConicalGradient(): Incorrect arguments");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
1673 }-
1674-
1675 if (!qt_is_finite(angle)) {
!qt_is_finite(angle)Description
TRUEnever evaluated
FALSEnever evaluated
0
1676 THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createConicalGradient(): Incorrect arguments");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
1677 }-
1678-
1679 QQuickContext2DEngineData *ed = engineData(scope.engine);-
1680-
1681 QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->allocate<QQuickContext2DStyle>());-
1682 QV4::ScopedObject p(scope, ed->gradientProto.value());-
1683 gradient->setPrototypeOf(p);-
1684 *gradient->d()->brush = QConicalGradient(x, y, angle);-
1685 RETURN_RESULT(*gradient);
never executed: return QV4::Encode(*gradient);
0
1686 }-
1687-
1688 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
1689-
1690}-
1691/*!-
1692 \qmlmethod variant QtQuick::Context2D::createPattern(color color, enumeration patternMode)-
1693 This is a overload function.-
1694 Returns a CanvasPattern object that uses the given \a color and \a patternMode.-
1695 The valid pattern modes are:-
1696 \list-
1697 \li Qt.SolidPattern-
1698 \li Qt.Dense1Pattern-
1699 \li Qt.Dense2Pattern-
1700 \li Qt.Dense3Pattern-
1701 \li Qt.Dense4Pattern-
1702 \li Qt.Dense5Pattern-
1703 \li Qt.Dense6Pattern-
1704 \li Qt.Dense7Pattern-
1705 \li Qt.HorPattern-
1706 \li Qt.VerPattern-
1707 \li Qt.CrossPattern-
1708 \li Qt.BDiagPattern-
1709 \li Qt.FDiagPattern-
1710 \li Qt.DiagCrossPattern-
1711\endlist-
1712 \sa Qt::BrushStyle-
1713 */-
1714/*!-
1715 \qmlmethod variant QtQuick::Context2D::createPattern(Image image, string repetition)-
1716 Returns a CanvasPattern object that uses the given image and repeats in the direction(s) given by the repetition argument.-
1717-
1718 The \a image parameter must be a valid Image item, a valid CanvasImageData object or loaded image url, if there is no image data, throws an INVALID_STATE_ERR exception.-
1719-
1720 The allowed values for \a repetition are:-
1721-
1722 \list-
1723 \li "repeat" - both directions-
1724 \li "repeat-x - horizontal only-
1725 \li "repeat-y" - vertical only-
1726 \li "no-repeat" - neither-
1727 \endlist-
1728-
1729 If the repetition argument is empty or null, the value "repeat" is used.-
1730-
1731 \sa strokeStyle-
1732 \sa fillStyle-
1733 */-
1734QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1735{-
1736 QV4::Scope scope(b);-
1737 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
1738 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1739-
1740 if (argc >= 2) {
argc >= 2Description
TRUEnever evaluated
FALSEnever evaluated
0
1741 QV4::Scoped<QQuickContext2DStyle> pattern(scope, scope.engine->memoryManager->allocate<QQuickContext2DStyle>());-
1742-
1743 QColor color = scope.engine->toVariant(argv[0], qMetaTypeId<QColor>()).value<QColor>();-
1744 if (color.isValid()) {
color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1745 int patternMode = argv[1].toInt32();-
1746 Qt::BrushStyle style = Qt::SolidPattern;-
1747 if (patternMode >= 0 && patternMode < Qt::LinearGradientPattern) {
patternMode >= 0Description
TRUEnever evaluated
FALSEnever evaluated
patternMode < ...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
1748 style = static_cast<Qt::BrushStyle>(patternMode);-
1749 }
never executed: end of block
0
1750 *pattern->d()->brush = QBrush(color, style);-
1751 } else {
never executed: end of block
0
1752 QImage patternTexture;-
1753-
1754 if (const QV4::Object *o = argv[0].as<Object>()) {
const QV4::Obj...].as<Object>()Description
TRUEnever evaluated
FALSEnever evaluated
0
1755 QV4::ScopedString s(scope, scope.engine->newString(QStringLiteral("data")));
never executed: return qstring_literal_temp;
0
1756 QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, o->get(s));-
1757 if (!!pixelData) {
!!pixelDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1758 patternTexture = *pixelData->d()->image;-
1759 }
never executed: end of block
0
1760 } else {
never executed: end of block
0
1761 patternTexture = r->d()->context->createPixmap(QUrl(argv[0].toQStringNoThrow()))->image();-
1762 }
never executed: end of block
0
1763-
1764 if (!patternTexture.isNull()) {
!patternTexture.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1765 pattern->d()->brush->setTextureImage(patternTexture);-
1766-
1767 QString repetition = argv[1].toQStringNoThrow();-
1768 if (repetition == QLatin1String("repeat") || repetition.isEmpty()) {
repetition == ...ring("repeat")Description
TRUEnever evaluated
FALSEnever evaluated
repetition.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1769 pattern->d()->patternRepeatX = true;-
1770 pattern->d()->patternRepeatY = true;-
1771 } else if (repetition == QLatin1String("repeat-x")) {
never executed: end of block
repetition == ...ng("repeat-x")Description
TRUEnever evaluated
FALSEnever evaluated
0
1772 pattern->d()->patternRepeatX = true;-
1773 pattern->d()->patternRepeatY = false;-
1774 } else if (repetition == QLatin1String("repeat-y")) {
never executed: end of block
repetition == ...ng("repeat-y")Description
TRUEnever evaluated
FALSEnever evaluated
0
1775 pattern->d()->patternRepeatX = false;-
1776 pattern->d()->patternRepeatY = true;-
1777 } else if (repetition == QLatin1String("no-repeat")) {
never executed: end of block
repetition == ...g("no-repeat")Description
TRUEnever evaluated
FALSEnever evaluated
0
1778 pattern->d()->patternRepeatX = false;-
1779 pattern->d()->patternRepeatY = false;-
1780 } else {
never executed: end of block
0
1781 //TODO: exception: SYNTAX_ERR-
1782 }
never executed: end of block
0
1783-
1784 }-
1785 }
never executed: end of block
0
1786-
1787 RETURN_RESULT(*pattern);
never executed: return QV4::Encode(*pattern);
0
1788-
1789 }-
1790 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1791}-
1792-
1793// line styles-
1794/*!-
1795 \qmlproperty string QtQuick::Context2D::lineCap-
1796 Holds the current line cap style.-
1797 The possible line cap styles are:-
1798 \list-
1799 \li butt - the end of each line has a flat edge perpendicular to the direction of the line, this is the default line cap value.-
1800 \li round - a semi-circle with the diameter equal to the width of the line must then be added on to the end of the line.-
1801 \li square - a rectangle with the length of the line width and the width of half the line width, placed flat against the edge perpendicular to the direction of the line.-
1802 \endlist-
1803 Other values are ignored.-
1804*/-
1805QV4::ReturnedValue QQuickJSContext2D::method_get_lineCap(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1806{-
1807 QV4::Scope scope(b);-
1808 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
1809 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1810-
1811 switch (r->d()->context->state.lineCap) {-
1812 case Qt::RoundCap:
never executed: case Qt::RoundCap:
0
1813 RETURN_RESULT(scope.engine->newString(QStringLiteral("round")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "round")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "round" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
1814 case Qt::SquareCap:
never executed: case Qt::SquareCap:
0
1815 RETURN_RESULT(scope.engine->newString(QStringLiteral("square")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "square")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "square" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
1816 case Qt::FlatCap:
never executed: case Qt::FlatCap:
0
1817 default:
never executed: default:
0
1818 break;
never executed: break;
0
1819 }-
1820 RETURN_RESULT(scope.engine->newString(QStringLiteral("butt")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "butt")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "butt" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
1821}-
1822-
1823QV4::ReturnedValue QQuickJSContext2D::method_set_lineCap(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1824{-
1825 if (!argc)
!argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
1826 return QV4::Encode::undefined();
never executed: return QV4::Encode::undefined();
0
1827-
1828 QV4::Scope scope(b);-
1829 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
1830 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1831-
1832 QString lineCap = argv[0].toQString();-
1833 Qt::PenCapStyle cap;-
1834 if (lineCap == QLatin1String("round"))
lineCap == QLa...tring("round")Description
TRUEnever evaluated
FALSEnever evaluated
0
1835 cap = Qt::RoundCap;
never executed: cap = Qt::RoundCap;
0
1836 else if (lineCap == QLatin1String("butt"))
lineCap == QLa...String("butt")Description
TRUEnever evaluated
FALSEnever evaluated
0
1837 cap = Qt::FlatCap;
never executed: cap = Qt::FlatCap;
0
1838 else if (lineCap == QLatin1String("square"))
lineCap == QLa...ring("square")Description
TRUEnever evaluated
FALSEnever evaluated
0
1839 cap = Qt::SquareCap;
never executed: cap = Qt::SquareCap;
0
1840 else-
1841 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1842-
1843 if (cap != r->d()->context->state.lineCap) {
cap != r->d()-...>state.lineCapDescription
TRUEnever evaluated
FALSEnever evaluated
0
1844 r->d()->context->state.lineCap = cap;-
1845 r->d()->context->buffer()->setLineCap(cap);-
1846 }
never executed: end of block
0
1847 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1848}-
1849-
1850/*!-
1851 \qmlproperty string QtQuick::Context2D::lineJoin-
1852 Holds the current line join style. A join exists at any point in a subpath-
1853 shared by two consecutive lines. When a subpath is closed, then a join also exists-
1854 at its first point (equivalent to its last point) connecting the first and last lines in the subpath.-
1855-
1856 The possible line join styles are:-
1857 \list-
1858 \li bevel - this is all that is rendered at joins.-
1859 \li round - a filled arc connecting the two aforementioned corners of the join, abutting (and not overlapping) the aforementioned triangle, with the diameter equal to the line width and the origin at the point of the join, must be rendered at joins.-
1860 \li miter - a second filled triangle must (if it can given the miter length) be rendered at the join, this is the default line join style.-
1861 \endlist-
1862 Other values are ignored.-
1863*/-
1864QV4::ReturnedValue QQuickJSContext2D::method_get_lineJoin(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1865{-
1866 QV4::Scope scope(b);-
1867 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
1868 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1869-
1870 switch (r->d()->context->state.lineJoin) {-
1871 case Qt::RoundJoin:
never executed: case Qt::RoundJoin:
0
1872 RETURN_RESULT(scope.engine->newString(QStringLiteral("round")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "round")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "round" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
1873 case Qt::BevelJoin:
never executed: case Qt::BevelJoin:
0
1874 RETURN_RESULT(scope.engine->newString(QStringLiteral("bevel")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "bevel")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "bevel" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
1875 case Qt::MiterJoin:
never executed: case Qt::MiterJoin:
0
1876 default:
never executed: default:
0
1877 break;
never executed: break;
0
1878 }-
1879 RETURN_RESULT(scope.engine->newString(QStringLiteral("miter")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "miter")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "miter" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
1880}-
1881-
1882QV4::ReturnedValue QQuickJSContext2D::method_set_lineJoin(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1883{-
1884 QV4::Scope scope(b);-
1885 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
1886 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1887-
1888 if (!argc)
!argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
1889 THROW_TYPE_ERROR();
never executed: return scope.engine->throwTypeError();
0
1890-
1891 QString lineJoin = argv[0].toQString();-
1892 Qt::PenJoinStyle join;-
1893 if (lineJoin == QLatin1String("round"))
lineJoin == QL...tring("round")Description
TRUEnever evaluated
FALSEnever evaluated
0
1894 join = Qt::RoundJoin;
never executed: join = Qt::RoundJoin;
0
1895 else if (lineJoin == QLatin1String("bevel"))
lineJoin == QL...tring("bevel")Description
TRUEnever evaluated
FALSEnever evaluated
0
1896 join = Qt::BevelJoin;
never executed: join = Qt::BevelJoin;
0
1897 else if (lineJoin == QLatin1String("miter"))
lineJoin == QL...tring("miter")Description
TRUEnever evaluated
FALSEnever evaluated
0
1898 join = Qt::SvgMiterJoin;
never executed: join = Qt::SvgMiterJoin;
0
1899 else-
1900 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1901-
1902 if (join != r->d()->context->state.lineJoin) {
join != r->d()...state.lineJoinDescription
TRUEnever evaluated
FALSEnever evaluated
0
1903 r->d()->context->state.lineJoin = join;-
1904 r->d()->context->buffer()->setLineJoin(join);-
1905 }
never executed: end of block
0
1906 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1907}-
1908-
1909/*!-
1910 \qmlproperty real QtQuick::Context2D::lineWidth-
1911 Holds the current line width. Values that are not finite values greater than zero are ignored.-
1912 */-
1913QV4::ReturnedValue QQuickJSContext2D::method_get_lineWidth(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1914{-
1915 QV4::Scope scope(b);-
1916 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
1917 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1918-
1919 RETURN_RESULT(QV4::Encode(r->d()->context->state.lineWidth));
never executed: return QV4::Encode(QV4::Encode(r->d()->context->state.lineWidth));
0
1920}-
1921-
1922QV4::ReturnedValue QQuickJSContext2D::method_set_lineWidth(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1923{-
1924 QV4::Scope scope(b);-
1925 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
1926 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1927-
1928 qreal w = argc ? argv[0].toNumber() : -1;
argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
1929-
1930 if (w > 0 && qt_is_finite(w) && w != r->d()->context->state.lineWidth) {
w > 0Description
TRUEnever evaluated
FALSEnever evaluated
qt_is_finite(w)Description
TRUEnever evaluated
FALSEnever evaluated
w != r->d()->c...tate.lineWidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1931 r->d()->context->state.lineWidth = w;-
1932 r->d()->context->buffer()->setLineWidth(w);-
1933 }
never executed: end of block
0
1934 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1935}-
1936-
1937/*!-
1938 \qmlproperty real QtQuick::Context2D::miterLimit-
1939 Holds the current miter limit ratio.-
1940 The default miter limit value is 10.0.-
1941 */-
1942QV4::ReturnedValue QQuickJSContext2D::method_get_miterLimit(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1943{-
1944 QV4::Scope scope(b);-
1945 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
1946 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1947-
1948 RETURN_RESULT(QV4::Encode(r->d()->context->state.miterLimit));
never executed: return QV4::Encode(QV4::Encode(r->d()->context->state.miterLimit));
0
1949}-
1950-
1951QV4::ReturnedValue QQuickJSContext2D::method_set_miterLimit(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1952{-
1953 QV4::Scope scope(b);-
1954 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
1955 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1956-
1957 qreal ml = argc ? argv[0].toNumber() : -1;
argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
1958-
1959 if (ml > 0 && qt_is_finite(ml) && ml != r->d()->context->state.miterLimit) {
ml > 0Description
TRUEnever evaluated
FALSEnever evaluated
qt_is_finite(ml)Description
TRUEnever evaluated
FALSEnever evaluated
ml != r->d()->...ate.miterLimitDescription
TRUEnever evaluated
FALSEnever evaluated
0
1960 r->d()->context->state.miterLimit = ml;-
1961 r->d()->context->buffer()->setMiterLimit(ml);-
1962 }
never executed: end of block
0
1963 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1964}-
1965-
1966// shadows-
1967/*!-
1968 \qmlproperty real QtQuick::Context2D::shadowBlur-
1969 Holds the current level of blur applied to shadows-
1970 */-
1971QV4::ReturnedValue QQuickJSContext2D::method_get_shadowBlur(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
1972{-
1973 QV4::Scope scope(b);-
1974 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
1975 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1976-
1977 RETURN_RESULT(QV4::Encode(r->d()->context->state.shadowBlur));
never executed: return QV4::Encode(QV4::Encode(r->d()->context->state.shadowBlur));
0
1978}-
1979-
1980QV4::ReturnedValue QQuickJSContext2D::method_set_shadowBlur(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
1981{-
1982 QV4::Scope scope(b);-
1983 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
1984 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1985-
1986 qreal blur = argc ? argv[0].toNumber() : -1;
argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
1987-
1988 if (blur > 0 && qt_is_finite(blur) && blur != r->d()->context->state.shadowBlur) {
blur > 0Description
TRUEnever evaluated
FALSEnever evaluated
qt_is_finite(blur)Description
TRUEnever evaluated
FALSEnever evaluated
blur != r->d()...ate.shadowBlurDescription
TRUEnever evaluated
FALSEnever evaluated
0
1989 r->d()->context->state.shadowBlur = blur;-
1990 r->d()->context->buffer()->setShadowBlur(blur);-
1991 }
never executed: end of block
0
1992 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
1993}-
1994-
1995/*!-
1996 \qmlproperty string QtQuick::Context2D::shadowColor-
1997 Holds the current shadow color.-
1998 */-
1999QV4::ReturnedValue QQuickJSContext2D::method_get_shadowColor(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2000{-
2001 QV4::Scope scope(b);-
2002 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2003 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2004-
2005 RETURN_RESULT(scope.engine->newString(r->d()->context->state.shadowColor.name()));
never executed: return QV4::Encode(scope.engine->newString(r->d()->context->state.shadowColor.name()));
0
2006}-
2007-
2008QV4::ReturnedValue QQuickJSContext2D::method_set_shadowColor(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2009{-
2010 QV4::Scope scope(b);-
2011 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2012 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2013-
2014 QColor color;-
2015 if (argc)
argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
2016 color = qt_color_from_string(argv[0]);
never executed: color = qt_color_from_string(argv[0]);
0
2017-
2018 if (color.isValid() && color != r->d()->context->state.shadowColor) {
color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
color != r->d(...te.shadowColorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2019 r->d()->context->state.shadowColor = color;-
2020 r->d()->context->buffer()->setShadowColor(color);-
2021 }
never executed: end of block
0
2022 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2023}-
2024-
2025-
2026/*!-
2027 \qmlproperty qreal QtQuick::Context2D::shadowOffsetX-
2028 Holds the current shadow offset in the positive horizontal distance.-
2029-
2030 \sa shadowOffsetY-
2031 */-
2032QV4::ReturnedValue QQuickJSContext2D::method_get_shadowOffsetX(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2033{-
2034 QV4::Scope scope(b);-
2035 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2036 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2037-
2038 RETURN_RESULT(QV4::Encode(r->d()->context->state.shadowOffsetX));
never executed: return QV4::Encode(QV4::Encode(r->d()->context->state.shadowOffsetX));
0
2039}-
2040-
2041QV4::ReturnedValue QQuickJSContext2D::method_set_shadowOffsetX(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2042{-
2043 QV4::Scope scope(b);-
2044 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2045 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2046-
2047 qreal offsetX = argc ? argv[0].toNumber() : qt_qnan();
argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
2048 if (qt_is_finite(offsetX) && offsetX != r->d()->context->state.shadowOffsetX) {
qt_is_finite(offsetX)Description
TRUEnever evaluated
FALSEnever evaluated
offsetX != r->....shadowOffsetXDescription
TRUEnever evaluated
FALSEnever evaluated
0
2049 r->d()->context->state.shadowOffsetX = offsetX;-
2050 r->d()->context->buffer()->setShadowOffsetX(offsetX);-
2051 }
never executed: end of block
0
2052 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2053}-
2054/*!-
2055 \qmlproperty qreal QtQuick::Context2D::shadowOffsetY-
2056 Holds the current shadow offset in the positive vertical distance.-
2057-
2058 \sa shadowOffsetX-
2059 */-
2060QV4::ReturnedValue QQuickJSContext2D::method_get_shadowOffsetY(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2061{-
2062 QV4::Scope scope(b);-
2063 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2064 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2065-
2066 RETURN_RESULT(QV4::Encode(r->d()->context->state.shadowOffsetY));
never executed: return QV4::Encode(QV4::Encode(r->d()->context->state.shadowOffsetY));
0
2067}-
2068-
2069QV4::ReturnedValue QQuickJSContext2D::method_set_shadowOffsetY(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2070{-
2071 QV4::Scope scope(b);-
2072 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2073 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2074-
2075 qreal offsetY = argc ? argv[0].toNumber() : qt_qnan();
argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
2076 if (qt_is_finite(offsetY) && offsetY != r->d()->context->state.shadowOffsetY) {
qt_is_finite(offsetY)Description
TRUEnever evaluated
FALSEnever evaluated
offsetY != r->....shadowOffsetYDescription
TRUEnever evaluated
FALSEnever evaluated
0
2077 r->d()->context->state.shadowOffsetY = offsetY;-
2078 r->d()->context->buffer()->setShadowOffsetY(offsetY);-
2079 }
never executed: end of block
0
2080 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2081}-
2082-
2083#if QT_CONFIG(quick_path)-
2084QV4::ReturnedValue QQuickJSContext2D::method_get_path(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2085{-
2086 QV4::Scope scope(b);-
2087 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2088 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2089-
2090 RETURN_RESULT(r->d()->context->m_v4path.value());
never executed: return QV4::Encode(r->d()->context->m_v4path.value());
0
2091}-
2092-
2093QV4::ReturnedValue QQuickJSContext2D::method_set_path(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2094{-
2095 QV4::Scope scope(b);-
2096 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2097 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2098-
2099 QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Primitive::undefinedValue());-
2100 r->d()->context->beginPath();-
2101 QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, value);-
2102 if (!!qobjectWrapper) {
!!qobjectWrapperDescription
TRUEnever evaluated
FALSEnever evaluated
0
2103 if (QQuickPath *path = qobject_cast<QQuickPath*>(qobjectWrapper->object()))
QQuickPath *pa...per->object())Description
TRUEnever evaluated
FALSEnever evaluated
0
2104 r->d()->context->m_path = path->path();
never executed: r->d()->context->m_path = path->path();
0
2105 } else {
never executed: end of block
0
2106 QString path =value->toQStringNoThrow();-
2107 QQuickSvgParser::parsePathDataFast(path, r->d()->context->m_path);-
2108 }
never executed: end of block
0
2109 r->d()->context->m_v4path.set(scope.engine, value);-
2110 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2111}-
2112#endif // QT_CONFIG(quick_path)-
2113-
2114//rects-
2115/*!-
2116 \qmlmethod object QtQuick::Context2D::clearRect(real x, real y, real w, real h)-
2117 Clears all pixels on the canvas in the given rectangle to transparent black.-
2118 */-
2119QV4::ReturnedValue QQuickJSContext2DPrototype::method_clearRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2120{-
2121 QV4::Scope scope(b);-
2122 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2123 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2124-
2125-
2126 if (argc >= 4)
argc >= 4Description
TRUEnever evaluated
FALSEnever evaluated
0
2127 r->d()->context->clearRect(argv[0].toNumber(),
never executed: r->d()->context->clearRect(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
0
2128 argv[1].toNumber(),
never executed: r->d()->context->clearRect(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
0
2129 argv[2].toNumber(),
never executed: r->d()->context->clearRect(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
0
2130 argv[3].toNumber());
never executed: r->d()->context->clearRect(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
0
2131-
2132 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2133-
2134}-
2135/*!-
2136 \qmlmethod object QtQuick::Context2D::fillRect(real x, real y, real w, real h)-
2137 Paint the specified rectangular area using the fillStyle.-
2138-
2139 \sa fillStyle-
2140 */-
2141QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2142{-
2143 QV4::Scope scope(b);-
2144 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2145 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2146-
2147 if (argc >= 4)
argc >= 4Description
TRUEnever evaluated
FALSEnever evaluated
0
2148 r->d()->context->fillRect(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
never executed: r->d()->context->fillRect(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
0
2149 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2150-
2151}-
2152-
2153/*!-
2154 \qmlmethod object QtQuick::Context2D::strokeRect(real x, real y, real w, real h)-
2155 Stroke the specified rectangle's path using the strokeStyle, lineWidth, lineJoin,-
2156 and (if appropriate) miterLimit attributes.-
2157-
2158 \sa strokeStyle-
2159 \sa lineWidth-
2160 \sa lineJoin-
2161 \sa miterLimit-
2162 */-
2163QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2164{-
2165 QV4::Scope scope(b);-
2166 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2167 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2168-
2169 if (argc >= 4)
argc >= 4Description
TRUEnever evaluated
FALSEnever evaluated
0
2170 r->d()->context->strokeRect(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
never executed: r->d()->context->strokeRect(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
0
2171-
2172 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2173-
2174}-
2175-
2176// Complex shapes (paths) API-
2177/*!-
2178 \qmlmethod object QtQuick::Context2D::arc(real x, real y, real radius,-
2179 real startAngle, real endAngle, bool anticlockwise)-
2180-
2181 Adds an arc to the current subpath that lies on the circumference of the-
2182 circle whose center is at the point (\a x, \a y) and whose radius is-
2183 \a radius.-
2184-
2185 Both \c startAngle and \c endAngle are measured from the x-axis in radians.-
2186-
2187 \image qml-item-canvas-arc.png-
2188-
2189 \image qml-item-canvas-startAngle.png-
2190-
2191 The \a anticlockwise parameter is \c true for each arc in the figure above-
2192 because they are all drawn in the anticlockwise direction.-
2193-
2194 \sa arcTo, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arc}{W3C's 2D-
2195 Context Standard for arc()}-
2196*/-
2197QV4::ReturnedValue QQuickJSContext2DPrototype::method_arc(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2198{-
2199 QV4::Scope scope(b);-
2200 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2201 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2202-
2203 if (argc >= 5) {
argc >= 5Description
TRUEnever evaluated
FALSEnever evaluated
0
2204 bool antiClockwise = false;-
2205-
2206 if (argc == 6)
argc == 6Description
TRUEnever evaluated
FALSEnever evaluated
0
2207 antiClockwise = argv[5].toBoolean();
never executed: antiClockwise = argv[5].toBoolean();
0
2208-
2209 qreal radius = argv[2].toNumber();-
2210-
2211 if (qt_is_finite(radius) && radius < 0)
qt_is_finite(radius)Description
TRUEnever evaluated
FALSEnever evaluated
radius < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2212 THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
2213-
2214 r->d()->context->arc(argv[0].toNumber(),-
2215 argv[1].toNumber(),-
2216 radius,-
2217 argv[3].toNumber(),-
2218 argv[4].toNumber(),-
2219 antiClockwise);-
2220 }
never executed: end of block
0
2221-
2222 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2223-
2224}-
2225-
2226/*!-
2227 \qmlmethod object QtQuick::Context2D::arcTo(real x1, real y1, real x2,-
2228 real y2, real radius)-
2229-
2230 Adds an arc with the given control points and radius to the current subpath,-
2231 connected to the previous point by a straight line. To draw an arc, you-
2232 begin with the same steps you followed to create a line:-
2233-
2234 \list-
2235 \li Call the beginPath() method to set a new path.-
2236 \li Call the moveTo(\c x, \c y) method to set your starting position on the-
2237 canvas at the point (\c x, \c y).-
2238 \li To draw an arc or circle, call the arcTo(\a x1, \a y1, \a x2, \a y2,-
2239 \a radius) method. This adds an arc with starting point (\a x1, \a y1),-
2240 ending point (\a x2, \a y2), and \a radius to the current subpath and-
2241 connects it to the previous subpath by a straight line.-
2242 \endlist-
2243-
2244 \image qml-item-canvas-arcTo.png-
2245-
2246 \sa arc, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arcto}{W3C's 2D-
2247 Context Standard for arcTo()}-
2248*/-
2249QV4::ReturnedValue QQuickJSContext2DPrototype::method_arcTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2250{-
2251 QV4::Scope scope(b);-
2252 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2253 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2254-
2255 if (argc >= 5) {
argc >= 5Description
TRUEnever evaluated
FALSEnever evaluated
0
2256 qreal radius = argv[4].toNumber();-
2257-
2258 if (qt_is_finite(radius) && radius < 0)
qt_is_finite(radius)Description
TRUEnever evaluated
FALSEnever evaluated
radius < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2259 THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
2260-
2261 r->d()->context->arcTo(argv[0].toNumber(),-
2262 argv[1].toNumber(),-
2263 argv[2].toNumber(),-
2264 argv[3].toNumber(),-
2265 radius);-
2266 }
never executed: end of block
0
2267-
2268 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2269-
2270}-
2271-
2272/*!-
2273 \qmlmethod object QtQuick::Context2D::beginPath()-
2274-
2275 Resets the current path to a new path.-
2276 */-
2277QV4::ReturnedValue QQuickJSContext2DPrototype::method_beginPath(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2278{-
2279 QV4::Scope scope(b);-
2280 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2281 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2282-
2283 r->d()->context->beginPath();-
2284-
2285 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2286-
2287}-
2288-
2289/*!-
2290 \qmlmethod object QtQuick::Context2D::bezierCurveTo(real cp1x, real cp1y, real cp2x, real cp2y, real x, real y)-
2291-
2292 Adds a cubic bezier curve between the current position and the given endPoint using the control points specified by (\c cp1x, cp1y),-
2293 and (\c cp2x, \c cp2y).-
2294 After the curve is added, the current position is updated to be at the end point (\c x, \c y) of the curve.-
2295 The following code produces the path shown below:-
2296 \code-
2297 ctx.strokeStyle = Qt.rgba(0, 0, 0, 1);-
2298 ctx.lineWidth = 1;-
2299 ctx.beginPath();-
2300 ctx.moveTo(20, 0);//start point-
2301 ctx.bezierCurveTo(-10, 90, 210, 90, 180, 0);-
2302 ctx.stroke();-
2303 \endcode-
2304 \image qml-item-canvas-bezierCurveTo.png-
2305 \sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-beziercurveto}{W3C 2d context standard for bezierCurveTo}-
2306 \sa {http://www.openrise.com/lab/FlowerPower/}{The beautiful flower demo by using bezierCurveTo}-
2307 */-
2308QV4::ReturnedValue QQuickJSContext2DPrototype::method_bezierCurveTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2309{-
2310 QV4::Scope scope(b);-
2311 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2312 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2313-
2314 if (argc >= 6) {
argc >= 6Description
TRUEnever evaluated
FALSEnever evaluated
0
2315 qreal cp1x = argv[0].toNumber();-
2316 qreal cp1y = argv[1].toNumber();-
2317 qreal cp2x = argv[2].toNumber();-
2318 qreal cp2y = argv[3].toNumber();-
2319 qreal x = argv[4].toNumber();-
2320 qreal y = argv[5].toNumber();-
2321-
2322 if (!qt_is_finite(cp1x) || !qt_is_finite(cp1y) || !qt_is_finite(cp2x) || !qt_is_finite(cp2y) || !qt_is_finite(x) || !qt_is_finite(y))
!qt_is_finite(cp1x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(cp1y)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(cp2x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(cp2y)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
2323 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2324-
2325 r->d()->context->bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);-
2326 }
never executed: end of block
0
2327 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2328}-
2329-
2330/*!-
2331 \qmlmethod object QtQuick::Context2D::clip()-
2332-
2333 Creates the clipping region from the current path.-
2334 Any parts of the shape outside the clipping path are not displayed.-
2335 To create a complex shape using the \c clip() method:-
2336-
2337 \list 1-
2338 \li Call the \c{context.beginPath()} method to set the clipping path.-
2339 \li Define the clipping path by calling any combination of the \c{lineTo},-
2340 \c{arcTo}, \c{arc}, \c{moveTo}, etc and \c{closePath} methods.-
2341 \li Call the \c{context.clip()} method.-
2342 \endlist-
2343-
2344 The new shape displays. The following shows how a clipping path can-
2345 modify how an image displays:-
2346-
2347 \image qml-item-canvas-clip-complex.png-
2348 \sa beginPath()-
2349 \sa closePath()-
2350 \sa stroke()-
2351 \sa fill()-
2352 \sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-clip}{W3C 2d context standard for clip}-
2353 */-
2354QV4::ReturnedValue QQuickJSContext2DPrototype::method_clip(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2355{-
2356 QV4::Scope scope(b);-
2357 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2358 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2359-
2360 r->d()->context->clip();-
2361 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2362}-
2363-
2364/*!-
2365 \qmlmethod object QtQuick::Context2D::closePath()-
2366 Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting a new path.-
2367 The current point of the new path is the previous subpath's first point.-
2368-
2369 \sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-closepath}{W3C 2d context standard for closePath}-
2370 */-
2371QV4::ReturnedValue QQuickJSContext2DPrototype::method_closePath(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2372{-
2373 QV4::Scope scope(b);-
2374 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2375 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2376-
2377 r->d()->context->closePath();-
2378-
2379 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2380}-
2381-
2382/*!-
2383 \qmlmethod object QtQuick::Context2D::fill()-
2384-
2385 Fills the subpaths with the current fill style.-
2386-
2387 \sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-fill}{W3C 2d context standard for fill}-
2388-
2389 \sa fillStyle-
2390 */-
2391QV4::ReturnedValue QQuickJSContext2DPrototype::method_fill(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2392{-
2393 QV4::Scope scope(b);-
2394 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2395 CHECK_CONTEXT(r);
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2396 r->d()->context->fill();-
2397 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2398}-
2399-
2400/*!-
2401 \qmlmethod object QtQuick::Context2D::lineTo(real x, real y)-
2402-
2403 Draws a line from the current position to the point (x, y).-
2404 */-
2405QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2406{-
2407 QV4::Scope scope(b);-
2408 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2409 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2410-
2411 if (argc >= 2) {
argc >= 2Description
TRUEnever evaluated
FALSEnever evaluated
0
2412 qreal x = argv[0].toNumber();-
2413 qreal y = argv[1].toNumber();-
2414-
2415 if (!qt_is_finite(x) || !qt_is_finite(y))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
2416 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2417-
2418 r->d()->context->lineTo(x, y);-
2419 }
never executed: end of block
0
2420-
2421 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2422}-
2423-
2424/*!-
2425 \qmlmethod object QtQuick::Context2D::moveTo(real x, real y)-
2426-
2427 Creates a new subpath with the given point.-
2428 */-
2429QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2430{-
2431 QV4::Scope scope(b);-
2432 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2433 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2434-
2435 if (argc >= 2) {
argc >= 2Description
TRUEnever evaluated
FALSEnever evaluated
0
2436 qreal x = argv[0].toNumber();-
2437 qreal y = argv[1].toNumber();-
2438-
2439 if (!qt_is_finite(x) || !qt_is_finite(y))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
2440 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2441 r->d()->context->moveTo(x, y);-
2442 }
never executed: end of block
0
2443-
2444 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2445}-
2446-
2447/*!-
2448 \qmlmethod object QtQuick::Context2D::quadraticCurveTo(real cpx, real cpy, real x, real y)-
2449-
2450 Adds a quadratic bezier curve between the current point and the endpoint (\c x, \c y) with the control point specified by (\c cpx, \c cpy).-
2451-
2452 See \l{http://www.w3.org/TR/2dcontext/#dom-context-2d-quadraticcurveto}{W3C 2d context standard for quadraticCurveTo}-
2453 */-
2454QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2455{-
2456 QV4::Scope scope(b);-
2457 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2458 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2459-
2460 if (argc >= 4) {
argc >= 4Description
TRUEnever evaluated
FALSEnever evaluated
0
2461 qreal cpx = argv[0].toNumber();-
2462 qreal cpy = argv[1].toNumber();-
2463 qreal x = argv[2].toNumber();-
2464 qreal y = argv[3].toNumber();-
2465-
2466 if (!qt_is_finite(cpx) || !qt_is_finite(cpy) || !qt_is_finite(x) || !qt_is_finite(y))
!qt_is_finite(cpx)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(cpy)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
2467 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2468-
2469 r->d()->context->quadraticCurveTo(cpx, cpy, x, y);-
2470 }
never executed: end of block
0
2471-
2472 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2473}-
2474-
2475/*!-
2476 \qmlmethod object QtQuick::Context2D::rect(real x, real y, real w, real h)-
2477-
2478 Adds a rectangle at position (\c x, \c y), with the given width \c w and height \c h, as a closed subpath.-
2479 */-
2480QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2481{-
2482 QV4::Scope scope(b);-
2483 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2484 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2485-
2486 if (argc >= 4)
argc >= 4Description
TRUEnever evaluated
FALSEnever evaluated
0
2487 r->d()->context->rect(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
never executed: r->d()->context->rect(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
0
2488 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2489-
2490}-
2491-
2492/*!-
2493 \qmlmethod object QtQuick::Context2D::roundedRect(real x, real y, real w, real h, real xRadius, real yRadius)-
2494-
2495 Adds the given rectangle rect with rounded corners to the path. The \c xRadius and \c yRadius arguments specify the radius of the-
2496 ellipses defining the corners of the rounded rectangle.-
2497 */-
2498QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2499{-
2500 QV4::Scope scope(b);-
2501 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2502 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2503-
2504 if (argc >= 6)
argc >= 6Description
TRUEnever evaluated
FALSEnever evaluated
0
2505 r->d()->context->roundedRect(argv[0].toNumber()
never executed: r->d()->context->roundedRect(argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
2506 , argv[1].toNumber()
never executed: r->d()->context->roundedRect(argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
2507 , argv[2].toNumber()
never executed: r->d()->context->roundedRect(argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
2508 , argv[3].toNumber()
never executed: r->d()->context->roundedRect(argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
2509 , argv[4].toNumber()
never executed: r->d()->context->roundedRect(argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
2510 , argv[5].toNumber());
never executed: r->d()->context->roundedRect(argv[0].toNumber() , argv[1].toNumber() , argv[2].toNumber() , argv[3].toNumber() , argv[4].toNumber() , argv[5].toNumber());
0
2511 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2512-
2513}-
2514-
2515/*!-
2516 \qmlmethod object QtQuick::Context2D::ellipse(real x, real y, real w, real h)-
2517-
2518 Creates an ellipse within the bounding rectangle defined by its top-left corner at (\a x, \ y), width \a w and height \a h,-
2519 and adds it to the path as a closed subpath.-
2520-
2521 The ellipse is composed of a clockwise curve, starting and finishing at zero degrees (the 3 o'clock position).-
2522 */-
2523QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2524{-
2525 QV4::Scope scope(b);-
2526 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2527 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2528-
2529 if (argc >= 4)
argc >= 4Description
TRUEnever evaluated
FALSEnever evaluated
0
2530 r->d()->context->ellipse(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
never executed: r->d()->context->ellipse(argv[0].toNumber(), argv[1].toNumber(), argv[2].toNumber(), argv[3].toNumber());
0
2531-
2532 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2533-
2534}-
2535-
2536/*!-
2537 \qmlmethod object QtQuick::Context2D::text(string text, real x, real y)-
2538-
2539 Adds the given \c text to the path as a set of closed subpaths created from the current context font supplied.-
2540 The subpaths are positioned so that the left end of the text's baseline lies at the point specified by (\c x, \c y).-
2541 */-
2542QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2543{-
2544 QV4::Scope scope(b);-
2545 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2546 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2547-
2548 if (argc >= 3) {
argc >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
2549 qreal x = argv[1].toNumber();-
2550 qreal y = argv[2].toNumber();-
2551-
2552 if (!qt_is_finite(x) || !qt_is_finite(y))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
2553 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2554 r->d()->context->text(argv[0].toQStringNoThrow(), x, y);-
2555 }
never executed: end of block
0
2556-
2557 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2558}-
2559-
2560/*!-
2561 \qmlmethod object QtQuick::Context2D::stroke()-
2562-
2563 Strokes the subpaths with the current stroke style.-
2564-
2565 See \l{http://www.w3.org/TR/2dcontext/#dom-context-2d-stroke}{W3C 2d context standard for stroke}-
2566-
2567 \sa strokeStyle-
2568 */-
2569QV4::ReturnedValue QQuickJSContext2DPrototype::method_stroke(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2570{-
2571 QV4::Scope scope(b);-
2572 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2573 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2574-
2575 r->d()->context->stroke();-
2576 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2577-
2578}-
2579-
2580/*!-
2581 \qmlmethod object QtQuick::Context2D::isPointInPath(real x, real y)-
2582-
2583 Returns true if the given point is in the current path.-
2584-
2585 \sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-ispointinpath}{W3C 2d context standard for isPointInPath}-
2586 */-
2587QV4::ReturnedValue QQuickJSContext2DPrototype::method_isPointInPath(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2588{-
2589 QV4::Scope scope(b);-
2590 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2591 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2592-
2593 bool pointInPath = false;-
2594 if (argc >= 2)
argc >= 2Description
TRUEnever evaluated
FALSEnever evaluated
0
2595 pointInPath = r->d()->context->isPointInPath(argv[0].toNumber(), argv[1].toNumber());
never executed: pointInPath = r->d()->context->isPointInPath(argv[0].toNumber(), argv[1].toNumber());
0
2596 RETURN_RESULT(QV4::Primitive::fromBoolean(pointInPath).asReturnedValue());
never executed: return QV4::Encode(QV4::Primitive::fromBoolean(pointInPath).asReturnedValue());
0
2597}-
2598-
2599QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawFocusRing(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *, int)-
2600{-
2601 QV4::Scope scope(b);-
2602 THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::drawFocusRing is not supported");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
2603}-
2604-
2605QV4::ReturnedValue QQuickJSContext2DPrototype::method_setCaretSelectionRect(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *, int)-
2606{-
2607 QV4::Scope scope(b);-
2608 THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::setCaretSelectionRect is not supported");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
2609}-
2610-
2611QV4::ReturnedValue QQuickJSContext2DPrototype::method_caretBlinkRate(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *, int)-
2612{-
2613 QV4::Scope scope(b);-
2614 THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::caretBlinkRate is not supported");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
2615}-
2616-
2617/*!-
2618 \qmlproperty string QtQuick::Context2D::font-
2619 Holds the current font settings.-
2620-
2621 A subset of the-
2622 \l {http://www.w3.org/TR/2dcontext/#dom-context-2d-font}{w3C 2d context standard for font}-
2623 is supported:-
2624-
2625 \list-
2626 \li font-style (optional):-
2627 normal | italic | oblique-
2628 \li font-variant (optional): normal | small-caps-
2629 \li font-weight (optional): normal | bold | 0 ... 99-
2630 \li font-size: Npx | Npt (where N is a positive number)-
2631 \li font-family: See \l {http://www.w3.org/TR/CSS2/fonts.html#propdef-font-family}-
2632 \endlist-
2633-
2634 \note The font-size and font-family properties are mandatory and must be in-
2635 the order they are shown in above. In addition, a font family with spaces in-
2636 its name must be quoted.-
2637-
2638 The default font value is "10px sans-serif".-
2639 */-
2640QV4::ReturnedValue QQuickJSContext2D::method_get_font(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2641{-
2642 QV4::Scope scope(b);-
2643 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2644 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2645-
2646 RETURN_RESULT(scope.engine->newString(r->d()->context->state.font.toString()));
never executed: return QV4::Encode(scope.engine->newString(r->d()->context->state.font.toString()));
0
2647}-
2648-
2649QV4::ReturnedValue QQuickJSContext2D::method_set_font(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2650{-
2651 QV4::Scope scope(b);-
2652 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2653 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2654-
2655 QV4::ScopedString s(scope, argc ? argv[0] : QV4::Primitive::undefinedValue(), QV4::ScopedString::Convert);-
2656 if (scope.engine->hasException)
scope.engine->hasExceptionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2657 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2658 QFont font = qt_font_from_string(s->toQString(), r->d()->context->state.font);-
2659 if (font != r->d()->context->state.font) {
font != r->d()...xt->state.fontDescription
TRUEnever evaluated
FALSEnever evaluated
0
2660 r->d()->context->state.font = font;-
2661 }
never executed: end of block
0
2662 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2663}-
2664-
2665/*!-
2666 \qmlproperty string QtQuick::Context2D::textAlign-
2667-
2668 Holds the current text alignment settings.-
2669 The possible values are:-
2670 \list-
2671 \li start-
2672 \li end-
2673 \li left-
2674 \li right-
2675 \li center-
2676 \endlist-
2677 Other values are ignored. The default value is "start".-
2678 */-
2679QV4::ReturnedValue QQuickJSContext2D::method_get_textAlign(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2680{-
2681 QV4::Scope scope(b);-
2682 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2683 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2684-
2685 switch (r->d()->context->state.textAlign) {-
2686 case QQuickContext2D::End:
never executed: case QQuickContext2D::End:
0
2687 RETURN_RESULT(scope.engine->newString(QStringLiteral("end")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "end")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "end" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
2688 case QQuickContext2D::Left:
never executed: case QQuickContext2D::Left:
0
2689 RETURN_RESULT(scope.engine->newString(QStringLiteral("left")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "left")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "left" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
2690 case QQuickContext2D::Right:
never executed: case QQuickContext2D::Right:
0
2691 RETURN_RESULT(scope.engine->newString(QStringLiteral("right")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "right")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "right" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
2692 case QQuickContext2D::Center:
never executed: case QQuickContext2D::Center:
0
2693 RETURN_RESULT(scope.engine->newString(QStringLiteral("center")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "center")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "center" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
2694 case QQuickContext2D::Start:
never executed: case QQuickContext2D::Start:
0
2695 default:
never executed: default:
0
2696 break;
never executed: break;
0
2697 }-
2698 RETURN_RESULT(scope.engine->newString(QStringLiteral("start")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "start")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "start" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
2699}-
2700-
2701QV4::ReturnedValue QQuickJSContext2D::method_set_textAlign(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2702{-
2703 QV4::Scope scope(b);-
2704 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2705 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2706-
2707 QV4::ScopedString s(scope, argc ? argv[0] : QV4::Primitive::undefinedValue(), QV4::ScopedString::Convert);-
2708 if (scope.engine->hasException)
scope.engine->hasExceptionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2709 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2710 QString textAlign = s->toQString();-
2711-
2712 QQuickContext2D::TextAlignType ta;-
2713 if (textAlign == QLatin1String("start"))
textAlign == Q...tring("start")Description
TRUEnever evaluated
FALSEnever evaluated
0
2714 ta = QQuickContext2D::Start;
never executed: ta = QQuickContext2D::Start;
0
2715 else if (textAlign == QLatin1String("end"))
textAlign == Q...1String("end")Description
TRUEnever evaluated
FALSEnever evaluated
0
2716 ta = QQuickContext2D::End;
never executed: ta = QQuickContext2D::End;
0
2717 else if (textAlign == QLatin1String("left"))
textAlign == Q...String("left")Description
TRUEnever evaluated
FALSEnever evaluated
0
2718 ta = QQuickContext2D::Left;
never executed: ta = QQuickContext2D::Left;
0
2719 else if (textAlign == QLatin1String("right"))
textAlign == Q...tring("right")Description
TRUEnever evaluated
FALSEnever evaluated
0
2720 ta = QQuickContext2D::Right;
never executed: ta = QQuickContext2D::Right;
0
2721 else if (textAlign == QLatin1String("center"))
textAlign == Q...ring("center")Description
TRUEnever evaluated
FALSEnever evaluated
0
2722 ta = QQuickContext2D::Center;
never executed: ta = QQuickContext2D::Center;
0
2723 else-
2724 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2725-
2726 if (ta != r->d()->context->state.textAlign)
ta != r->d()->...tate.textAlignDescription
TRUEnever evaluated
FALSEnever evaluated
0
2727 r->d()->context->state.textAlign = ta;
never executed: r->d()->context->state.textAlign = ta;
0
2728-
2729 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2730}-
2731-
2732/*!-
2733 \qmlproperty string QtQuick::Context2D::textBaseline-
2734-
2735 Holds the current baseline alignment settings.-
2736 The possible values are:-
2737 \list-
2738 \li top-
2739 \li hanging-
2740 \li middle-
2741 \li alphabetic-
2742 \li ideographic-
2743 \li bottom-
2744 \endlist-
2745 Other values are ignored. The default value is "alphabetic".-
2746 */-
2747QV4::ReturnedValue QQuickJSContext2D::method_get_textBaseline(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
2748{-
2749 QV4::Scope scope(b);-
2750 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2751 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2752-
2753 switch (r->d()->context->state.textBaseline) {-
2754 case QQuickContext2D::Hanging:
never executed: case QQuickContext2D::Hanging:
0
2755 RETURN_RESULT(scope.engine->newString(QStringLiteral("hanging")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "hanging")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "hanging" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
2756 case QQuickContext2D::Top:
never executed: case QQuickContext2D::Top:
0
2757 RETURN_RESULT(scope.engine->newString(QStringLiteral("top")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "top")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "top" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
2758 case QQuickContext2D::Bottom:
never executed: case QQuickContext2D::Bottom:
0
2759 RETURN_RESULT(scope.engine->newString(QStringLiteral("bottom")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "bottom")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "bottom" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
2760 case QQuickContext2D::Middle:
never executed: case QQuickContext2D::Middle:
0
2761 RETURN_RESULT(scope.engine->newString(QStringLiteral("middle")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "middle")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "middle" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
2762 case QQuickContext2D::Alphabetic:
never executed: case QQuickContext2D::Alphabetic:
0
2763 default:
never executed: default:
0
2764 break;
never executed: break;
0
2765 }-
2766 RETURN_RESULT(scope.engine->newString(QStringLiteral("alphabetic")));
never executed: return QV4::Encode(scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "alphabetic")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "alphabetic" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
2767}-
2768-
2769QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2770{-
2771 QV4::Scope scope(b);-
2772 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2773 CHECK_CONTEXT_SETTER(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2774 QV4::ScopedString s(scope, argc ? argv[0] : QV4::Primitive::undefinedValue(), QV4::ScopedString::Convert);-
2775 if (scope.engine->hasException)
scope.engine->hasExceptionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2776 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2777 QString textBaseline = s->toQString();-
2778-
2779 QQuickContext2D::TextBaseLineType tb;-
2780 if (textBaseline == QLatin1String("alphabetic"))
textBaseline =...("alphabetic")Description
TRUEnever evaluated
FALSEnever evaluated
0
2781 tb = QQuickContext2D::Alphabetic;
never executed: tb = QQuickContext2D::Alphabetic;
0
2782 else if (textBaseline == QLatin1String("hanging"))
textBaseline =...ing("hanging")Description
TRUEnever evaluated
FALSEnever evaluated
0
2783 tb = QQuickContext2D::Hanging;
never executed: tb = QQuickContext2D::Hanging;
0
2784 else if (textBaseline == QLatin1String("top"))
textBaseline =...1String("top")Description
TRUEnever evaluated
FALSEnever evaluated
0
2785 tb = QQuickContext2D::Top;
never executed: tb = QQuickContext2D::Top;
0
2786 else if (textBaseline == QLatin1String("bottom"))
textBaseline =...ring("bottom")Description
TRUEnever evaluated
FALSEnever evaluated
0
2787 tb = QQuickContext2D::Bottom;
never executed: tb = QQuickContext2D::Bottom;
0
2788 else if (textBaseline == QLatin1String("middle"))
textBaseline =...ring("middle")Description
TRUEnever evaluated
FALSEnever evaluated
0
2789 tb = QQuickContext2D::Middle;
never executed: tb = QQuickContext2D::Middle;
0
2790 else-
2791 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2792-
2793 if (tb != r->d()->context->state.textBaseline)
tb != r->d()->...e.textBaselineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2794 r->d()->context->state.textBaseline = tb;
never executed: r->d()->context->state.textBaseline = tb;
0
2795-
2796 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2797}-
2798-
2799/*!-
2800 \qmlmethod object QtQuick::Context2D::fillText(text, x, y)-
2801 Fills the given text at the given position.-
2802 \sa font-
2803 \sa textAlign-
2804 \sa textBaseline-
2805 \sa strokeText-
2806 */-
2807QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillText(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2808{-
2809 QV4::Scope scope(b);-
2810 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2811 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2812-
2813 if (argc >= 3) {
argc >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
2814 qreal x = argv[1].toNumber();-
2815 qreal y = argv[2].toNumber();-
2816 if (!qt_is_finite(x) || !qt_is_finite(y))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
2817 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2818 QPainterPath textPath = r->d()->context->createTextGlyphs(x, y, argv[0].toQStringNoThrow());-
2819 r->d()->context->buffer()->fill(textPath);-
2820 }
never executed: end of block
0
2821-
2822 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2823}-
2824/*!-
2825 \qmlmethod object QtQuick::Context2D::strokeText(text, x, y)-
2826 Strokes the given text at the given position.-
2827 \sa font-
2828 \sa textAlign-
2829 \sa textBaseline-
2830 \sa fillText-
2831 */-
2832QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeText(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2833{-
2834 QV4::Scope scope(b);-
2835 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2836 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2837-
2838 if (argc >= 3)
argc >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
2839 r->d()->context->drawText(argv[0].toQStringNoThrow(), argv[1].toNumber(), argv[2].toNumber(), false);
never executed: r->d()->context->drawText(argv[0].toQStringNoThrow(), argv[1].toNumber(), argv[2].toNumber(), false);
0
2840-
2841 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
2842}-
2843-
2844/*!-
2845 \qmlmethod object QtQuick::Context2D::measureText(text)-
2846-
2847 Returns an object with a \c width property, whose value is equivalent to-
2848 calling \l {QFontMetrics::width()} with the given \a text in the current font.-
2849 */-
2850QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2851{-
2852 QV4::Scope scope(b);-
2853 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2854 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2855-
2856 if (argc >= 1) {
argc >= 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2857 QFontMetrics fm(r->d()->context->state.font);-
2858 uint width = fm.width(argv[0].toQStringNoThrow());-
2859 QV4::ScopedObject tm(scope, scope.engine->newObject());-
2860 tm->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("width"))).getPointer(),
never executed: return qstring_literal_temp;
0
2861 QV4::ScopedValue(scope, QV4::Primitive::fromDouble(width)));-
2862 RETURN_RESULT(*tm);
never executed: return QV4::Encode(*tm);
0
2863 }-
2864 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2865}-
2866-
2867// drawing images-
2868/*!-
2869 \qmlmethod QtQuick::Context2D::drawImage(variant image, real dx, real dy)-
2870 Draws the given \a image on the canvas at position (\a dx, \a dy).-
2871 Note:-
2872 The \a image type can be an Image item, an image url or a CanvasImageData object.-
2873 When given as Image item, if the image isn't fully loaded, this method draws nothing.-
2874 When given as url string, the image should be loaded by calling Canvas item's Canvas::loadImage() method first.-
2875 This image been drawing is subject to the current context clip path, even the given \c image is a CanvasImageData object.-
2876-
2877 \sa CanvasImageData-
2878 \sa Image-
2879 \sa Canvas::loadImage-
2880 \sa Canvas::isImageLoaded-
2881 \sa Canvas::imageLoaded-
2882-
2883 \sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-drawimage}{W3C 2d context standard for drawImage}-
2884 */-
2885/*!-
2886 \qmlmethod QtQuick::Context2D::drawImage(variant image, real dx, real dy, real dw, real dh)-
2887 This is an overloaded function.-
2888 Draws the given item as \a image onto the canvas at point (\a dx, \a dy) and with width \a dw,-
2889 height \a dh.-
2890-
2891 Note:-
2892 The \a image type can be an Image item, an image url or a CanvasImageData object.-
2893 When given as Image item, if the image isn't fully loaded, this method draws nothing.-
2894 When given as url string, the image should be loaded by calling Canvas item's Canvas::loadImage() method first.-
2895 This image been drawing is subject to the current context clip path, even the given \c image is a CanvasImageData object.-
2896-
2897 \sa CanvasImageData-
2898 \sa Image-
2899 \sa Canvas::loadImage()-
2900 \sa Canvas::isImageLoaded-
2901 \sa Canvas::imageLoaded-
2902-
2903 \sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-drawimage}{W3C 2d context standard for drawImage}-
2904 */-
2905/*!-
2906 \qmlmethod QtQuick::Context2D::drawImage(variant image, real sx, real sy, real sw, real sh, real dx, real dy, real dw, real dh)-
2907 This is an overloaded function.-
2908 Draws the given item as \a image from source point (\a sx, \a sy) and source width \a sw, source height \a sh-
2909 onto the canvas at point (\a dx, \a dy) and with width \a dw, height \a dh.-
2910-
2911-
2912 Note:-
2913 The \a image type can be an Image or Canvas item, an image url or a CanvasImageData object.-
2914 When given as Image item, if the image isn't fully loaded, this method draws nothing.-
2915 When given as url string, the image should be loaded by calling Canvas item's Canvas::loadImage() method first.-
2916 This image been drawing is subject to the current context clip path, even the given \c image is a CanvasImageData object.-
2917-
2918 \sa CanvasImageData-
2919 \sa Image-
2920 \sa Canvas::loadImage()-
2921 \sa Canvas::isImageLoaded-
2922 \sa Canvas::imageLoaded-
2923-
2924 \sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-drawimage}{W3C 2d context standard for drawImage}-
2925*/-
2926QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
2927{-
2928 QV4::Scope scope(b);-
2929 QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);-
2930 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2931-
2932 qreal sx, sy, sw, sh, dx, dy, dw, dh;-
2933-
2934 if (!argc)
!argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
2935 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2936-
2937 //FIXME:This function should be moved to QQuickContext2D::drawImage(...)-
2938 if (!r->d()->context->state.invertibleCTM)
!r->d()->conte....invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
2939 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2940-
2941 QQmlRefPointer<QQuickCanvasPixmap> pixmap;-
2942-
2943 QV4::ScopedValue arg(scope, argv[0]);-
2944 if (arg->isString()) {
arg->isString()Description
TRUEnever evaluated
FALSEnever evaluated
0
2945 QUrl url(arg->toQString());-
2946 if (!url.isValid())
!url.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2947 THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
2948-
2949 pixmap = r->d()->context->createPixmap(url);-
2950 } else if (arg->isObject()) {
never executed: end of block
arg->isObject()Description
TRUEnever evaluated
FALSEnever evaluated
0
2951 QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, arg);-
2952 if (!!qobjectWrapper) {
!!qobjectWrapperDescription
TRUEnever evaluated
FALSEnever evaluated
0
2953 if (QQuickImage *imageItem = qobject_cast<QQuickImage*>(qobjectWrapper->object())) {
QQuickImage *i...per->object())Description
TRUEnever evaluated
FALSEnever evaluated
0
2954 pixmap = r->d()->context->createPixmap(imageItem->source());-
2955 } else if (QQuickCanvasItem *canvas = qobject_cast<QQuickCanvasItem*>(qobjectWrapper->object())) {
never executed: end of block
QQuickCanvasIt...per->object())Description
TRUEnever evaluated
FALSEnever evaluated
0
2956 QImage img = canvas->toImage();-
2957 if (!img.isNull())
!img.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2958 pixmap.adopt(new QQuickCanvasPixmap(img));
never executed: pixmap.adopt(new QQuickCanvasPixmap(img));
0
2959 } else {
never executed: end of block
0
2960 THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
2961 }-
2962 } else {-
2963 QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, arg);-
2964 if (!!imageData) {
!!imageDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
2965 QV4::Scoped<QQuickJSContext2DPixelData> pix(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());-
2966 if (pix && !pix->d()->image->isNull()) {
pixDescription
TRUEnever evaluated
FALSEnever evaluated
!pix->d()->image->isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2967 pixmap.adopt(new QQuickCanvasPixmap(*pix->d()->image));-
2968 } else {
never executed: end of block
0
2969 THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
2970 }-
2971 } else {-
2972 QUrl url(arg->toQStringNoThrow());-
2973 if (url.isValid())
url.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2974 pixmap = r->d()->context->createPixmap(url);
never executed: pixmap = r->d()->context->createPixmap(url);
0
2975 else-
2976 THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
2977 }-
2978 }-
2979 } else {-
2980 THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
2981 }-
2982-
2983 if (pixmap.isNull() || !pixmap->isValid())
pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
!pixmap->isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2984 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
2985-
2986 if (argc >= 9) {
argc >= 9Description
TRUEnever evaluated
FALSEnever evaluated
0
2987 sx = argv[1].toNumber();-
2988 sy = argv[2].toNumber();-
2989 sw = argv[3].toNumber();-
2990 sh = argv[4].toNumber();-
2991 dx = argv[5].toNumber();-
2992 dy = argv[6].toNumber();-
2993 dw = argv[7].toNumber();-
2994 dh = argv[8].toNumber();-
2995 } else if (argc >= 5) {
never executed: end of block
argc >= 5Description
TRUEnever evaluated
FALSEnever evaluated
0
2996 sx = 0;-
2997 sy = 0;-
2998 sw = pixmap->width();-
2999 sh = pixmap->height();-
3000 dx = argv[1].toNumber();-
3001 dy = argv[2].toNumber();-
3002 dw = argv[3].toNumber();-
3003 dh = argv[4].toNumber();-
3004 } else if (argc >= 3) {
never executed: end of block
argc >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
3005 dx = argv[1].toNumber();-
3006 dy = argv[2].toNumber();-
3007 sx = 0;-
3008 sy = 0;-
3009 sw = pixmap->width();-
3010 sh = pixmap->height();-
3011 dw = sw;-
3012 dh = sh;-
3013 } else {
never executed: end of block
0
3014 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
3015 }-
3016-
3017 if (!qt_is_finite(sx)
!qt_is_finite(sx)Description
TRUEnever evaluated
FALSEnever evaluated
0
3018 || !qt_is_finite(sy)
!qt_is_finite(sy)Description
TRUEnever evaluated
FALSEnever evaluated
0
3019 || !qt_is_finite(sw)
!qt_is_finite(sw)Description
TRUEnever evaluated
FALSEnever evaluated
0
3020 || !qt_is_finite(sh)
!qt_is_finite(sh)Description
TRUEnever evaluated
FALSEnever evaluated
0
3021 || !qt_is_finite(dx)
!qt_is_finite(dx)Description
TRUEnever evaluated
FALSEnever evaluated
0
3022 || !qt_is_finite(dy)
!qt_is_finite(dy)Description
TRUEnever evaluated
FALSEnever evaluated
0
3023 || !qt_is_finite(dw)
!qt_is_finite(dw)Description
TRUEnever evaluated
FALSEnever evaluated
0
3024 || !qt_is_finite(dh))
!qt_is_finite(dh)Description
TRUEnever evaluated
FALSEnever evaluated
0
3025 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
3026-
3027 if (sx < 0
sx < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3028 || sy < 0
sy < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3029 || sw == 0
sw == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3030 || sh == 0
sh == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3031 || sx + sw > pixmap->width()
sx + sw > pixmap->width()Description
TRUEnever evaluated
FALSEnever evaluated
0
3032 || sy + sh > pixmap->height()
sy + sh > pixmap->height()Description
TRUEnever evaluated
FALSEnever evaluated
0
3033 || sx + sw < 0 || sy + sh < 0) {
sx + sw < 0Description
TRUEnever evaluated
FALSEnever evaluated
sy + sh < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3034 THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "drawImage(), index size error");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
3035 }-
3036-
3037 r->d()->context->buffer()->drawPixmap(pixmap, QRectF(sx, sy, sw, sh), QRectF(dx, dy, dw, dh));-
3038-
3039 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
3040}-
3041-
3042// pixel manipulation-
3043/*!-
3044 \qmltype CanvasImageData-
3045 \inqmlmodule QtQuick-
3046 \ingroup qtquick-canvas-
3047 \brief Contains image pixel data in RGBA order.-
3048-
3049 The CanvasImageData object holds the image pixel data.-
3050-
3051 The CanvasImageData object has the actual dimensions of the data stored in-
3052 this object and holds the one-dimensional array containing the data in RGBA order,-
3053 as integers in the range 0 to 255.-
3054-
3055 \sa width-
3056 \sa height-
3057 \sa data-
3058 \sa Context2D::createImageData()-
3059 \sa Context2D::getImageData()-
3060 \sa Context2D::putImageData()-
3061 */-
3062/*!-
3063 \qmlproperty int QtQuick::CanvasImageData::width-
3064 Holds the actual width dimension of the data in the ImageData object, in device pixels.-
3065 */-
3066QV4::ReturnedValue QQuickJSContext2DImageData::method_get_width(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
3067{-
3068 QV4::Scope scope(b);-
3069 QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, *thisObject);-
3070 if (!imageData)
!imageDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3071 THROW_TYPE_ERROR();
never executed: return scope.engine->throwTypeError();
0
3072 QV4::Scoped<QQuickJSContext2DPixelData> r(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());-
3073 int width = r ? r->d()->image->width() : 0;
rDescription
TRUEnever evaluated
FALSEnever evaluated
0
3074 RETURN_RESULT(QV4::Encode(width));
never executed: return QV4::Encode(QV4::Encode(width));
0
3075}-
3076-
3077/*!-
3078 \qmlproperty int QtQuick::CanvasImageData::height-
3079 Holds the actual height dimension of the data in the ImageData object, in device pixels.-
3080 */-
3081QV4::ReturnedValue QQuickJSContext2DImageData::method_get_height(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
3082{-
3083 QV4::Scope scope(b);-
3084 QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, *thisObject);-
3085 if (!imageData)
!imageDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3086 THROW_TYPE_ERROR();
never executed: return scope.engine->throwTypeError();
0
3087 QV4::Scoped<QQuickJSContext2DPixelData> r(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());-
3088 int height = r ? r->d()->image->height() : 0;
rDescription
TRUEnever evaluated
FALSEnever evaluated
0
3089 RETURN_RESULT(QV4::Encode(height));
never executed: return QV4::Encode(QV4::Encode(height));
0
3090}-
3091-
3092/*!-
3093 \qmlproperty object QtQuick::CanvasImageData::data-
3094 Holds the one-dimensional array containing the data in RGBA order, as integers in the range 0 to 255.-
3095 */-
3096QV4::ReturnedValue QQuickJSContext2DImageData::method_get_data(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
3097{-
3098 QV4::Scope scope(b);-
3099 QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, *thisObject);-
3100 if (!imageData)
!imageDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3101 THROW_TYPE_ERROR();
never executed: return scope.engine->throwTypeError();
0
3102 RETURN_RESULT(imageData->d()->pixelData);
never executed: return QV4::Encode(imageData->d()->pixelData);
0
3103}-
3104-
3105/*!-
3106 \qmltype CanvasPixelArray-
3107 \inqmlmodule QtQuick-
3108 \ingroup qtquick-canvas-
3109 \brief Provides ordered and indexed access to the components of each pixel in image data.-
3110-
3111 The CanvasPixelArray object provides ordered, indexed access to the color components of each pixel of the image data.-
3112 The CanvasPixelArray can be accessed as normal Javascript array.-
3113 \sa CanvasImageData-
3114 \sa {http://www.w3.org/TR/2dcontext/#canvaspixelarray}{W3C 2d context standard for PixelArray}-
3115 */-
3116-
3117/*!-
3118 \qmlproperty int QtQuick::CanvasPixelArray::length-
3119 The CanvasPixelArray object represents h×w×4 integers which w and h comes from CanvasImageData.-
3120 The length attribute of a CanvasPixelArray object must return this h×w×4 number value.-
3121 This property is read only.-
3122*/-
3123QV4::ReturnedValue QQuickJSContext2DPixelData::proto_get_length(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)-
3124{-
3125 QV4::Scope scope(b);-
3126 QV4::Scoped<QQuickJSContext2DPixelData> r(scope, thisObject->as<QQuickJSContext2DPixelData>());-
3127 if (!r || r->d()->image->isNull())
!rDescription
TRUEnever evaluated
FALSEnever evaluated
r->d()->image->isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3128 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
3129-
3130 RETURN_RESULT(QV4::Encode(r->d()->image->width() * r->d()->image->height() * 4));
never executed: return QV4::Encode(QV4::Encode(r->d()->image->width() * r->d()->image->height() * 4));
0
3131}-
3132-
3133QV4::ReturnedValue QQuickJSContext2DPixelData::virtualGet(const QV4::Managed *m, QV4::PropertyKey id, const QV4::Value *receiver, bool *hasProperty)-
3134{-
3135 if (!id.isArrayIndex())
!id.isArrayIndex()Description
TRUEnever evaluated
FALSEnever evaluated
0
3136 return QV4::Object::virtualGet(m, id, receiver, hasProperty);
never executed: return QV4::Object::virtualGet(m, id, receiver, hasProperty);
0
3137-
3138 uint index = id.asArrayIndex();-
3139 Q_ASSERT(m->as<QQuickJSContext2DPixelData>());-
3140 QV4::ExecutionEngine *v4 = static_cast<const QQuickJSContext2DPixelData *>(m)->engine();-
3141 QV4::Scope scope(v4);-
3142 QV4::Scoped<QQuickJSContext2DPixelData> r(scope, static_cast<const QQuickJSContext2DPixelData *>(m));-
3143-
3144 if (index < static_cast<quint32>(r->d()->image->width() * r->d()->image->height() * 4)) {
index < static...>height() * 4)Description
TRUEnever evaluated
FALSEnever evaluated
0
3145 if (hasProperty)
hasPropertyDescription
TRUEnever evaluated
FALSEnever evaluated
0
3146 *hasProperty = true;
never executed: *hasProperty = true;
0
3147 const quint32 w = r->d()->image->width();-
3148 const quint32 row = (index / 4) / w;-
3149 const quint32 col = (index / 4) % w;-
3150 const QRgb* pixel = reinterpret_cast<const QRgb*>(r->d()->image->constScanLine(row));-
3151 pixel += col;-
3152 switch (index % 4) {-
3153 case 0:
never executed: case 0:
0
3154 return QV4::Encode(qRed(*pixel));
never executed: return QV4::Encode(qRed(*pixel));
0
3155 case 1:
never executed: case 1:
0
3156 return QV4::Encode(qGreen(*pixel));
never executed: return QV4::Encode(qGreen(*pixel));
0
3157 case 2:
never executed: case 2:
0
3158 return QV4::Encode(qBlue(*pixel));
never executed: return QV4::Encode(qBlue(*pixel));
0
3159 case 3:
never executed: case 3:
0
3160 return QV4::Encode(qAlpha(*pixel));
never executed: return QV4::Encode(qAlpha(*pixel));
0
3161 }-
3162 }
never executed: end of block
0
3163-
3164 if (hasProperty)
hasPropertyDescription
TRUEnever evaluated
FALSEnever evaluated
0
3165 *hasProperty = false;
never executed: *hasProperty = false;
0
3166 return QV4::Encode::undefined();
never executed: return QV4::Encode::undefined();
0
3167}-
3168-
3169bool QQuickJSContext2DPixelData::virtualPut(QV4::Managed *m, QV4::PropertyKey id, const QV4::Value &value, QV4::Value *receiver)-
3170{-
3171 if (!id.isArrayIndex())
!id.isArrayIndex()Description
TRUEnever evaluated
FALSEnever evaluated
0
3172 return Object::virtualPut(m, id, value, receiver);
never executed: return Object::virtualPut(m, id, value, receiver);
0
3173-
3174 Q_ASSERT(m->as<QQuickJSContext2DPixelData>());-
3175 QV4::ExecutionEngine *v4 = static_cast<QQuickJSContext2DPixelData *>(m)->engine();-
3176 QV4::Scope scope(v4);-
3177 if (scope.hasException())
scope.hasException()Description
TRUEnever evaluated
FALSEnever evaluated
0
3178 return false;
never executed: return false;
0
3179-
3180 uint index = id.asArrayIndex();-
3181 QV4::Scoped<QQuickJSContext2DPixelData> r(scope, static_cast<QQuickJSContext2DPixelData *>(m));-
3182-
3183 const int v = value.toInt32();-
3184 if (r && index < static_cast<quint32>(r->d()->image->width() * r->d()->image->height() * 4) && v >= 0 && v <= 255) {
rDescription
TRUEnever evaluated
FALSEnever evaluated
index < static...>height() * 4)Description
TRUEnever evaluated
FALSEnever evaluated
v >= 0Description
TRUEnever evaluated
FALSEnever evaluated
v <= 255Description
TRUEnever evaluated
FALSEnever evaluated
0
3185 const quint32 w = r->d()->image->width();-
3186 const quint32 row = (index / 4) / w;-
3187 const quint32 col = (index / 4) % w;-
3188-
3189 QRgb* pixel = reinterpret_cast<QRgb*>(r->d()->image->scanLine(row));-
3190 pixel += col;-
3191 switch (index % 4) {-
3192 case 0:
never executed: case 0:
0
3193 *pixel = qRgba(v, qGreen(*pixel), qBlue(*pixel), qAlpha(*pixel));-
3194 break;
never executed: break;
0
3195 case 1:
never executed: case 1:
0
3196 *pixel = qRgba(qRed(*pixel), v, qBlue(*pixel), qAlpha(*pixel));-
3197 break;
never executed: break;
0
3198 case 2:
never executed: case 2:
0
3199 *pixel = qRgba(qRed(*pixel), qGreen(*pixel), v, qAlpha(*pixel));-
3200 break;
never executed: break;
0
3201 case 3:
never executed: case 3:
0
3202 *pixel = qRgba(qRed(*pixel), qGreen(*pixel), qBlue(*pixel), v);-
3203 break;
never executed: break;
0
3204 }-
3205 return true;
never executed: return true;
0
3206 }-
3207-
3208 return false;
never executed: return false;
0
3209}-
3210/*!-
3211 \qmlmethod CanvasImageData QtQuick::Context2D::createImageData(real sw, real sh)-
3212-
3213 Creates a CanvasImageData object with the given dimensions(\a sw, \a sh).-
3214*/-
3215/*!-
3216 \qmlmethod CanvasImageData QtQuick::Context2D::createImageData(CanvasImageData imageData)-
3217-
3218 Creates a CanvasImageData object with the same dimensions as the argument.-
3219*/-
3220/*!-
3221 \qmlmethod CanvasImageData QtQuick::Context2D::createImageData(Url imageUrl)-
3222-
3223 Creates a CanvasImageData object with the given image loaded from \a imageUrl.-
3224-
3225 \note The \a imageUrl must be already loaded before this function call,-
3226 otherwise an empty CanvasImageData obect will be returned.-
3227-
3228 \sa Canvas::loadImage(), QtQuick::Canvas::unloadImage(),-
3229 QtQuick::Canvas::isImageLoaded-
3230 */-
3231QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
3232{-
3233 QV4::Scope scope(b);-
3234 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
3235 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3236-
3237 if (argc == 1) {
argc == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
3238 QV4::ScopedValue arg0(scope, argv[0]);-
3239 QV4::Scoped<QQuickJSContext2DImageData> imgData(scope, arg0);-
3240 if (!!imgData) {
!!imgDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3241 QV4::Scoped<QQuickJSContext2DPixelData> pa(scope, imgData->d()->pixelData.as<QQuickJSContext2DPixelData>());-
3242 if (pa) {
paDescription
TRUEnever evaluated
FALSEnever evaluated
0
3243 qreal w = pa->d()->image->width();-
3244 qreal h = pa->d()->image->height();-
3245 RETURN_RESULT(qt_create_image_data(w, h, scope.engine, QImage()));
never executed: return QV4::Encode(qt_create_image_data(w, h, scope.engine, QImage()));
0
3246 }-
3247 } else if (arg0->isString()) {
never executed: end of block
arg0->isString()Description
TRUEnever evaluated
FALSEnever evaluated
0
3248 QImage image = r->d()->context->createPixmap(QUrl(arg0->toQStringNoThrow()))->image();-
3249 RETURN_RESULT(qt_create_image_data(image.width(), image.height(), scope.engine, image));
never executed: return QV4::Encode(qt_create_image_data(image.width(), image.height(), scope.engine, image));
0
3250 }-
3251 } else if (argc == 2) {
never executed: end of block
argc == 2Description
TRUEnever evaluated
FALSEnever evaluated
0
3252 qreal w = argv[0].toNumber();-
3253 qreal h = argv[1].toNumber();-
3254-
3255 if (!qt_is_finite(w) || !qt_is_finite(h))
!qt_is_finite(w)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(h)Description
TRUEnever evaluated
FALSEnever evaluated
0
3256 THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createImageData(): invalid arguments");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
3257-
3258 if (w > 0 && h > 0)
w > 0Description
TRUEnever evaluated
FALSEnever evaluated
h > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3259 RETURN_RESULT(qt_create_image_data(w, h, scope.engine, QImage()));
never executed: return QV4::Encode(qt_create_image_data(w, h, scope.engine, QImage()));
0
3260 else-
3261 THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createImageData(): invalid arguments");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
3262 }-
3263 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
3264}-
3265-
3266/*!-
3267 \qmlmethod CanvasImageData QtQuick::Context2D::getImageData(real sx, real sy, real sw, real sh)-
3268 Returns an CanvasImageData object containing the image data for the given rectangle of the canvas.-
3269 */-
3270QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
3271{-
3272 QV4::Scope scope(b);-
3273 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
3274 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3275-
3276 if (argc >= 4) {
argc >= 4Description
TRUEnever evaluated
FALSEnever evaluated
0
3277 qreal x = argv[0].toNumber();-
3278 qreal y = argv[1].toNumber();-
3279 qreal w = argv[2].toNumber();-
3280 qreal h = argv[3].toNumber();-
3281 if (!qt_is_finite(x) || !qt_is_finite(y) || !qt_is_finite(w) || !qt_is_finite(h))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(w)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(h)Description
TRUEnever evaluated
FALSEnever evaluated
0
3282 THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "getImageData(): Invalid arguments");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
3283-
3284 if (w <= 0 || h <= 0)
w <= 0Description
TRUEnever evaluated
FALSEnever evaluated
h <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3285 THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "getImageData(): Invalid arguments");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
3286-
3287 QImage image = r->d()->context->canvas()->toImage(QRectF(x, y, w, h));-
3288 RETURN_RESULT(qt_create_image_data(w, h, scope.engine, image));
never executed: return QV4::Encode(qt_create_image_data(w, h, scope.engine, image));
0
3289 }-
3290 RETURN_RESULT(QV4::Encode::null());
never executed: return QV4::Encode(QV4::Encode::null());
0
3291}-
3292-
3293/*!-
3294 \qmlmethod object QtQuick::Context2D::putImageData(CanvasImageData imageData, real dx, real dy, real dirtyX, real dirtyY, real dirtyWidth, real dirtyHeight)-
3295 Paints the data from the given ImageData object onto the canvas. If a dirty rectangle (\a dirtyX, \a dirtyY, \a dirtyWidth, \a dirtyHeight) is provided, only the pixels from that rectangle are painted.-
3296 */-
3297QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
3298{-
3299 QV4::Scope scope(b);-
3300 QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());-
3301 CHECK_CONTEXT(r)
never executed: return scope.engine->throwError(QString::fromUtf8("Not a Context2D object"));
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->contextDescription
TRUEnever evaluated
FALSEnever evaluated
!r->d()->conte...>bufferValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3302 if (argc < 7)
argc < 7Description
TRUEnever evaluated
FALSEnever evaluated
0
3303 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
3304-
3305 QV4::ScopedValue arg0(scope, argv[0]);-
3306 if (!arg0->isObject())
!arg0->isObject()Description
TRUEnever evaluated
FALSEnever evaluated
0
3307 THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "Context2D::putImageData, the image data type mismatch");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
3308-
3309 qreal dx = argv[1].toNumber();-
3310 qreal dy = argv[2].toNumber();-
3311 qreal w, h, dirtyX, dirtyY, dirtyWidth, dirtyHeight;-
3312-
3313 if (!qt_is_finite(dx) || !qt_is_finite(dy))
!qt_is_finite(dx)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(dy)Description
TRUEnever evaluated
FALSEnever evaluated
0
3314 THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "putImageData() : Invalid arguments");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
3315-
3316 QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, arg0);-
3317 if (!imageData)
!imageDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3318 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
3319-
3320 QV4::Scoped<QQuickJSContext2DPixelData> pixelArray(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());-
3321 if (pixelArray) {
pixelArrayDescription
TRUEnever evaluated
FALSEnever evaluated
0
3322 w = pixelArray->d()->image->width();-
3323 h = pixelArray->d()->image->height();-
3324-
3325 if (argc == 7) {
argc == 7Description
TRUEnever evaluated
FALSEnever evaluated
0
3326 dirtyX = argv[3].toNumber();-
3327 dirtyY = argv[4].toNumber();-
3328 dirtyWidth = argv[5].toNumber();-
3329 dirtyHeight = argv[6].toNumber();-
3330-
3331 if (!qt_is_finite(dirtyX) || !qt_is_finite(dirtyY) || !qt_is_finite(dirtyWidth) || !qt_is_finite(dirtyHeight))
!qt_is_finite(dirtyX)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(dirtyY)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(dirtyWidth)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(dirtyHeight)Description
TRUEnever evaluated
FALSEnever evaluated
0
3332 THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "putImageData() : Invalid arguments");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
3333-
3334-
3335 if (dirtyWidth < 0) {
dirtyWidth < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3336 dirtyX = dirtyX+dirtyWidth;-
3337 dirtyWidth = -dirtyWidth;-
3338 }
never executed: end of block
0
3339-
3340 if (dirtyHeight < 0) {
dirtyHeight < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3341 dirtyY = dirtyY+dirtyHeight;-
3342 dirtyHeight = -dirtyHeight;-
3343 }
never executed: end of block
0
3344-
3345 if (dirtyX < 0) {
dirtyX < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3346 dirtyWidth = dirtyWidth+dirtyX;-
3347 dirtyX = 0;-
3348 }
never executed: end of block
0
3349-
3350 if (dirtyY < 0) {
dirtyY < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3351 dirtyHeight = dirtyHeight+dirtyY;-
3352 dirtyY = 0;-
3353 }
never executed: end of block
0
3354-
3355 if (dirtyX+dirtyWidth > w) {
dirtyX+dirtyWidth > wDescription
TRUEnever evaluated
FALSEnever evaluated
0
3356 dirtyWidth = w - dirtyX;-
3357 }
never executed: end of block
0
3358-
3359 if (dirtyY+dirtyHeight > h) {
dirtyY+dirtyHeight > hDescription
TRUEnever evaluated
FALSEnever evaluated
0
3360 dirtyHeight = h - dirtyY;-
3361 }
never executed: end of block
0
3362-
3363 if (dirtyWidth <=0 || dirtyHeight <= 0)
dirtyWidth <=0Description
TRUEnever evaluated
FALSEnever evaluated
dirtyHeight <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3364 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
3365 } else {
never executed: end of block
0
3366 dirtyX = 0;-
3367 dirtyY = 0;-
3368 dirtyWidth = w;-
3369 dirtyHeight = h;-
3370 }
never executed: end of block
0
3371-
3372 QImage image = pixelArray->d()->image->copy(dirtyX, dirtyY, dirtyWidth, dirtyHeight);-
3373 r->d()->context->buffer()->drawImage(image, QRectF(dirtyX, dirtyY, dirtyWidth, dirtyHeight), QRectF(dx, dy, dirtyWidth, dirtyHeight));-
3374 }
never executed: end of block
0
3375-
3376 RETURN_RESULT(*thisObject);
never executed: return QV4::Encode(*thisObject);
0
3377}-
3378-
3379/*!-
3380 \qmltype CanvasGradient-
3381 \inqmlmodule QtQuick-
3382 \since 5.0-
3383 \ingroup qtquick-canvas-
3384 \brief Provides an opaque CanvasGradient interface.-
3385 */-
3386-
3387/*!-
3388 \qmlmethod CanvasGradient QtQuick::CanvasGradient::addColorStop(real offsetof, string color)-
3389 Adds a color stop with the given color to the gradient at the given offset.-
3390 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end.-
3391-
3392 For example:-
3393 \code-
3394 var gradient = ctx.createLinearGradient(0, 0, 100, 100);-
3395 gradient.addColorStop(0.3, Qt.rgba(1, 0, 0, 1));-
3396 gradient.addColorStop(0.7, 'rgba(0, 255, 255, 1');-
3397 \endcode-
3398 */-
3399QV4::ReturnedValue QQuickContext2DStyle::gradient_proto_addColorStop(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)-
3400{-
3401 QV4::Scope scope(b);-
3402 QV4::Scoped<QQuickContext2DStyle> style(scope, thisObject->as<QQuickContext2DStyle>());-
3403 if (!style)
!styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
3404 THROW_GENERIC_ERROR("Not a CanvasGradient object");
never executed: return scope.engine->throwError(QString::fromUtf8("Not a CanvasGradient object"));
0
3405-
3406 if (argc == 2) {
argc == 2Description
TRUEnever evaluated
FALSEnever evaluated
0
3407-
3408 if (!style->d()->brush->gradient())
!style->d()->brush->gradient()Description
TRUEnever evaluated
FALSEnever evaluated
0
3409 THROW_GENERIC_ERROR("Not a valid CanvasGradient object, can't get the gradient information");
never executed: return scope.engine->throwError(QString::fromUtf8("Not a valid CanvasGradient object, can't get the gradient information"));
0
3410 QGradient gradient = *(style->d()->brush->gradient());-
3411 qreal pos = argv[0].toNumber();-
3412 QColor color;-
3413-
3414 if (argv[1].as<Object>()) {
argv[1].as<Object>()Description
TRUEnever evaluated
FALSEnever evaluated
0
3415 color = scope.engine->toVariant(argv[1], qMetaTypeId<QColor>()).value<QColor>();-
3416 } else {
never executed: end of block
0
3417 color = qt_color_from_string(argv[1]);-
3418 }
never executed: end of block
0
3419 if (pos < 0.0 || pos > 1.0 || !qt_is_finite(pos)) {
pos < 0.0Description
TRUEnever evaluated
FALSEnever evaluated
pos > 1.0Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
3420 THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "CanvasGradient: parameter offset out of range");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
3421 }-
3422-
3423 if (color.isValid()) {
color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3424 gradient.setColorAt(pos, color);-
3425 } else {
never executed: end of block
0
3426 THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "CanvasGradient: parameter color is not a valid color string");
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
never executed: return scope.engine->throwError(ex);
0
3427 }-
3428 *style->d()->brush = gradient;-
3429 }
never executed: end of block
0
3430-
3431 return thisObject->asReturnedValue();
never executed: return thisObject->asReturnedValue();
0
3432}-
3433-
3434void QQuickContext2D::scale(qreal x, qreal y)-
3435{-
3436 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3437 return;
never executed: return;
0
3438-
3439 if (!qt_is_finite(x) || !qt_is_finite(y))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
3440 return;
never executed: return;
0
3441-
3442 QTransform newTransform = state.matrix;-
3443 newTransform.scale(x, y);-
3444-
3445 if (!newTransform.isInvertible()) {
!newTransform.isInvertible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3446 state.invertibleCTM = false;-
3447 return;
never executed: return;
0
3448 }-
3449-
3450 state.matrix = newTransform;-
3451 buffer()->updateMatrix(state.matrix);-
3452 m_path = QTransform().scale(1.0 / x, 1.0 / y).map(m_path);-
3453}
never executed: end of block
0
3454-
3455void QQuickContext2D::rotate(qreal angle)-
3456{-
3457 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3458 return;
never executed: return;
0
3459-
3460 if (!qt_is_finite(angle))
!qt_is_finite(angle)Description
TRUEnever evaluated
FALSEnever evaluated
0
3461 return;
never executed: return;
0
3462-
3463 QTransform newTransform =state.matrix;-
3464 newTransform.rotate(qRadiansToDegrees(angle));-
3465-
3466 if (!newTransform.isInvertible()) {
!newTransform.isInvertible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3467 state.invertibleCTM = false;-
3468 return;
never executed: return;
0
3469 }-
3470-
3471 state.matrix = newTransform;-
3472 buffer()->updateMatrix(state.matrix);-
3473 m_path = QTransform().rotate(-qRadiansToDegrees(angle)).map(m_path);-
3474}
never executed: end of block
0
3475-
3476void QQuickContext2D::shear(qreal h, qreal v)-
3477{-
3478 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3479 return;
never executed: return;
0
3480-
3481 if (!qt_is_finite(h) || !qt_is_finite(v))
!qt_is_finite(h)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(v)Description
TRUEnever evaluated
FALSEnever evaluated
0
3482 return ;
never executed: return ;
0
3483-
3484 QTransform newTransform = state.matrix;-
3485 newTransform.shear(h, v);-
3486-
3487 if (!newTransform.isInvertible()) {
!newTransform.isInvertible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3488 state.invertibleCTM = false;-
3489 return;
never executed: return;
0
3490 }-
3491-
3492 state.matrix = newTransform;-
3493 buffer()->updateMatrix(state.matrix);-
3494 m_path = QTransform().shear(-h, -v).map(m_path);-
3495}
never executed: end of block
0
3496-
3497void QQuickContext2D::translate(qreal x, qreal y)-
3498{-
3499 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3500 return;
never executed: return;
0
3501-
3502 if (!qt_is_finite(x) || !qt_is_finite(y))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
3503 return ;
never executed: return ;
0
3504-
3505 QTransform newTransform = state.matrix;-
3506 newTransform.translate(x, y);-
3507-
3508 if (!newTransform.isInvertible()) {
!newTransform.isInvertible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3509 state.invertibleCTM = false;-
3510 return;
never executed: return;
0
3511 }-
3512-
3513 state.matrix = newTransform;-
3514 buffer()->updateMatrix(state.matrix);-
3515 m_path = QTransform().translate(-x, -y).map(m_path);-
3516}
never executed: end of block
0
3517-
3518void QQuickContext2D::transform(qreal a, qreal b, qreal c, qreal d, qreal e, qreal f)-
3519{-
3520 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3521 return;
never executed: return;
0
3522-
3523 if (!qt_is_finite(a) || !qt_is_finite(b) || !qt_is_finite(c) || !qt_is_finite(d) || !qt_is_finite(e) || !qt_is_finite(f))
!qt_is_finite(a)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(b)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(c)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(d)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(e)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(f)Description
TRUEnever evaluated
FALSEnever evaluated
0
3524 return;
never executed: return;
0
3525-
3526 QTransform transform(a, b, c, d, e, f);-
3527 QTransform newTransform = state.matrix * transform;-
3528-
3529 if (!newTransform.isInvertible()) {
!newTransform.isInvertible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3530 state.invertibleCTM = false;-
3531 return;
never executed: return;
0
3532 }-
3533 state.matrix = newTransform;-
3534 buffer()->updateMatrix(state.matrix);-
3535 m_path = transform.inverted().map(m_path);-
3536}
never executed: end of block
0
3537-
3538void QQuickContext2D::setTransform(qreal a, qreal b, qreal c, qreal d, qreal e, qreal f)-
3539{-
3540 if (!qt_is_finite(a) || !qt_is_finite(b) || !qt_is_finite(c) || !qt_is_finite(d) || !qt_is_finite(e) || !qt_is_finite(f))
!qt_is_finite(a)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(b)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(c)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(d)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(e)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(f)Description
TRUEnever evaluated
FALSEnever evaluated
0
3541 return;
never executed: return;
0
3542-
3543 QTransform ctm = state.matrix;-
3544 if (!ctm.isInvertible())
!ctm.isInvertible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3545 return;
never executed: return;
0
3546-
3547 state.matrix = ctm.inverted() * state.matrix;-
3548 m_path = ctm.map(m_path);-
3549 state.invertibleCTM = true;-
3550 transform(a, b, c, d, e, f);-
3551}
never executed: end of block
0
3552-
3553void QQuickContext2D::fill()-
3554{-
3555 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3556 return;
never executed: return;
0
3557-
3558 if (!m_path.elementCount())
!m_path.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
3559 return;
never executed: return;
0
3560-
3561 m_path.setFillRule(state.fillRule);-
3562 buffer()->fill(m_path);-
3563}
never executed: end of block
0
3564-
3565void QQuickContext2D::clip()-
3566{-
3567 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3568 return;
never executed: return;
0
3569-
3570 QPainterPath clipPath = m_path;-
3571 clipPath.closeSubpath();-
3572 if (state.clip) {
state.clipDescription
TRUEnever evaluated
FALSEnever evaluated
0
3573 state.clipPath = clipPath.intersected(state.clipPath);-
3574 } else {
never executed: end of block
0
3575 state.clip = true;-
3576 state.clipPath = clipPath;-
3577 }
never executed: end of block
0
3578 buffer()->clip(state.clip, state.clipPath);-
3579}
never executed: end of block
0
3580-
3581void QQuickContext2D::stroke()-
3582{-
3583 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3584 return;
never executed: return;
0
3585-
3586 if (!m_path.elementCount())
!m_path.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
3587 return;
never executed: return;
0
3588-
3589 buffer()->stroke(m_path);-
3590}
never executed: end of block
0
3591-
3592void QQuickContext2D::fillRect(qreal x, qreal y, qreal w, qreal h)-
3593{-
3594 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3595 return;
never executed: return;
0
3596-
3597 if (!qt_is_finite(x) || !qt_is_finite(y) || !qt_is_finite(w) || !qt_is_finite(h))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(w)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(h)Description
TRUEnever evaluated
FALSEnever evaluated
0
3598 return;
never executed: return;
0
3599-
3600 buffer()->fillRect(QRectF(x, y, w, h));-
3601}
never executed: end of block
0
3602-
3603void QQuickContext2D::strokeRect(qreal x, qreal y, qreal w, qreal h)-
3604{-
3605 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3606 return;
never executed: return;
0
3607-
3608 if (!qt_is_finite(x) || !qt_is_finite(y) || !qt_is_finite(w) || !qt_is_finite(h))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(w)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(h)Description
TRUEnever evaluated
FALSEnever evaluated
0
3609 return;
never executed: return;
0
3610-
3611 buffer()->strokeRect(QRectF(x, y, w, h));-
3612}
never executed: end of block
0
3613-
3614void QQuickContext2D::clearRect(qreal x, qreal y, qreal w, qreal h)-
3615{-
3616 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3617 return;
never executed: return;
0
3618-
3619 if (!qt_is_finite(x) || !qt_is_finite(y) || !qt_is_finite(w) || !qt_is_finite(h))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(w)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(h)Description
TRUEnever evaluated
FALSEnever evaluated
0
3620 return;
never executed: return;
0
3621-
3622 buffer()->clearRect(QRectF(x, y, w, h));-
3623}
never executed: end of block
0
3624-
3625void QQuickContext2D::drawText(const QString& text, qreal x, qreal y, bool fill)-
3626{-
3627 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3628 return;
never executed: return;
0
3629-
3630 if (!qt_is_finite(x) || !qt_is_finite(y))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
3631 return;
never executed: return;
0
3632-
3633 QPainterPath textPath = createTextGlyphs(x, y, text);-
3634 if (fill)
fillDescription
TRUEnever evaluated
FALSEnever evaluated
0
3635 buffer()->fill(textPath);
never executed: buffer()->fill(textPath);
0
3636 else-
3637 buffer()->stroke(textPath);
never executed: buffer()->stroke(textPath);
0
3638}-
3639-
3640-
3641void QQuickContext2D::beginPath()-
3642{-
3643 if (!m_path.elementCount())
!m_path.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
3644 return;
never executed: return;
0
3645 m_path = QPainterPath();-
3646}
never executed: end of block
0
3647-
3648void QQuickContext2D::closePath()-
3649{-
3650 if (!m_path.elementCount())
!m_path.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
3651 return;
never executed: return;
0
3652-
3653 QRectF boundRect = m_path.boundingRect();-
3654 if (boundRect.width() || boundRect.height())
boundRect.width()Description
TRUEnever evaluated
FALSEnever evaluated
boundRect.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
3655 m_path.closeSubpath();
never executed: m_path.closeSubpath();
0
3656 //FIXME:QPainterPath set the current point to (0,0) after close subpath-
3657 //should be the first point of the previous subpath-
3658}
never executed: end of block
0
3659-
3660void QQuickContext2D::moveTo( qreal x, qreal y)-
3661{-
3662 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3663 return;
never executed: return;
0
3664-
3665 //FIXME: moveTo should not close the previous subpath-
3666 m_path.moveTo(QPointF(x, y));-
3667}
never executed: end of block
0
3668-
3669void QQuickContext2D::lineTo( qreal x, qreal y)-
3670{-
3671 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3672 return;
never executed: return;
0
3673-
3674 QPointF pt(x, y);-
3675-
3676 if (!m_path.elementCount())
!m_path.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
3677 m_path.moveTo(pt);
never executed: m_path.moveTo(pt);
0
3678 else if (m_path.currentPosition() != pt)
m_path.currentPosition() != ptDescription
TRUEnever evaluated
FALSEnever evaluated
0
3679 m_path.lineTo(pt);
never executed: m_path.lineTo(pt);
0
3680}
never executed: end of block
0
3681-
3682void QQuickContext2D::quadraticCurveTo(qreal cpx, qreal cpy,-
3683 qreal x, qreal y)-
3684{-
3685 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3686 return;
never executed: return;
0
3687-
3688 if (!m_path.elementCount())
!m_path.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
3689 m_path.moveTo(QPointF(cpx, cpy));
never executed: m_path.moveTo(QPointF(cpx, cpy));
0
3690-
3691 QPointF pt(x, y);-
3692 if (m_path.currentPosition() != pt)
m_path.currentPosition() != ptDescription
TRUEnever evaluated
FALSEnever evaluated
0
3693 m_path.quadTo(QPointF(cpx, cpy), pt);
never executed: m_path.quadTo(QPointF(cpx, cpy), pt);
0
3694}
never executed: end of block
0
3695-
3696void QQuickContext2D::bezierCurveTo(qreal cp1x, qreal cp1y,-
3697 qreal cp2x, qreal cp2y,-
3698 qreal x, qreal y)-
3699{-
3700 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3701 return;
never executed: return;
0
3702-
3703 if (!m_path.elementCount())
!m_path.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
3704 m_path.moveTo(QPointF(cp1x, cp1y));
never executed: m_path.moveTo(QPointF(cp1x, cp1y));
0
3705-
3706 QPointF pt(x, y);-
3707 if (m_path.currentPosition() != pt)
m_path.currentPosition() != ptDescription
TRUEnever evaluated
FALSEnever evaluated
0
3708 m_path.cubicTo(QPointF(cp1x, cp1y), QPointF(cp2x, cp2y), pt);
never executed: m_path.cubicTo(QPointF(cp1x, cp1y), QPointF(cp2x, cp2y), pt);
0
3709}
never executed: end of block
0
3710-
3711void QQuickContext2D::addArcTo(const QPointF& p1, const QPointF& p2, float radius)-
3712{-
3713 QPointF p0(m_path.currentPosition());-
3714-
3715 QPointF p1p0((p0.x() - p1.x()), (p0.y() - p1.y()));-
3716 QPointF p1p2((p2.x() - p1.x()), (p2.y() - p1.y()));-
3717 float p1p0_length = std::sqrt(p1p0.x() * p1p0.x() + p1p0.y() * p1p0.y());-
3718 float p1p2_length = std::sqrt(p1p2.x() * p1p2.x() + p1p2.y() * p1p2.y());-
3719-
3720 double cos_phi = (p1p0.x() * p1p2.x() + p1p0.y() * p1p2.y()) / (p1p0_length * p1p2_length);-
3721-
3722 // The points p0, p1, and p2 are on the same straight line (HTML5, 4.8.11.1.8)-
3723 // We could have used areCollinear() here, but since we're reusing-
3724 // the variables computed above later on we keep this logic.-
3725 if (qFuzzyCompare(std::abs(cos_phi), 1.0)) {
qFuzzyCompare(...cos_phi), 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
3726 m_path.lineTo(p1);-
3727 return;
never executed: return;
0
3728 }-
3729-
3730 float tangent = radius / std::tan(std::acos(cos_phi) / 2);-
3731 float factor_p1p0 = tangent / p1p0_length;-
3732 QPointF t_p1p0((p1.x() + factor_p1p0 * p1p0.x()), (p1.y() + factor_p1p0 * p1p0.y()));-
3733-
3734 QPointF orth_p1p0(p1p0.y(), -p1p0.x());-
3735 float orth_p1p0_length = std::sqrt(orth_p1p0.x() * orth_p1p0.x() + orth_p1p0.y() * orth_p1p0.y());-
3736 float factor_ra = radius / orth_p1p0_length;-
3737-
3738 // angle between orth_p1p0 and p1p2 to get the right vector orthographic to p1p0-
3739 double cos_alpha = (orth_p1p0.x() * p1p2.x() + orth_p1p0.y() * p1p2.y()) / (orth_p1p0_length * p1p2_length);-
3740 if (cos_alpha < 0.f)
cos_alpha < 0.fDescription
TRUEnever evaluated
FALSEnever evaluated
0
3741 orth_p1p0 = QPointF(-orth_p1p0.x(), -orth_p1p0.y());
never executed: orth_p1p0 = QPointF(-orth_p1p0.x(), -orth_p1p0.y());
0
3742-
3743 QPointF p((t_p1p0.x() + factor_ra * orth_p1p0.x()), (t_p1p0.y() + factor_ra * orth_p1p0.y()));-
3744-
3745 // calculate angles for addArc-
3746 orth_p1p0 = QPointF(-orth_p1p0.x(), -orth_p1p0.y());-
3747 float sa = std::acos(orth_p1p0.x() / orth_p1p0_length);-
3748 if (orth_p1p0.y() < 0.f)
orth_p1p0.y() < 0.fDescription
TRUEnever evaluated
FALSEnever evaluated
0
3749 sa = 2 * M_PI - sa;
never executed: sa = 2 * 3.14159265358979323846 - sa;
0
3750-
3751 // anticlockwise logic-
3752 bool anticlockwise = false;-
3753-
3754 float factor_p1p2 = tangent / p1p2_length;-
3755 QPointF t_p1p2((p1.x() + factor_p1p2 * p1p2.x()), (p1.y() + factor_p1p2 * p1p2.y()));-
3756 QPointF orth_p1p2((t_p1p2.x() - p.x()), (t_p1p2.y() - p.y()));-
3757 float orth_p1p2_length = std::sqrt(orth_p1p2.x() * orth_p1p2.x() + orth_p1p2.y() * orth_p1p2.y());-
3758 float ea = std::acos(orth_p1p2.x() / orth_p1p2_length);-
3759 if (orth_p1p2.y() < 0)
orth_p1p2.y() < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3760 ea = 2 * M_PI - ea;
never executed: ea = 2 * 3.14159265358979323846 - ea;
0
3761 if ((sa > ea) && ((sa - ea) < M_PI))
(sa > ea)Description
TRUEnever evaluated
FALSEnever evaluated
((sa - ea) < 3...358979323846 )Description
TRUEnever evaluated
FALSEnever evaluated
0
3762 anticlockwise = true;
never executed: anticlockwise = true;
0
3763 if ((sa < ea) && ((ea - sa) > M_PI))
(sa < ea)Description
TRUEnever evaluated
FALSEnever evaluated
((ea - sa) > 3...358979323846 )Description
TRUEnever evaluated
FALSEnever evaluated
0
3764 anticlockwise = true;
never executed: anticlockwise = true;
0
3765-
3766 arc(p.x(), p.y(), radius, sa, ea, anticlockwise);-
3767}
never executed: end of block
0
3768-
3769void QQuickContext2D::arcTo(qreal x1, qreal y1,-
3770 qreal x2, qreal y2,-
3771 qreal radius)-
3772{-
3773 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3774 return;
never executed: return;
0
3775-
3776 if (!qt_is_finite(x1) || !qt_is_finite(y1) || !qt_is_finite(x2) || !qt_is_finite(y2) || !qt_is_finite(radius))
!qt_is_finite(x1)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y1)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(x2)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y2)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(radius)Description
TRUEnever evaluated
FALSEnever evaluated
0
3777 return;
never executed: return;
0
3778-
3779 QPointF st(x1, y1);-
3780 QPointF end(x2, y2);-
3781-
3782 if (!m_path.elementCount())
!m_path.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
3783 m_path.moveTo(st);
never executed: m_path.moveTo(st);
0
3784 else if (st == m_path.currentPosition() || st == end || !radius)
st == m_path.currentPosition()Description
TRUEnever evaluated
FALSEnever evaluated
st == endDescription
TRUEnever evaluated
FALSEnever evaluated
!radiusDescription
TRUEnever evaluated
FALSEnever evaluated
0
3785 lineTo(x1, y1);
never executed: lineTo(x1, y1);
0
3786 else-
3787 addArcTo(st, end, radius);
never executed: addArcTo(st, end, radius);
0
3788 }-
3789-
3790void QQuickContext2D::rect(qreal x, qreal y, qreal w, qreal h)-
3791{-
3792 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3793 return;
never executed: return;
0
3794 if (!qt_is_finite(x) || !qt_is_finite(y) || !qt_is_finite(w) || !qt_is_finite(h))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(w)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(h)Description
TRUEnever evaluated
FALSEnever evaluated
0
3795 return;
never executed: return;
0
3796-
3797 if (!w && !h) {
!wDescription
TRUEnever evaluated
FALSEnever evaluated
!hDescription
TRUEnever evaluated
FALSEnever evaluated
0
3798 m_path.moveTo(x, y);-
3799 return;
never executed: return;
0
3800 }-
3801 m_path.addRect(x, y, w, h);-
3802}
never executed: end of block
0
3803-
3804void QQuickContext2D::roundedRect(qreal x, qreal y,-
3805 qreal w, qreal h,-
3806 qreal xr, qreal yr)-
3807{-
3808 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3809 return;
never executed: return;
0
3810-
3811 if (!qt_is_finite(x) || !qt_is_finite(y) || !qt_is_finite(w) || !qt_is_finite(h) || !qt_is_finite(xr) || !qt_is_finite(yr))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(w)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(h)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(xr)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(yr)Description
TRUEnever evaluated
FALSEnever evaluated
0
3812 return;
never executed: return;
0
3813-
3814 if (!w && !h) {
!wDescription
TRUEnever evaluated
FALSEnever evaluated
!hDescription
TRUEnever evaluated
FALSEnever evaluated
0
3815 m_path.moveTo(x, y);-
3816 return;
never executed: return;
0
3817 }-
3818 m_path.addRoundedRect(QRectF(x, y, w, h), xr, yr, Qt::AbsoluteSize);-
3819}
never executed: end of block
0
3820-
3821void QQuickContext2D::ellipse(qreal x, qreal y,-
3822 qreal w, qreal h)-
3823{-
3824 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3825 return;
never executed: return;
0
3826-
3827 if (!qt_is_finite(x) || !qt_is_finite(y) || !qt_is_finite(w) || !qt_is_finite(h))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(w)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(h)Description
TRUEnever evaluated
FALSEnever evaluated
0
3828 return;
never executed: return;
0
3829-
3830 if (!w && !h) {
!wDescription
TRUEnever evaluated
FALSEnever evaluated
!hDescription
TRUEnever evaluated
FALSEnever evaluated
0
3831 m_path.moveTo(x, y);-
3832 return;
never executed: return;
0
3833 }-
3834-
3835 m_path.addEllipse(x, y, w, h);-
3836}
never executed: end of block
0
3837-
3838void QQuickContext2D::text(const QString& str, qreal x, qreal y)-
3839{-
3840 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3841 return;
never executed: return;
0
3842-
3843 QPainterPath path;-
3844 path.addText(x, y, state.font, str);-
3845 m_path.addPath(path);-
3846}
never executed: end of block
0
3847-
3848void QQuickContext2D::arc(qreal xc, qreal yc, qreal radius, qreal sar, qreal ear, bool antiClockWise)-
3849{-
3850 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3851 return;
never executed: return;
0
3852-
3853 if (!qt_is_finite(xc) || !qt_is_finite(yc) || !qt_is_finite(sar) || !qt_is_finite(ear) || !qt_is_finite(radius))
!qt_is_finite(xc)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(yc)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(sar)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(ear)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(radius)Description
TRUEnever evaluated
FALSEnever evaluated
0
3854 return;
never executed: return;
0
3855-
3856 if (sar == ear)
sar == earDescription
TRUEnever evaluated
FALSEnever evaluated
0
3857 return;
never executed: return;
0
3858-
3859-
3860 //### HACK-
3861-
3862 // In Qt we don't switch the coordinate system for degrees-
3863 // and still use the 0,0 as bottom left for degrees so we need-
3864 // to switch-
3865 sar = -sar;-
3866 ear = -ear;-
3867 antiClockWise = !antiClockWise;-
3868 //end hack-
3869-
3870 float sa = qRadiansToDegrees(sar);-
3871 float ea = qRadiansToDegrees(ear);-
3872-
3873 double span = 0;-
3874-
3875 double xs = xc - radius;-
3876 double ys = yc - radius;-
3877 double width = radius*2;-
3878 double height = radius*2;-
3879 if ((!antiClockWise && (ea - sa >= 360)) || (antiClockWise && (sa - ea >= 360)))
!antiClockWiseDescription
TRUEnever evaluated
FALSEnever evaluated
(ea - sa >= 360)Description
TRUEnever evaluated
FALSEnever evaluated
antiClockWiseDescription
TRUEnever evaluated
FALSEnever evaluated
(sa - ea >= 360)Description
TRUEnever evaluated
FALSEnever evaluated
0
3880 // If the anticlockwise argument is false and endAngle-startAngle is equal to or greater than 2*PI, or, if the-
3881 // anticlockwise argument is true and startAngle-endAngle is equal to or greater than 2*PI, then the arc is the whole-
3882 // circumference of this circle.-
3883 span = 360;
never executed: span = 360;
0
3884 else {-
3885 if (!antiClockWise && (ea < sa)) {
!antiClockWiseDescription
TRUEnever evaluated
FALSEnever evaluated
(ea < sa)Description
TRUEnever evaluated
FALSEnever evaluated
0
3886 span += 360;-
3887 } else if (antiClockWise && (sa < ea)) {
never executed: end of block
antiClockWiseDescription
TRUEnever evaluated
FALSEnever evaluated
(sa < ea)Description
TRUEnever evaluated
FALSEnever evaluated
0
3888 span -= 360;-
3889 }
never executed: end of block
0
3890 //### this is also due to switched coordinate system-
3891 // we would end up with a 0 span instead of 360-
3892 if (!(qFuzzyCompare(span + (ea - sa) + 1, 1) &&
qFuzzyCompare(... - sa) + 1, 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
3893 qFuzzyCompare(qAbs(span), 360))) {
qFuzzyCompare(qAbs(span), 360)Description
TRUEnever evaluated
FALSEnever evaluated
0
3894 span += ea - sa;-
3895 }
never executed: end of block
0
3896 }
never executed: end of block
0
3897-
3898 // If the path is empty, move to where the arc will start to avoid painting a line from (0,0)-
3899 if (!m_path.elementCount())
!m_path.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
3900 m_path.arcMoveTo(xs, ys, width, height, sa);
never executed: m_path.arcMoveTo(xs, ys, width, height, sa);
0
3901 else if (!radius) {
!radiusDescription
TRUEnever evaluated
FALSEnever evaluated
0
3902 m_path.lineTo(xc, yc);-
3903 return;
never executed: return;
0
3904 }-
3905-
3906 m_path.arcTo(xs, ys, width, height, sa, span);-
3907}
never executed: end of block
0
3908-
3909int baseLineOffset(QQuickContext2D::TextBaseLineType value, const QFontMetrics &metrics)-
3910{-
3911 int offset = 0;-
3912 switch (value) {-
3913 case QQuickContext2D::Top:
never executed: case QQuickContext2D::Top:
0
3914 case QQuickContext2D::Hanging:
never executed: case QQuickContext2D::Hanging:
0
3915 break;
never executed: break;
0
3916 case QQuickContext2D::Middle:
never executed: case QQuickContext2D::Middle:
0
3917 offset = (metrics.ascent() >> 1) + metrics.height() - metrics.ascent();-
3918 break;
never executed: break;
0
3919 case QQuickContext2D::Alphabetic:
never executed: case QQuickContext2D::Alphabetic:
0
3920 offset = metrics.ascent();-
3921 break;
never executed: break;
0
3922 case QQuickContext2D::Bottom:
never executed: case QQuickContext2D::Bottom:
0
3923 offset = metrics.height();-
3924 break;
never executed: break;
0
3925 }-
3926 return offset;
never executed: return offset;
0
3927}-
3928-
3929static int textAlignOffset(QQuickContext2D::TextAlignType value, const QFontMetrics &metrics, const QString &text)-
3930{-
3931 int offset = 0;-
3932 if (value == QQuickContext2D::Start)
value == QQuic...ntext2D::StartDescription
TRUEnever evaluated
FALSEnever evaluated
0
3933 value = QGuiApplication::layoutDirection() == Qt::LeftToRight ? QQuickContext2D::Left : QQuickContext2D::Right;
never executed: value = QGuiApplication::layoutDirection() == Qt::LeftToRight ? QQuickContext2D::Left : QQuickContext2D::Right;
QGuiApplicatio...t::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3934 else if (value == QQuickContext2D::End)
value == QQuickContext2D::EndDescription
TRUEnever evaluated
FALSEnever evaluated
0
3935 value = QGuiApplication::layoutDirection() == Qt::LeftToRight ? QQuickContext2D::Right: QQuickContext2D::Left;
never executed: value = QGuiApplication::layoutDirection() == Qt::LeftToRight ? QQuickContext2D::Right: QQuickContext2D::Left;
QGuiApplicatio...t::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3936 switch (value) {-
3937 case QQuickContext2D::Center:
never executed: case QQuickContext2D::Center:
0
3938 offset = metrics.width(text)/2;-
3939 break;
never executed: break;
0
3940 case QQuickContext2D::Right:
never executed: case QQuickContext2D::Right:
0
3941 offset = metrics.width(text);-
3942 case QQuickContext2D::Left:
code before this statement never executed: case QQuickContext2D::Left:
never executed: case QQuickContext2D::Left:
0
3943 default:
never executed: default:
0
3944 break;
never executed: break;
0
3945 }-
3946 return offset;
never executed: return offset;
0
3947}-
3948-
3949void QQuickContext2D::setGrabbedImage(const QImage& grab)-
3950{-
3951 m_grabbedImage = grab;-
3952 m_grabbed = true;-
3953}
never executed: end of block
0
3954-
3955QQmlRefPointer<QQuickCanvasPixmap> QQuickContext2D::createPixmap(const QUrl& url)-
3956{-
3957 return m_canvas->loadedPixmap(url);
never executed: return m_canvas->loadedPixmap(url);
0
3958}-
3959-
3960QPainterPath QQuickContext2D::createTextGlyphs(qreal x, qreal y, const QString& text)-
3961{-
3962 const QFontMetrics metrics(state.font);-
3963 int yoffset = baseLineOffset(static_cast<QQuickContext2D::TextBaseLineType>(state.textBaseline), metrics);-
3964 int xoffset = textAlignOffset(static_cast<QQuickContext2D::TextAlignType>(state.textAlign), metrics, text);-
3965-
3966 QPainterPath textPath;-
3967-
3968 textPath.addText(x - xoffset, y - yoffset+metrics.ascent(), state.font, text);-
3969 return textPath;
never executed: return textPath;
0
3970}-
3971-
3972-
3973static inline bool areCollinear(const QPointF& a, const QPointF& b, const QPointF& c)-
3974{-
3975 // Solved from comparing the slopes of a to b and b to c: (ay-by)/(ax-bx) == (cy-by)/(cx-bx)-
3976 return qFuzzyCompare((c.y() - b.y()) * (a.x() - b.x()), (a.y() - b.y()) * (c.x() - b.x()));
never executed: return qFuzzyCompare((c.y() - b.y()) * (a.x() - b.x()), (a.y() - b.y()) * (c.x() - b.x()));
0
3977}-
3978-
3979static inline bool withinRange(qreal p, qreal a, qreal b)-
3980{-
3981 return (p >= a && p <= b) || (p >= b && p <= a);
never executed: return (p >= a && p <= b) || (p >= b && p <= a);
0
3982}-
3983-
3984bool QQuickContext2D::isPointInPath(qreal x, qreal y) const-
3985{-
3986 if (!state.invertibleCTM)
!state.invertibleCTMDescription
TRUEnever evaluated
FALSEnever evaluated
0
3987 return false;
never executed: return false;
0
3988-
3989 if (!m_path.elementCount())
!m_path.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
3990 return false;
never executed: return false;
0
3991-
3992 if (!qt_is_finite(x) || !qt_is_finite(y))
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
3993 return false;
never executed: return false;
0
3994-
3995 QPointF point(x, y);-
3996 QTransform ctm = state.matrix;-
3997 QPointF p = ctm.inverted().map(point);-
3998 if (!qt_is_finite(p.x()) || !qt_is_finite(p.y()))
!qt_is_finite(p.x())Description
TRUEnever evaluated
FALSEnever evaluated
!qt_is_finite(p.y())Description
TRUEnever evaluated
FALSEnever evaluated
0
3999 return false;
never executed: return false;
0
4000-
4001 const_cast<QQuickContext2D *>(this)->m_path.setFillRule(state.fillRule);-
4002-
4003 bool contains = m_path.contains(p);-
4004-
4005 if (!contains) {
!containsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4006 // check whether the point is on the border-
4007 QPolygonF border = m_path.toFillPolygon();-
4008-
4009 QPointF p1 = border.at(0);-
4010 QPointF p2;-
4011-
4012 for (int i = 1; i < border.size(); ++i) {
i < border.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4013 p2 = border.at(i);-
4014 if (areCollinear(p, p1, p2)
areCollinear(p, p1, p2)Description
TRUEnever evaluated
FALSEnever evaluated
0
4015 // Once we know that the points are collinear we-
4016 // only need to check one of the coordinates-
4017 && (qAbs(p2.x() - p1.x()) > qAbs(p2.y() - p1.y()) ?
qAbs(p2.x() - ....y() - p1.y())Description
TRUEnever evaluated
FALSEnever evaluated
(qAbs(p2.x() -....y(), p2.y()))Description
TRUEnever evaluated
FALSEnever evaluated
0
4018 withinRange(p.x(), p1.x(), p2.x()) :
(qAbs(p2.x() -....y(), p2.y()))Description
TRUEnever evaluated
FALSEnever evaluated
0
4019 withinRange(p.y(), p1.y(), p2.y()))) {
(qAbs(p2.x() -....y(), p2.y()))Description
TRUEnever evaluated
FALSEnever evaluated
0
4020 return true;
never executed: return true;
0
4021 }-
4022 p1 = p2;-
4023 }
never executed: end of block
0
4024 }
never executed: end of block
0
4025 return contains;
never executed: return contains;
0
4026}-
4027-
4028class QQuickContext2DThreadCleanup : public QObject-
4029{-
4030public:-
4031 QQuickContext2DThreadCleanup(QOpenGLContext *gl, QQuickContext2DTexture *t, QOffscreenSurface *s)-
4032 : context(gl), texture(t), surface(s)-
4033 { }
never executed: end of block
0
4034-
4035 ~QQuickContext2DThreadCleanup()-
4036 {-
4037#if QT_CONFIG(opengl)-
4038 context->makeCurrent(surface);-
4039 delete texture;-
4040 context->doneCurrent();-
4041 delete context;-
4042#endif-
4043 surface->deleteLater();-
4044 }
never executed: end of block
0
4045-
4046 QOpenGLContext *context;-
4047 QQuickContext2DTexture *texture;-
4048 QOffscreenSurface *surface;-
4049};-
4050-
4051class QQuickContext2DTextureCleanup : public QRunnable-
4052{-
4053public:-
4054 QQuickContext2DTexture *texture;-
4055 void run() override { delete texture; }
never executed: end of block
0
4056};-
4057-
4058QMutex QQuickContext2D::mutex;-
4059-
4060QQuickContext2D::QQuickContext2D(QObject *parent)-
4061 : QQuickCanvasContext(parent)-
4062 , m_buffer(new QQuickContext2DCommandBuffer)-
4063 , m_v4engine(nullptr)-
4064 , m_surface(nullptr)-
4065 , m_glContext(nullptr)-
4066 , m_thread(nullptr)-
4067 , m_grabbed(false)-
4068{-
4069}
never executed: end of block
0
4070-
4071QQuickContext2D::~QQuickContext2D()-
4072{-
4073 mutex.lock();-
4074 m_texture->setItem(nullptr);-
4075 delete m_buffer;-
4076-
4077 if (m_renderTarget == QQuickCanvasItem::FramebufferObject) {
m_renderTarget...mebufferObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4078#if QT_CONFIG(opengl)-
4079 if (m_renderStrategy == QQuickCanvasItem::Immediate && m_glContext) {
m_renderStrate...tem::ImmediateDescription
TRUEnever evaluated
FALSEnever evaluated
m_glContextDescription
TRUEnever evaluated
FALSEnever evaluated
0
4080 Q_ASSERT(QThread::currentThread() == m_glContext->thread());-
4081 m_glContext->makeCurrent(m_surface.data());-
4082 delete m_texture;-
4083 m_glContext->doneCurrent();-
4084 delete m_glContext;-
4085 } else if (m_texture->isOnCustomThread()) {
never executed: end of block
m_texture->isOnCustomThread()Description
TRUEnever evaluated
FALSEnever evaluated
0
4086 Q_ASSERT(m_glContext);-
4087 QQuickContext2DThreadCleanup *cleaner = new QQuickContext2DThreadCleanup(m_glContext, m_texture, m_surface.take());-
4088 cleaner->moveToThread(m_texture->thread());-
4089 cleaner->deleteLater();-
4090 } else {
never executed: end of block
0
4091 if (m_canvas->window()) {
m_canvas->window()Description
TRUEnever evaluated
FALSEnever evaluated
0
4092 QQuickContext2DTextureCleanup *c = new QQuickContext2DTextureCleanup;-
4093 c->texture = m_texture;-
4094 m_canvas->window()->scheduleRenderJob(c, QQuickWindow::AfterSynchronizingStage);-
4095 } else {
never executed: end of block
0
4096 m_texture->deleteLater();-
4097 }
never executed: end of block
0
4098 }-
4099#endif-
4100 } else {-
4101 // Image based does not have GL resources, but must still be deleted-
4102 // on its designated thread after it has completed whatever it might-
4103 // currently be doing.-
4104 m_texture->deleteLater();-
4105 }
never executed: end of block
0
4106 mutex.unlock();-
4107}
never executed: end of block
0
4108-
4109QV4::ReturnedValue QQuickContext2D::v4value() const-
4110{-
4111 return m_v4value.value();
never executed: return m_v4value.value();
0
4112}-
4113-
4114QStringList QQuickContext2D::contextNames() const-
4115{-
4116 return QStringList() << QStringLiteral("2d");
never executed: return QStringList() << ([]() noexcept -> QString { enum { Size = sizeof(u"" "2d")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "2d" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
4117}-
4118-
4119void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args)-
4120{-
4121 Q_UNUSED(args);-
4122-
4123 m_canvas = canvasItem;-
4124 m_renderTarget = canvasItem->renderTarget();-
4125 m_renderStrategy = canvasItem->renderStrategy();-
4126-
4127#ifdef Q_OS_WIN-
4128 if (m_renderTarget == QQuickCanvasItem::FramebufferObject-
4129 && (m_renderStrategy != QQuickCanvasItem::Cooperative)) {-
4130 // On windows a context needs to be unbound set up sharing, so-
4131 // for simplicity we disallow FBO + !coop here.-
4132 m_renderTarget = QQuickCanvasItem::Image;-
4133 }-
4134#endif-
4135-
4136 // Disable threaded background rendering if the platform has issues with it-
4137 if (m_renderTarget == QQuickCanvasItem::FramebufferObject
m_renderTarget...mebufferObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4138 && m_renderStrategy == QQuickCanvasItem::Threaded
m_renderStrate...Item::ThreadedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4139 && !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL)) {
!QGuiApplicati...hreadedOpenGL)Description
TRUEnever evaluated
FALSEnever evaluated
0
4140 m_renderTarget = QQuickCanvasItem::Image;-
4141 }
never executed: end of block
0
4142-
4143 // Disable Framebuffer Object based rendering when not running with OpenGL-
4144 if (m_renderTarget == QQuickCanvasItem::FramebufferObject) {
m_renderTarget...mebufferObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4145 QSGRendererInterface *rif = canvasItem->window()->rendererInterface();-
4146 if (rif && rif->graphicsApi() != QSGRendererInterface::OpenGL)
rifDescription
TRUEnever evaluated
FALSEnever evaluated
rif->graphicsA...erface::OpenGLDescription
TRUEnever evaluated
FALSEnever evaluated
0
4147 m_renderTarget = QQuickCanvasItem::Image;
never executed: m_renderTarget = QQuickCanvasItem::Image;
0
4148 }
never executed: end of block
0
4149-
4150 switch (m_renderTarget) {-
4151 case QQuickCanvasItem::Image:
never executed: case QQuickCanvasItem::Image:
0
4152 m_texture = new QQuickContext2DImageTexture;-
4153 break;
never executed: break;
0
4154 case QQuickCanvasItem::FramebufferObject:
never executed: case QQuickCanvasItem::FramebufferObject:
0
4155#if QT_CONFIG(opengl)-
4156 m_texture = new QQuickContext2DFBOTexture;-
4157#else-
4158 // It shouldn't be possible to use a FramebufferObject without OpenGL-
4159 m_texture = nullptr;-
4160#endif-
4161 break;
never executed: break;
0
4162 }-
4163-
4164 m_texture->setItem(canvasItem);-
4165 m_texture->setCanvasWindow(canvasItem->canvasWindow().toRect());-
4166 m_texture->setTileSize(canvasItem->tileSize());-
4167 m_texture->setCanvasSize(canvasItem->canvasSize().toSize());-
4168 m_texture->setSmooth(canvasItem->smooth());-
4169 m_texture->setAntialiasing(canvasItem->antialiasing());-
4170 m_texture->setOnCustomThread(m_renderStrategy == QQuickCanvasItem::Threaded);-
4171 m_thread = QThread::currentThread();-
4172-
4173 QThread *renderThread = m_thread;-
4174#if QT_CONFIG(opengl)-
4175 QQuickWindow *window = canvasItem->window();-
4176 QQuickWindowPrivate *wd = QQuickWindowPrivate::get(window);-
4177 QThread *sceneGraphThread = wd->context->thread();-
4178-
4179 if (m_renderStrategy == QQuickCanvasItem::Threaded)
m_renderStrate...Item::ThreadedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4180 renderThread = QQuickContext2DRenderThread::instance(qmlEngine(canvasItem));
never executed: renderThread = QQuickContext2DRenderThread::instance(qmlEngine(canvasItem));
0
4181 else if (m_renderStrategy == QQuickCanvasItem::Cooperative)
m_renderStrate...m::CooperativeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4182 renderThread = sceneGraphThread;
never executed: renderThread = sceneGraphThread;
0
4183#else-
4184 if (m_renderStrategy == QQuickCanvasItem::Threaded)-
4185 renderThread = QQuickContext2DRenderThread::instance(qmlEngine(canvasItem));-
4186#endif-
4187-
4188-
4189 if (renderThread && renderThread != QThread::currentThread())
renderThreadDescription
TRUEnever evaluated
FALSEnever evaluated
renderThread !...urrentThread()Description
TRUEnever evaluated
FALSEnever evaluated
0
4190 m_texture->moveToThread(renderThread);
never executed: m_texture->moveToThread(renderThread);
0
4191#if QT_CONFIG(opengl)-
4192 if (m_renderTarget == QQuickCanvasItem::FramebufferObject && renderThread != sceneGraphThread) {
m_renderTarget...mebufferObjectDescription
TRUEnever evaluated
FALSEnever evaluated
renderThread !...eneGraphThreadDescription
TRUEnever evaluated
FALSEnever evaluated
0
4193 auto openglRenderContext = static_cast<const QSGDefaultRenderContext *>(QQuickWindowPrivate::get(window)->context);-
4194 QOpenGLContext *cc = openglRenderContext->openglContext();-
4195 m_surface.reset(new QOffscreenSurface);-
4196 m_surface->setFormat(window->format());-
4197 m_surface->create();-
4198 m_glContext = new QOpenGLContext;-
4199 m_glContext->setFormat(cc->format());-
4200 m_glContext->setShareContext(cc);-
4201 if (renderThread != QThread::currentThread())
renderThread !...urrentThread()Description
TRUEnever evaluated
FALSEnever evaluated
0
4202 m_glContext->moveToThread(renderThread);
never executed: m_glContext->moveToThread(renderThread);
0
4203 m_texture->initializeOpenGL(m_glContext, m_surface.data());-
4204 }
never executed: end of block
0
4205#endif-
4206 connect(m_texture, SIGNAL(textureChanged()), SIGNAL(textureChanged()));-
4207-
4208 reset();-
4209}
never executed: end of block
0
4210-
4211void QQuickContext2D::prepare(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth, bool antialiasing)-
4212{-
4213 if (m_texture->thread() == QThread::currentThread()) {
m_texture->thr...urrentThread()Description
TRUEnever evaluated
FALSEnever evaluated
0
4214 m_texture->canvasChanged(canvasSize, tileSize, canvasWindow, dirtyRect, smooth, antialiasing);-
4215 } else {
never executed: end of block
0
4216 QEvent *e = new QQuickContext2DTexture::CanvasChangeEvent(canvasSize,-
4217 tileSize,-
4218 canvasWindow,-
4219 dirtyRect,-
4220 smooth,-
4221 antialiasing);-
4222 QCoreApplication::postEvent(m_texture, e);-
4223 }
never executed: end of block
0
4224}-
4225-
4226void QQuickContext2D::flush()-
4227{-
4228 if (m_buffer) {
m_bufferDescription
TRUEnever evaluated
FALSEnever evaluated
0
4229 if (m_texture->thread() == QThread::currentThread())
m_texture->thr...urrentThread()Description
TRUEnever evaluated
FALSEnever evaluated
0
4230 m_texture->paint(m_buffer);
never executed: m_texture->paint(m_buffer);
0
4231 else-
4232 QCoreApplication::postEvent(m_texture, new QQuickContext2DTexture::PaintEvent(m_buffer));
never executed: QCoreApplication::postEvent(m_texture, new QQuickContext2DTexture::PaintEvent(m_buffer));
0
4233 }-
4234 m_buffer = new QQuickContext2DCommandBuffer();-
4235}
never executed: end of block
0
4236-
4237QQuickContext2DTexture *QQuickContext2D::texture() const-
4238{-
4239 return m_texture;
never executed: return m_texture;
0
4240}-
4241-
4242QImage QQuickContext2D::toImage(const QRectF& bounds)-
4243{-
4244 if (m_texture->thread() == QThread::currentThread()) {
m_texture->thr...urrentThread()Description
TRUEnever evaluated
FALSEnever evaluated
0
4245 // if we're either not rendering to an fbo or we have a separate opengl context we can just-
4246 // flush. Otherwise we have to make sure the shared opengl context is current before we do-
4247 // so. It may or may not be current already, depending on how this method is called.-
4248 if (m_renderTarget != QQuickCanvasItem::FramebufferObject || m_glContext) {
m_renderTarget...mebufferObjectDescription
TRUEnever evaluated
FALSEnever evaluated
m_glContextDescription
TRUEnever evaluated
FALSEnever evaluated
0
4249 flush();-
4250 m_texture->grabImage(bounds);-
4251 } else {
never executed: end of block
0
4252#if QT_CONFIG(opengl)-
4253 QQuickWindow *window = m_canvas->window();-
4254 QOpenGLContext *ctx = window ? window->openglContext() : nullptr;
windowDescription
TRUEnever evaluated
FALSEnever evaluated
0
4255 if (ctx && ctx->isValid()) {
ctxDescription
TRUEnever evaluated
FALSEnever evaluated
ctx->isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
4256 if (ctx == QOpenGLContext::currentContext()) {
ctx == QOpenGL...rrentContext()Description
TRUEnever evaluated
FALSEnever evaluated
0
4257 flush();-
4258 } else {
never executed: end of block
0
4259 ctx->makeCurrent(window);-
4260 flush();-
4261 ctx->doneCurrent();-
4262 }
never executed: end of block
0
4263 m_texture->grabImage(bounds);-
4264 } else {
never executed: end of block
0
4265 qWarning() << "Cannot read pixels from canvas before opengl context is valid";-
4266 return QImage();
never executed: return QImage();
0
4267 }-
4268#else-
4269 flush();-
4270 m_texture->grabImage(bounds);-
4271#endif-
4272 }-
4273 } else if (m_renderStrategy == QQuickCanvasItem::Cooperative) {
m_renderStrate...m::CooperativeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4274 qWarning() << "Pixel readback is not supported in Cooperative mode, please try Threaded or Immediate mode";-
4275 return QImage();
never executed: return QImage();
0
4276 } else {-
4277 flush();-
4278 QCoreApplication::postEvent(m_texture, new QEvent(QEvent::Type(QEvent::User + 10)));-
4279 QMetaObject::invokeMethod(m_texture,-
4280 "grabImage",-
4281 Qt::BlockingQueuedConnection,-
4282 Q_ARG(QRectF, bounds));-
4283 }
never executed: end of block
0
4284 QImage img = m_grabbedImage;-
4285 m_grabbedImage = QImage();-
4286 m_grabbed = false;-
4287 return img;
never executed: return img;
0
4288}-
4289-
4290-
4291QQuickContext2DEngineData::QQuickContext2DEngineData(QV4::ExecutionEngine *v4)-
4292{-
4293 QV4::Scope scope(v4);-
4294-
4295 QV4::ScopedObject proto(scope, QQuickJSContext2DPrototype::create(v4));-
4296 proto->defineAccessorProperty(QStringLiteral("strokeStyle"), QQuickJSContext2D::method_get_strokeStyle, QQuickJSContext2D::method_set_strokeStyle);
never executed: return qstring_literal_temp;
0
4297 proto->defineAccessorProperty(QStringLiteral("font"), QQuickJSContext2D::method_get_font, QQuickJSContext2D::method_set_font);
never executed: return qstring_literal_temp;
0
4298 proto->defineAccessorProperty(QStringLiteral("fillRule"), QQuickJSContext2D::method_get_fillRule, QQuickJSContext2D::method_set_fillRule);
never executed: return qstring_literal_temp;
0
4299 proto->defineAccessorProperty(QStringLiteral("globalAlpha"), QQuickJSContext2D::method_get_globalAlpha, QQuickJSContext2D::method_set_globalAlpha);
never executed: return qstring_literal_temp;
0
4300 proto->defineAccessorProperty(QStringLiteral("lineCap"), QQuickJSContext2D::method_get_lineCap, QQuickJSContext2D::method_set_lineCap);
never executed: return qstring_literal_temp;
0
4301 proto->defineAccessorProperty(QStringLiteral("shadowOffsetX"), QQuickJSContext2D::method_get_shadowOffsetX, QQuickJSContext2D::method_set_shadowOffsetX);
never executed: return qstring_literal_temp;
0
4302 proto->defineAccessorProperty(QStringLiteral("shadowOffsetY"), QQuickJSContext2D::method_get_shadowOffsetY, QQuickJSContext2D::method_set_shadowOffsetY);
never executed: return qstring_literal_temp;
0
4303 proto->defineAccessorProperty(QStringLiteral("globalCompositeOperation"), QQuickJSContext2D::method_get_globalCompositeOperation, QQuickJSContext2D::method_set_globalCompositeOperation);
never executed: return qstring_literal_temp;
0
4304 proto->defineAccessorProperty(QStringLiteral("miterLimit"), QQuickJSContext2D::method_get_miterLimit, QQuickJSContext2D::method_set_miterLimit);
never executed: return qstring_literal_temp;
0
4305 proto->defineAccessorProperty(QStringLiteral("fillStyle"), QQuickJSContext2D::method_get_fillStyle, QQuickJSContext2D::method_set_fillStyle);
never executed: return qstring_literal_temp;
0
4306 proto->defineAccessorProperty(QStringLiteral("shadowColor"), QQuickJSContext2D::method_get_shadowColor, QQuickJSContext2D::method_set_shadowColor);
never executed: return qstring_literal_temp;
0
4307 proto->defineAccessorProperty(QStringLiteral("textBaseline"), QQuickJSContext2D::method_get_textBaseline, QQuickJSContext2D::method_set_textBaseline);
never executed: return qstring_literal_temp;
0
4308#if QT_CONFIG(quick_path)-
4309 proto->defineAccessorProperty(QStringLiteral("path"), QQuickJSContext2D::method_get_path, QQuickJSContext2D::method_set_path);
never executed: return qstring_literal_temp;
0
4310#endif-
4311 proto->defineAccessorProperty(QStringLiteral("lineJoin"), QQuickJSContext2D::method_get_lineJoin, QQuickJSContext2D::method_set_lineJoin);
never executed: return qstring_literal_temp;
0
4312 proto->defineAccessorProperty(QStringLiteral("lineWidth"), QQuickJSContext2D::method_get_lineWidth, QQuickJSContext2D::method_set_lineWidth);
never executed: return qstring_literal_temp;
0
4313 proto->defineAccessorProperty(QStringLiteral("textAlign"), QQuickJSContext2D::method_get_textAlign, QQuickJSContext2D::method_set_textAlign);
never executed: return qstring_literal_temp;
0
4314 proto->defineAccessorProperty(QStringLiteral("shadowBlur"), QQuickJSContext2D::method_get_shadowBlur, QQuickJSContext2D::method_set_shadowBlur);
never executed: return qstring_literal_temp;
0
4315 contextPrototype = proto;-
4316-
4317 proto = scope.engine->newObject();-
4318 proto->defineDefaultProperty(QStringLiteral("addColorStop"), QQuickContext2DStyle::gradient_proto_addColorStop, 0);
never executed: return qstring_literal_temp;
0
4319 gradientProto = proto;-
4320-
4321 proto = scope.engine->newObject();-
4322 proto->defineAccessorProperty(scope.engine->id_length(), QQuickJSContext2DPixelData::proto_get_length, nullptr);-
4323 pixelArrayProto = proto;-
4324}
never executed: end of block
0
4325-
4326QQuickContext2DEngineData::~QQuickContext2DEngineData()-
4327{-
4328}-
4329-
4330void QQuickContext2D::popState()-
4331{-
4332 if (m_stateStack.isEmpty())
m_stateStack.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4333 return;
never executed: return;
0
4334-
4335 QQuickContext2D::State newState = m_stateStack.pop();-
4336-
4337 if (state.matrix != newState.matrix)
state.matrix !...ewState.matrixDescription
TRUEnever evaluated
FALSEnever evaluated
0
4338 buffer()->updateMatrix(newState.matrix);
never executed: buffer()->updateMatrix(newState.matrix);
0
4339-
4340 if (newState.globalAlpha != state.globalAlpha)
newState.globa...te.globalAlphaDescription
TRUEnever evaluated
FALSEnever evaluated
0
4341 buffer()->setGlobalAlpha(newState.globalAlpha);
never executed: buffer()->setGlobalAlpha(newState.globalAlpha);
0
4342-
4343 if (newState.globalCompositeOperation != state.globalCompositeOperation)
newState.globa...ositeOperationDescription
TRUEnever evaluated
FALSEnever evaluated
0
4344 buffer()->setGlobalCompositeOperation(newState.globalCompositeOperation);
never executed: buffer()->setGlobalCompositeOperation(newState.globalCompositeOperation);
0
4345-
4346 if (newState.fillStyle != state.fillStyle)
newState.fillS...tate.fillStyleDescription
TRUEnever evaluated
FALSEnever evaluated
0
4347 buffer()->setFillStyle(newState.fillStyle);
never executed: buffer()->setFillStyle(newState.fillStyle);
0
4348-
4349 if (newState.strokeStyle != state.strokeStyle)
newState.strok...te.strokeStyleDescription
TRUEnever evaluated
FALSEnever evaluated
0
4350 buffer()->setStrokeStyle(newState.strokeStyle);
never executed: buffer()->setStrokeStyle(newState.strokeStyle);
0
4351-
4352 if (newState.lineWidth != state.lineWidth)
newState.lineW...tate.lineWidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
4353 buffer()->setLineWidth(newState.lineWidth);
never executed: buffer()->setLineWidth(newState.lineWidth);
0
4354-
4355 if (newState.lineCap != state.lineCap)
newState.lineC... state.lineCapDescription
TRUEnever evaluated
FALSEnever evaluated
0
4356 buffer()->setLineCap(newState.lineCap);
never executed: buffer()->setLineCap(newState.lineCap);
0
4357-
4358 if (newState.lineJoin != state.lineJoin)
newState.lineJ...state.lineJoinDescription
TRUEnever evaluated
FALSEnever evaluated
0
4359 buffer()->setLineJoin(newState.lineJoin);
never executed: buffer()->setLineJoin(newState.lineJoin);
0
4360-
4361 if (newState.miterLimit != state.miterLimit)
newState.miter...ate.miterLimitDescription
TRUEnever evaluated
FALSEnever evaluated
0
4362 buffer()->setMiterLimit(newState.miterLimit);
never executed: buffer()->setMiterLimit(newState.miterLimit);
0
4363-
4364 if (newState.clip != state.clip || newState.clipPath != state.clipPath)
newState.clip != state.clipDescription
TRUEnever evaluated
FALSEnever evaluated
newState.clipP...state.clipPathDescription
TRUEnever evaluated
FALSEnever evaluated
0
4365 buffer()->clip(newState.clip, newState.clipPath);
never executed: buffer()->clip(newState.clip, newState.clipPath);
0
4366-
4367 if (newState.shadowBlur != state.shadowBlur)
newState.shado...ate.shadowBlurDescription
TRUEnever evaluated
FALSEnever evaluated
0
4368 buffer()->setShadowBlur(newState.shadowBlur);
never executed: buffer()->setShadowBlur(newState.shadowBlur);
0
4369-
4370 if (newState.shadowColor != state.shadowColor)
newState.shado...te.shadowColorDescription
TRUEnever evaluated
FALSEnever evaluated
0
4371 buffer()->setShadowColor(newState.shadowColor);
never executed: buffer()->setShadowColor(newState.shadowColor);
0
4372-
4373 if (newState.shadowOffsetX != state.shadowOffsetX)
newState.shado....shadowOffsetXDescription
TRUEnever evaluated
FALSEnever evaluated
0
4374 buffer()->setShadowOffsetX(newState.shadowOffsetX);
never executed: buffer()->setShadowOffsetX(newState.shadowOffsetX);
0
4375-
4376 if (newState.shadowOffsetY != state.shadowOffsetY)
newState.shado....shadowOffsetYDescription
TRUEnever evaluated
FALSEnever evaluated
0
4377 buffer()->setShadowOffsetY(newState.shadowOffsetY);
never executed: buffer()->setShadowOffsetY(newState.shadowOffsetY);
0
4378 m_path = state.matrix.map(m_path);-
4379 state = newState;-
4380 m_path = state.matrix.inverted().map(m_path);-
4381}
never executed: end of block
0
4382void QQuickContext2D::pushState()-
4383{-
4384 m_stateStack.push(state);-
4385}
never executed: end of block
0
4386-
4387void QQuickContext2D::reset()-
4388{-
4389 QQuickContext2D::State newState;-
4390-
4391 m_path = QPainterPath();-
4392-
4393 newState.clipPath.setFillRule(Qt::WindingFill);-
4394-
4395 m_stateStack.clear();-
4396 m_stateStack.push(newState);-
4397 popState();-
4398 m_buffer->clearRect(QRectF(0, 0, m_canvas->width(), m_canvas->height()));-
4399}
never executed: end of block
0
4400-
4401void QQuickContext2D::setV4Engine(QV4::ExecutionEngine *engine)-
4402{-
4403 if (m_v4engine != engine) {
m_v4engine != engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
4404 m_v4engine = engine;-
4405-
4406 if (m_v4engine == nullptr)
m_v4engine == nullptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
4407 return;
never executed: return;
0
4408-
4409 QQuickContext2DEngineData *ed = engineData(engine);-
4410 QV4::Scope scope(engine);-
4411 QV4::Scoped<QQuickJSContext2D> wrapper(scope, engine->memoryManager->allocate<QQuickJSContext2D>());-
4412 QV4::ScopedObject p(scope, ed->contextPrototype.value());-
4413 wrapper->setPrototypeOf(p);-
4414 wrapper->d()->context = this;-
4415 m_v4value = wrapper;-
4416 }
never executed: end of block
0
4417}
never executed: end of block
0
4418-
4419QT_END_NAMESPACE-
4420-
4421#include "moc_qquickcontext2d_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0