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-