Solved Anti-Aliasing get omitted when layer enabled
-
Hello everyone!
I just found a problem that an Item (and it's children) won't transform smoothly if its
layer.enabled
property is set totrue
.As the image shows above, the left rectangle gets smoothed well while the right one does not. The only different between these rectangles is the
layer.enabled
property.Environment: Windows 10 x64, Qt 5.11
Here's a minimum example to reproduce this issue:
import QtQuick 2.11 import QtQuick.Window 2.11 Window { visible: true width: 640 height: 480 color: "black" title: qsTr("Antialiasing Issuses") Row { anchors.centerIn: parent spacing: 32 Rectangle { width: 256 height: 256 rotation: 20 antialiasing: true } Rectangle { width: 256 height: 256 rotation: 20 antialiasing: true layer.enabled: true // this screws things up } } }
Is this a bug or there's something I missed?
I also tried to change thelayer.samples
andlayer.mipmap
properties but with no luck.
Thank you for any ideas :P -
@GPBeta hi,
I found this interesting (related to QML Shapes) :
https://stackoverflow.com/questions/48895449/how-do-i-enable-antialiasing-on-qml-shapesYou can enable multisampling
//main.cppQSurfaceFormat format; format.setSamples(8); QSurfaceFormat::setDefaultFormat(format);
-
Hi @LeLev , thank you very much for the useful hint!
I found out the reason why thelayer.samples
property doesn't take effects finally.There're something different from the
Shape
's anti-aliasing problem, my issue in the example is caused by layer's transformation.
So we have to enable the multi-sampling feature of a transformed layer's parent node:Row { ...... // this fix the layer transformation layer.enabled: true layer.samples: 8 Rectangle { width: 256 height: 256 rotation: 20 antialiasing: true } Rectangle { width: 256 height: 256 rotation: 20 antialiasing: true layer.enabled: true // rotate a layered item smoothly now! } }
Even thought layering theRow
clips the rectangles, it solves my issue and question. -
@GPBeta said in Anti-Aliasing get omitted when layer enabled:
Thanks for the info!I just tried your example, and found that it is also equivalent with setting
smooth: true
on the parentRow
.Row { ...... // this fix the layer transformation layer.enabled: true smooth: true }