aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/context2d
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-03-24 15:36:37 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-03-25 21:25:28 +0100
commitd009c0088bac6da4d775345a60e33fee22af22ce (patch)
treece420925f16f6fea77f9b6ee5e47e81b86011e4c /src/quick/items/context2d
parent3ce1ee554b7c9cb9200a88071cb2d9e45dda90c0 (diff)
QV4::Engine::toVariant: Use metatype instead of metatype id
This way, we can avoid the costly id to metatype lookup in case where we actually need the full metatype. Task-number: QTBUG-88766 Change-Id: Ibe29b323007f00d2f8d1807fb9b64f9a8f87e807 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/quick/items/context2d')
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 1fbb9595ae..64b8b80f8b 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -1433,7 +1433,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_fillStyle(const QV4::FunctionOb
QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Value::undefinedValue());
if (value->as<Object>()) {
- QColor color = scope.engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();
+ QColor color = scope.engine->toVariant(value, QMetaType::fromType<QColor>()).value<QColor>();
if (color.isValid()) {
r->d()->context()->state.fillStyle = color;
r->d()->context()->buffer()->setFillStyle(color);
@@ -1542,7 +1542,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_strokeStyle(const QV4::Function
QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Value::undefinedValue());
if (value->as<Object>()) {
- QColor color = scope.engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();
+ QColor color = scope.engine->toVariant(value, QMetaType::fromType<QColor>()).value<QColor>();
if (color.isValid()) {
r->d()->context()->state.strokeStyle = color;
r->d()->context()->buffer()->setStrokeStyle(color);
@@ -1774,7 +1774,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(const QV4::F
if (argc >= 2) {
QV4::Scoped<QQuickContext2DStyle> pattern(scope, scope.engine->memoryManager->allocate<QQuickContext2DStyle>());
- QColor color = scope.engine->toVariant(argv[0], qMetaTypeId<QColor>()).value<QColor>();
+ QColor color = scope.engine->toVariant(argv[0], QMetaType::fromType<QColor>()).value<QColor>();
if (color.isValid()) {
int patternMode = argv[1].toInt32();
Qt::BrushStyle style = Qt::SolidPattern;
@@ -3588,7 +3588,7 @@ QV4::ReturnedValue QQuickContext2DStyle::gradient_proto_addColorStop(const QV4::
QColor color;
if (argv[1].as<Object>()) {
- color = scope.engine->toVariant(argv[1], qMetaTypeId<QColor>()).value<QColor>();
+ color = scope.engine->toVariant(argv[1], QMetaType::fromType<QColor>()).value<QColor>();
} else {
color = qt_color_from_string(argv[1]);
}