[vlc-devel] [PATCH 3/4] Qt: refactor vout resize

Анатолий Аниськович lin.aaa.lin at gmail.com
Sun Aug 7 12:07:43 CEST 2016


2016-08-07 11:54 GMT+03:00 Jean-Baptiste Kempf <jb at videolan.org>:
>
> I don't see how this is:
> - can be correct...

Point of this patch is to load up resizing routine to Qt. It'll do it
better than us.

> - related to HiDPI,

That's simple, less we use physical pixels (as those coming from
vout), less errors calculating proper sizes. The best code is no code
at all.

>
> On 07 Aug, Anatoliy Anischovich wrote :
>>  VideoWidget::VideoWidget( intf_thread_t *_p_i )
>> -            : QFrame( NULL ) , p_intf( _p_i )
>> +            : QFrame( NULL ) , p_intf( _p_i ) , i_width( 0 ), i_height( 0 )
>>  {
>>      /* Set the policy to expand in both directions */
>> -    // setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
>> +    setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
>
> Changing the policy? Why?

As I said before, that's all about loading up size calculations to the
framework. Size policy + size hints do all this dirty job us.
Explaining few paragraphs below.

>> -WId VideoWidget::request( struct vout_window_t *p_wnd, unsigned int *pi_width,
>> -                          unsigned int *pi_height, bool b_keep_size )
>> +WId VideoWidget::request( struct vout_window_t *p_wnd )
>
> This will break "keep-size" option.

Explain, please. From my understanding, "keep-size" option is to
prevent resize of the main window when the video size changes. If my
point is right, then this patch already handles such case.

>> -void VideoWidget::setSize( unsigned int w, unsigned int h )
>> +void VideoWidget::setSize( int w, int h )
>
> Why?

Qt use signed integers for sizing everywhere. Narrowing down number of
casts and compiler warnings.

>>  {
>> -    /* If the size changed, resizeEvent will be called, otherwise not,
>> -     * in which case we need to tell the vout what the size actually is
>> -     */
>> -    if( (unsigned)size().width() == w && (unsigned)size().height() == h )
>> -    {
>> -        if( p_window != NULL )
>> -            vout_window_ReportSize( p_window, w, h );
>> -        return;
>> -    }
>> +    i_width = w;
>> +    i_height = h;
>>
>> -    resize( w, h );
>>      emit sizeChanged( w, h );
>> -    /* Work-around a bug?misconception? that would happen when vout core resize
>> -       twice to the same size and would make the vout not centered.
>> -       This cause a small flicker.
>> -       See #3621
>> -     */
>> -    if( (unsigned)size().width() == w && (unsigned)size().height() == h )
>> -        updateGeometry();
>> +
>>      sync();
>>  }
>
> How can you remove all that and not break everything?

sizeChanged triggers resize, thus, few more geometry recalculations.
Idea is to avoid resizing by ourself and trust the parent
widget/layout to provide correct size. That's why we need custom size
hint and size policy.


More information about the vlc-devel mailing list