You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Piotr Kołaczkowski <p....@sages.com.pl> on 2012/01/20 10:09:33 UTC

Double buffering of components

Hi,

Is there support for explicit double-buffering of components (especially 
windows) like it is in Swing?
Currently I faced another performance problem - imagine a top level 
Window with a one single Frame open in it.
The Window contains an animation, that needs to be repainted at >30 FPS. 
When I issue the repaint, not only the window gets repainted, but also 
the parts of the frame that happened to be inside the repaint region (if 
the user shadows a part of the animation with the frame, the frame gets 
the repaints).
For complex Frames with lots of components inside them, it may be slow. 
And it is not needed, because I actually haven't changed anything inside 
the frame, so it is perfect case for double buffering and drawing the 
whole frame with a single drawImage statement.

So, is there a workaround now for this? Is this planned?

Regards,
Piotr

-- 
Piotr Kołaczkowski
senior consultant
Sages Sp. z o.o.
www.sages.com.pl


Re: Double buffering of components

Posted by Noel Grandin <no...@gmail.com>.
Hi

It could be that something is generating repaint() events with a larger 
repaint region than necessary.
Can you track down the source of the repaint() events and check if this 
is the case?

-- Noel Grandin

On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
> Hi,
>
> Is there support for explicit double-buffering of components 
> (especially windows) like it is in Swing?
> Currently I faced another performance problem - imagine a top level 
> Window with a one single Frame open in it.
> The Window contains an animation, that needs to be repainted at >30 
> FPS. When I issue the repaint, not only the window gets repainted, but 
> also the parts of the frame that happened to be inside the repaint 
> region (if the user shadows a part of the animation with the frame, 
> the frame gets the repaints).
> For complex Frames with lots of components inside them, it may be 
> slow. And it is not needed, because I actually haven't changed 
> anything inside the frame, so it is perfect case for double buffering 
> and drawing the whole frame with a single drawImage statement.
>
> So, is there a workaround now for this? Is this planned?
>
> Regards,
> Piotr
>

Re: Double buffering of components

Posted by Piotr Kołaczkowski <pk...@gmail.com>.
Hi,

Works like a charm now. The performance improvement is huge.
Thanks!

-- Piotr

W dniu 26 stycznia 2012 10:33 użytkownik Noel Grandin <noelgrandin@gmail.com
> napisał:

>
> Ping?
>
>
> On 2012-01-23 19:52, Piotr Kołaczkowski wrote:
>
>> Thanks.
>> Unfortunately no time to check that now, but I get back to you as soon as
>> I know if it helps or not.
>> According to my profiler, it should speed up some parts of our
>> application by about 10x.
>>
>> Regards,
>> Piotr
>>
>>
>>

Re: Double buffering of components

Posted by Noel Grandin <no...@gmail.com>.
Ping?

On 2012-01-23 19:52, Piotr Kołaczkowski wrote:
> Thanks.
> Unfortunately no time to check that now, but I get back to you as soon 
> as I know if it helps or not.
> According to my profiler, it should speed up some parts of our 
> application by about 10x.
>
> Regards,
> Piotr
>
>

Re: Double buffering of components

Posted by Piotr Kołaczkowski <P....@elka.pw.edu.pl>.
Thanks.
Unfortunately no time to check that now, but I get back to you as soon 
as I know if it helps or not.
According to my profiler, it should speed up some parts of our 
application by about 10x.

Regards,
Piotr

W dniu 23.01.2012 07:11, Noel Grandin pisze:
> Hi
>
> OK, good point, try this patch - moved the logic down into Container.
>
> -- Noel.
>
> On 2012-01-22 14:14, Piotr Kołaczkowski wrote:
>> Hi,
>>
>> Ok, I found what is wrong.
>> I thought that setting doubleBuffered on a Container is enough. But 
>> unfortunately the patch applies only to the Component.paint
>> and Container overrides it with a method explicitly calling paint on 
>> all the children, regardless it is doubleBuffered or not.
>> So the patch works currently only for child-level components.  But 
>> double buffering would be most useful on complex components 
>> containing lot of subcomponents, e.g. whole frames (we save not only 
>> on painting, but also on the whole painting logic like bounds 
>> calculation, etc.).
>>
>> Best regards,
>> Piotr
>>
>>
>>
>> W dniu 20.01.2012 15:35, Noel Grandin pisze:
>>> note that you have to enable double-buffering explicitly on a 
>>> per-component basis.
>>>
>>> On 2012-01-20 16:13, Piotr Kołaczkowski wrote:
>>>> Hmm,
>>>>
>>>> Can't see a difference. But I have to profile it to see what is 
>>>> causing the slowdown.
>>>> Thanks for the patch.
>>>>
>>>> -- Piotr
>>>>
>>>> W dniu 20.01.2012 13:53, Noel Grandin pisze:
>>>>>
>>>>> Hmm, interesting idea.
>>>>>
>>>>> This is a prototype patch. Try it out and let me know how it goes.
>>>>>
>>>>> -- Noel Grandin
>>>>>
>>>>> On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
>>>>>> Hi,
>>>>>>
>>>>>> Is there support for explicit double-buffering of components 
>>>>>> (especially windows) like it is in Swing?
>>>>>> Currently I faced another performance problem - imagine a top 
>>>>>> level Window with a one single Frame open in it.
>>>>>> The Window contains an animation, that needs to be repainted at 
>>>>>> >30 FPS. When I issue the repaint, not only the window gets 
>>>>>> repainted, but also the parts of the frame that happened to be 
>>>>>> inside the repaint region (if the user shadows a part of the 
>>>>>> animation with the frame, the frame gets the repaints).
>>>>>> For complex Frames with lots of components inside them, it may be 
>>>>>> slow. And it is not needed, because I actually haven't changed 
>>>>>> anything inside the frame, so it is perfect case for double 
>>>>>> buffering and drawing the whole frame with a single drawImage 
>>>>>> statement.
>>>>>>
>>>>>> So, is there a workaround now for this? Is this planned?
>>>>>>
>>>>>> Regards,
>>>>>> Piotr
>>>>>>
>>>>
>>>>
>>>
>>
>>


-- 
Piotr Kołaczkowski
Instytut Informatyki, Politechnika Warszawska
Nowowiejska 15/19, 00-665 Warszawa
e-mail: pkolaczk@ii.pw.edu.pl
www: http://home.elka.pw.edu.pl/~pkolaczk/


Re: Double buffering of components

Posted by Noel Grandin <no...@gmail.com>.
Hi

OK, good point, try this patch - moved the logic down into Container.

-- Noel.

On 2012-01-22 14:14, Piotr Kołaczkowski wrote:
> Hi,
>
> Ok, I found what is wrong.
> I thought that setting doubleBuffered on a Container is enough. But 
> unfortunately the patch applies only to the Component.paint
> and Container overrides it with a method explicitly calling paint on 
> all the children, regardless it is doubleBuffered or not.
> So the patch works currently only for child-level components.  But 
> double buffering would be most useful on complex components containing 
> lot of subcomponents, e.g. whole frames (we save not only on painting, 
> but also on the whole painting logic like bounds calculation, etc.).
>
> Best regards,
> Piotr
>
>
>
> W dniu 20.01.2012 15:35, Noel Grandin pisze:
>> note that you have to enable double-buffering explicitly on a 
>> per-component basis.
>>
>> On 2012-01-20 16:13, Piotr Kołaczkowski wrote:
>>> Hmm,
>>>
>>> Can't see a difference. But I have to profile it to see what is 
>>> causing the slowdown.
>>> Thanks for the patch.
>>>
>>> -- Piotr
>>>
>>> W dniu 20.01.2012 13:53, Noel Grandin pisze:
>>>>
>>>> Hmm, interesting idea.
>>>>
>>>> This is a prototype patch. Try it out and let me know how it goes.
>>>>
>>>> -- Noel Grandin
>>>>
>>>> On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
>>>>> Hi,
>>>>>
>>>>> Is there support for explicit double-buffering of components 
>>>>> (especially windows) like it is in Swing?
>>>>> Currently I faced another performance problem - imagine a top 
>>>>> level Window with a one single Frame open in it.
>>>>> The Window contains an animation, that needs to be repainted at 
>>>>> >30 FPS. When I issue the repaint, not only the window gets 
>>>>> repainted, but also the parts of the frame that happened to be 
>>>>> inside the repaint region (if the user shadows a part of the 
>>>>> animation with the frame, the frame gets the repaints).
>>>>> For complex Frames with lots of components inside them, it may be 
>>>>> slow. And it is not needed, because I actually haven't changed 
>>>>> anything inside the frame, so it is perfect case for double 
>>>>> buffering and drawing the whole frame with a single drawImage 
>>>>> statement.
>>>>>
>>>>> So, is there a workaround now for this? Is this planned?
>>>>>
>>>>> Regards,
>>>>> Piotr
>>>>>
>>>
>>>
>>
>
>

Re: Double buffering of components

Posted by Noel Grandin <no...@gmail.com>.
Hi

OK, good point, try this patch - moved the logic down into Container.

-- Noel.

On 2012-01-22 14:14, Piotr Kołaczkowski wrote:
> Hi,
>
> Ok, I found what is wrong.
> I thought that setting doubleBuffered on a Container is enough. But 
> unfortunately the patch applies only to the Component.paint
> and Container overrides it with a method explicitly calling paint on 
> all the children, regardless it is doubleBuffered or not.
> So the patch works currently only for child-level components.  But 
> double buffering would be most useful on complex components containing 
> lot of subcomponents, e.g. whole frames (we save not only on painting, 
> but also on the whole painting logic like bounds calculation, etc.).
>
> Best regards,
> Piotr
>
>
>
> W dniu 20.01.2012 15:35, Noel Grandin pisze:
>> note that you have to enable double-buffering explicitly on a 
>> per-component basis.
>>
>> On 2012-01-20 16:13, Piotr Kołaczkowski wrote:
>>> Hmm,
>>>
>>> Can't see a difference. But I have to profile it to see what is 
>>> causing the slowdown.
>>> Thanks for the patch.
>>>
>>> -- Piotr
>>>
>>> W dniu 20.01.2012 13:53, Noel Grandin pisze:
>>>>
>>>> Hmm, interesting idea.
>>>>
>>>> This is a prototype patch. Try it out and let me know how it goes.
>>>>
>>>> -- Noel Grandin
>>>>
>>>> On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
>>>>> Hi,
>>>>>
>>>>> Is there support for explicit double-buffering of components 
>>>>> (especially windows) like it is in Swing?
>>>>> Currently I faced another performance problem - imagine a top 
>>>>> level Window with a one single Frame open in it.
>>>>> The Window contains an animation, that needs to be repainted at 
>>>>> >30 FPS. When I issue the repaint, not only the window gets 
>>>>> repainted, but also the parts of the frame that happened to be 
>>>>> inside the repaint region (if the user shadows a part of the 
>>>>> animation with the frame, the frame gets the repaints).
>>>>> For complex Frames with lots of components inside them, it may be 
>>>>> slow. And it is not needed, because I actually haven't changed 
>>>>> anything inside the frame, so it is perfect case for double 
>>>>> buffering and drawing the whole frame with a single drawImage 
>>>>> statement.
>>>>>
>>>>> So, is there a workaround now for this? Is this planned?
>>>>>
>>>>> Regards,
>>>>> Piotr
>>>>>
>>>
>>>
>>
>
>

Re: Double buffering of components

Posted by Piotr Kołaczkowski <p....@sages.com.pl>.
Hi,

Ok, I found what is wrong.
I thought that setting doubleBuffered on a Container is enough. But 
unfortunately the patch applies only to the Component.paint
and Container overrides it with a method explicitly calling paint on all 
the children, regardless it is doubleBuffered or not.
So the patch works currently only for child-level components.  But 
double buffering would be most useful on complex components containing 
lot of subcomponents, e.g. whole frames (we save not only on painting, 
but also on the whole painting logic like bounds calculation, etc.).

Best regards,
Piotr



W dniu 20.01.2012 15:35, Noel Grandin pisze:
> note that you have to enable double-buffering explicitly on a 
> per-component basis.
>
> On 2012-01-20 16:13, Piotr Kołaczkowski wrote:
>> Hmm,
>>
>> Can't see a difference. But I have to profile it to see what is 
>> causing the slowdown.
>> Thanks for the patch.
>>
>> -- Piotr
>>
>> W dniu 20.01.2012 13:53, Noel Grandin pisze:
>>>
>>> Hmm, interesting idea.
>>>
>>> This is a prototype patch. Try it out and let me know how it goes.
>>>
>>> -- Noel Grandin
>>>
>>> On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
>>>> Hi,
>>>>
>>>> Is there support for explicit double-buffering of components 
>>>> (especially windows) like it is in Swing?
>>>> Currently I faced another performance problem - imagine a top level 
>>>> Window with a one single Frame open in it.
>>>> The Window contains an animation, that needs to be repainted at >30 
>>>> FPS. When I issue the repaint, not only the window gets repainted, 
>>>> but also the parts of the frame that happened to be inside the 
>>>> repaint region (if the user shadows a part of the animation with 
>>>> the frame, the frame gets the repaints).
>>>> For complex Frames with lots of components inside them, it may be 
>>>> slow. And it is not needed, because I actually haven't changed 
>>>> anything inside the frame, so it is perfect case for double 
>>>> buffering and drawing the whole frame with a single drawImage 
>>>> statement.
>>>>
>>>> So, is there a workaround now for this? Is this planned?
>>>>
>>>> Regards,
>>>> Piotr
>>>>
>>
>>
>


-- 
Piotr Kołaczkowski
senior consultant
Sages Sp. z o.o.
www.sages.com.pl


Re: Double buffering of components

Posted by Piotr Kołaczkowski <p....@sages.com.pl>.
Hi,

Ok, I found what is wrong.
I thought that setting doubleBuffered on a Container is enough. But 
unfortunately the patch applies only to the Component.paint
and Container overrides it with a method explicitly calling paint on all 
the children, regardless it is doubleBuffered or not.
So the patch works currently only for child-level components.  But 
double buffering would be most useful on complex components containing 
lot of subcomponents, e.g. whole frames (we save not only on painting, 
but also on the whole painting logic like bounds calculation, etc.).

Best regards,
Piotr



W dniu 20.01.2012 15:35, Noel Grandin pisze:
> note that you have to enable double-buffering explicitly on a 
> per-component basis.
>
> On 2012-01-20 16:13, Piotr Kołaczkowski wrote:
>> Hmm,
>>
>> Can't see a difference. But I have to profile it to see what is 
>> causing the slowdown.
>> Thanks for the patch.
>>
>> -- Piotr
>>
>> W dniu 20.01.2012 13:53, Noel Grandin pisze:
>>>
>>> Hmm, interesting idea.
>>>
>>> This is a prototype patch. Try it out and let me know how it goes.
>>>
>>> -- Noel Grandin
>>>
>>> On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
>>>> Hi,
>>>>
>>>> Is there support for explicit double-buffering of components 
>>>> (especially windows) like it is in Swing?
>>>> Currently I faced another performance problem - imagine a top level 
>>>> Window with a one single Frame open in it.
>>>> The Window contains an animation, that needs to be repainted at >30 
>>>> FPS. When I issue the repaint, not only the window gets repainted, 
>>>> but also the parts of the frame that happened to be inside the 
>>>> repaint region (if the user shadows a part of the animation with 
>>>> the frame, the frame gets the repaints).
>>>> For complex Frames with lots of components inside them, it may be 
>>>> slow. And it is not needed, because I actually haven't changed 
>>>> anything inside the frame, so it is perfect case for double 
>>>> buffering and drawing the whole frame with a single drawImage 
>>>> statement.
>>>>
>>>> So, is there a workaround now for this? Is this planned?
>>>>
>>>> Regards,
>>>> Piotr
>>>>
>>
>>
>


-- 
Piotr Kołaczkowski
senior consultant
Sages Sp. z o.o.
www.sages.com.pl


Re: Double buffering of components

Posted by Noel Grandin <no...@gmail.com>.
note that you have to enable double-buffering explicitly on a 
per-component basis.

On 2012-01-20 16:13, Piotr Kołaczkowski wrote:
> Hmm,
>
> Can't see a difference. But I have to profile it to see what is 
> causing the slowdown.
> Thanks for the patch.
>
> -- Piotr
>
> W dniu 20.01.2012 13:53, Noel Grandin pisze:
>>
>> Hmm, interesting idea.
>>
>> This is a prototype patch. Try it out and let me know how it goes.
>>
>> -- Noel Grandin
>>
>> On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
>>> Hi,
>>>
>>> Is there support for explicit double-buffering of components 
>>> (especially windows) like it is in Swing?
>>> Currently I faced another performance problem - imagine a top level 
>>> Window with a one single Frame open in it.
>>> The Window contains an animation, that needs to be repainted at >30 
>>> FPS. When I issue the repaint, not only the window gets repainted, 
>>> but also the parts of the frame that happened to be inside the 
>>> repaint region (if the user shadows a part of the animation with the 
>>> frame, the frame gets the repaints).
>>> For complex Frames with lots of components inside them, it may be 
>>> slow. And it is not needed, because I actually haven't changed 
>>> anything inside the frame, so it is perfect case for double 
>>> buffering and drawing the whole frame with a single drawImage 
>>> statement.
>>>
>>> So, is there a workaround now for this? Is this planned?
>>>
>>> Regards,
>>> Piotr
>>>
>
>

Re: Double buffering of components

Posted by Noel Grandin <no...@gmail.com>.
note that you have to enable double-buffering explicitly on a 
per-component basis.

On 2012-01-20 16:13, Piotr Kołaczkowski wrote:
> Hmm,
>
> Can't see a difference. But I have to profile it to see what is 
> causing the slowdown.
> Thanks for the patch.
>
> -- Piotr
>
> W dniu 20.01.2012 13:53, Noel Grandin pisze:
>>
>> Hmm, interesting idea.
>>
>> This is a prototype patch. Try it out and let me know how it goes.
>>
>> -- Noel Grandin
>>
>> On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
>>> Hi,
>>>
>>> Is there support for explicit double-buffering of components 
>>> (especially windows) like it is in Swing?
>>> Currently I faced another performance problem - imagine a top level 
>>> Window with a one single Frame open in it.
>>> The Window contains an animation, that needs to be repainted at >30 
>>> FPS. When I issue the repaint, not only the window gets repainted, 
>>> but also the parts of the frame that happened to be inside the 
>>> repaint region (if the user shadows a part of the animation with the 
>>> frame, the frame gets the repaints).
>>> For complex Frames with lots of components inside them, it may be 
>>> slow. And it is not needed, because I actually haven't changed 
>>> anything inside the frame, so it is perfect case for double 
>>> buffering and drawing the whole frame with a single drawImage 
>>> statement.
>>>
>>> So, is there a workaround now for this? Is this planned?
>>>
>>> Regards,
>>> Piotr
>>>
>
>

Re: Double buffering of components

Posted by Piotr Kołaczkowski <p....@sages.com.pl>.
Hmm,

Can't see a difference. But I have to profile it to see what is causing 
the slowdown.
Thanks for the patch.

-- Piotr

W dniu 20.01.2012 13:53, Noel Grandin pisze:
>
> Hmm, interesting idea.
>
> This is a prototype patch. Try it out and let me know how it goes.
>
> -- Noel Grandin
>
> On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
>> Hi,
>>
>> Is there support for explicit double-buffering of components 
>> (especially windows) like it is in Swing?
>> Currently I faced another performance problem - imagine a top level 
>> Window with a one single Frame open in it.
>> The Window contains an animation, that needs to be repainted at >30 
>> FPS. When I issue the repaint, not only the window gets repainted, 
>> but also the parts of the frame that happened to be inside the 
>> repaint region (if the user shadows a part of the animation with the 
>> frame, the frame gets the repaints).
>> For complex Frames with lots of components inside them, it may be 
>> slow. And it is not needed, because I actually haven't changed 
>> anything inside the frame, so it is perfect case for double buffering 
>> and drawing the whole frame with a single drawImage statement.
>>
>> So, is there a workaround now for this? Is this planned?
>>
>> Regards,
>> Piotr
>>


-- 
Piotr Kołaczkowski
senior consultant
Sages Sp. z o.o.
www.sages.com.pl


Re: Double buffering of components

Posted by Piotr Kołaczkowski <p....@sages.com.pl>.
Hmm,

Can't see a difference. But I have to profile it to see what is causing 
the slowdown.
Thanks for the patch.

-- Piotr

W dniu 20.01.2012 13:53, Noel Grandin pisze:
>
> Hmm, interesting idea.
>
> This is a prototype patch. Try it out and let me know how it goes.
>
> -- Noel Grandin
>
> On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
>> Hi,
>>
>> Is there support for explicit double-buffering of components 
>> (especially windows) like it is in Swing?
>> Currently I faced another performance problem - imagine a top level 
>> Window with a one single Frame open in it.
>> The Window contains an animation, that needs to be repainted at >30 
>> FPS. When I issue the repaint, not only the window gets repainted, 
>> but also the parts of the frame that happened to be inside the 
>> repaint region (if the user shadows a part of the animation with the 
>> frame, the frame gets the repaints).
>> For complex Frames with lots of components inside them, it may be 
>> slow. And it is not needed, because I actually haven't changed 
>> anything inside the frame, so it is perfect case for double buffering 
>> and drawing the whole frame with a single drawImage statement.
>>
>> So, is there a workaround now for this? Is this planned?
>>
>> Regards,
>> Piotr
>>


-- 
Piotr Kołaczkowski
senior consultant
Sages Sp. z o.o.
www.sages.com.pl


Re: Double buffering of components

Posted by Noel Grandin <no...@gmail.com>.
Hmm, interesting idea.

This is a prototype patch. Try it out and let me know how it goes.

-- Noel Grandin

On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
> Hi,
>
> Is there support for explicit double-buffering of components 
> (especially windows) like it is in Swing?
> Currently I faced another performance problem - imagine a top level 
> Window with a one single Frame open in it.
> The Window contains an animation, that needs to be repainted at >30 
> FPS. When I issue the repaint, not only the window gets repainted, but 
> also the parts of the frame that happened to be inside the repaint 
> region (if the user shadows a part of the animation with the frame, 
> the frame gets the repaints).
> For complex Frames with lots of components inside them, it may be 
> slow. And it is not needed, because I actually haven't changed 
> anything inside the frame, so it is perfect case for double buffering 
> and drawing the whole frame with a single drawImage statement.
>
> So, is there a workaround now for this? Is this planned?
>
> Regards,
> Piotr
>

Re: Double buffering of components

Posted by Noel Grandin <no...@gmail.com>.
Hmm, interesting idea.

This is a prototype patch. Try it out and let me know how it goes.

-- Noel Grandin

On 2012-01-20 11:09, Piotr Kołaczkowski wrote:
> Hi,
>
> Is there support for explicit double-buffering of components 
> (especially windows) like it is in Swing?
> Currently I faced another performance problem - imagine a top level 
> Window with a one single Frame open in it.
> The Window contains an animation, that needs to be repainted at >30 
> FPS. When I issue the repaint, not only the window gets repainted, but 
> also the parts of the frame that happened to be inside the repaint 
> region (if the user shadows a part of the animation with the frame, 
> the frame gets the repaints).
> For complex Frames with lots of components inside them, it may be 
> slow. And it is not needed, because I actually haven't changed 
> anything inside the frame, so it is perfect case for double buffering 
> and drawing the whole frame with a single drawImage statement.
>
> So, is there a workaround now for this? Is this planned?
>
> Regards,
> Piotr
>