qmlweb
qmlweb copied to clipboard
About optimizing Text $updateImplicit.
I'm trying to optimize the performance of the $updateImplicit function in Text.
When the content of the text is only plain text rather than HTML, use canvas measureText to replace the DOM's offsetWidth calculation properties.
But this is only targeted optimization, it means that the use of frequent changes in the content of the Text, need to follow a best practice(no HTML but text) to get this optimization.
Test Code
import QtQuick 2.0
Item {
Rectangle {
id: rect
anchors.centerIn:parent
width: 300
height: 300
color: "red"
NumberAnimation on width{
id : ani_width
from: 300
to: 100
duration: 1000
running:false
}
NumberAnimation on height{
id : ani_height
from: 300
to: 100
duration: 1000
running:false
}
Text{
id:color_info
text:[rect.width,rect.height].join()
anchors.centerIn: parent
}
Text{
anchors.top: color_info.bottom
text:[color_info.implicitWidth,color_info.implicitHeight].join(',')
}
MouseArea{
onClicked:{
ani_width.running = !ani_width.running
ani_height.running = !ani_height.running
}
anchors.fill: parent;
}
}
}
SCREENSHOT
NEWEST

OLD

@ChALkeR If you think this targeted optimization and tell the user best practices are valuable, I will create a pull-request. Or we can find a better optimization program.