[Qt-qml] Shiny!
Martin Jones
martin.jones at nokia.com
Tue Jul 27 02:00:39 CEST 2010
Currently you will have 3 passes. For gradient Rectangles the news is even
worse - they are painted using QPainter::drawRect() for every frame (most
Rectangles are cached, so it just ends up being a pixmap blit).
For best performance this shiny highlight is probably best achieved using an
image. That does limit you somewhat, in particular the roundedness, but in
most real applications you tend to have a limited number of things that you
want shiny, so you can get by with a few images.
There's obviously some scope for improvement in the future.
Martin.
On Tue, 27 Jul 2010 06:07:49 am ext Jason H wrote:
> Yeah, but you'll likely get bogged down if you do a lot of this.
>
> For best results, put it in the artwork, and put your text on top, if text
> is to be there. It helps with readability.
>
> But sometimes, you do want the shine to interfere. I'd be interested to
> know if Qt[ML] caches it by composting it so that int he future, as long
> as the contents don't change you don't end up doing 3 draw passes
> (background, foreground, and shine) every time rather tn just once.
>
> I'd love to hear more about how QML objects are handled internally.
>
> ________________________________
> From: "alan.westbrook at nokia.com" <alan.westbrook at nokia.com>
> To: qt-qml at trolltech.com
> Sent: Mon, July 26, 2010 2:28:03 PM
> Subject: [Qt-qml] Shiny!
>
> I was messing about with some controls I had written, and I wrote this to
> see if it might make something look shiny.
>
> And it did!
>
> So I'd like to share it with everyone.
>
> It's pretty much a poor man's shine plastered on top of anything you stick
> it in.
>
>
> ---8<--- Shine.qml ---8<----------8<----------------------
>
>
> import Qt 4.7
>
> Rectangle {
>
> id: shine
>
> radius: parent.radius - 1
>
> smooth: true
>
> gradient: Gradient {
>
> GradientStop {
>
> position: 0
>
> color: "#aaffffff"
>
> }
>
> GradientStop {
>
> position: 1
>
> color: "#22ffffff"
>
> }
>
> }
>
> anchors.fill: parent
>
> anchors.bottomMargin: parent.height / 2
>
> anchors.topMargin: 1
>
> anchors.leftMargin: 1
>
> anchors.rightMargin: 1
>
> }
>
> ---8<--------------------------8<-----------------------------
>
> Just place a Shine { } as the last item in an element, and Bam! lickable!
> =)
>
> Alan
>
> PS: Is there a site yet for sharing qml components?
--
Martin
More information about the Qt-qml
mailing list