Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to avoid Composite Flicker ?
How to avoid Composite Flicker ? [message #454555] |
Sun, 24 April 2005 13:35 |
Eclipse User |
|
|
|
Originally posted by: aaa.domain.invalid
Hi,
I have a compopsite and a lsitview with a set of commands.
In the composites paintControl(..) I traverse through the list from item
0 to item n and interpret it and draw text, change
backgrounds,foregrounds etc.
I see a lot of flicker, how do I preven this flicker?
Are there any rules of updating th composite in the painting.
-chhil
|
|
| |
Re: How to avoid Composite Flicker ? [message #454608 is a reply to message #454605] |
Mon, 25 April 2005 15:18 |
Eclipse User |
|
|
|
Originally posted by: aaa.domain.invalid
Hello Steve,
I already use the SWT.NO_BACKGROUND do a fillrect at the beginning.
I have a grid cells that get painted over and over again that causes the
flicker.
-thanks chhil
Steve Northover wrote:
> Please investigate the SWT.NO_BACKGROUND style.
>
> "Chhil" <aaa@domain.invalid> wrote in message
> news:d4g7g0$q2s$1@news.eclipse.org...
>
>>Hi,
>>
>>I have a compopsite and a lsitview with a set of commands.
>>In the composites paintControl(..) I traverse through the list from item
>>0 to item n and interpret it and draw text, change
>>backgrounds,foregrounds etc.
>>I see a lot of flicker, how do I preven this flicker?
>>Are there any rules of updating th composite in the painting.
>>
>>
>>-chhil
>
>
>
|
|
|
Re: How to avoid Composite Flicker ? [message #454614 is a reply to message #454608] |
Mon, 25 April 2005 21:28 |
Emil Crumhorn Messages: 169 Registered: July 2009 |
Senior Member |
|
|
You will want to double buffer your canvas. In Windows XP things are not
double buffered by default so you get some flicker even with
SWT.NO_BACKGROUND. On OS/X everything is automatically double buffered so
you don't need it there. Here's an example of how to do double buffering
(the easy way).
---
(This assumes your paint event is sent to the following method)
private boolean created = false;
private void repaint(PaintEvent event) {
if (created) {
try {
// draw into a buffer, then transfer it over to the canvas
Image buffer = new Image(Display.getDefault(), super.getBounds());
GC gc2 = new GC(buffer);
drawChartOntoGC(gc2);
// transfer the image buffer onto this canvas (just
drawImage(buffer, w, h) didn't work for me, so I use this way, I haven't
investigated further)
Rectangle b = getBounds();
gc.drawImage(buffer, 0, 0, b.width, b.height, 0, 0, b.width,
b.height);
// dispose used objects (important, or you'll run out of handles)
buffer.dispose();
gc2.dispose();
}
catch (IllegalArgumentException iae) {
iae.printStackTrace();
}
}
else {
drawChartOntoGC(gc);
created = true;
}
}
private void drawChartOntoGC(GC gc) {
// do your drawing
}
Maybe not the prettiest way to do it, but it works pretty well.
Emil
"Chhil" <aaa@domain.invalid> wrote in message
news:d4j1tl$jed$1@news.eclipse.org...
> Hello Steve,
>
> I already use the SWT.NO_BACKGROUND do a fillrect at the beginning.
> I have a grid cells that get painted over and over again that causes the
> flicker.
>
> -thanks chhil
> Steve Northover wrote:
>> Please investigate the SWT.NO_BACKGROUND style.
>>
>> "Chhil" <aaa@domain.invalid> wrote in message
>> news:d4g7g0$q2s$1@news.eclipse.org...
>>
>>>Hi,
>>>
>>>I have a compopsite and a lsitview with a set of commands.
>>>In the composites paintControl(..) I traverse through the list from item
>>>0 to item n and interpret it and draw text, change
>>>backgrounds,foregrounds etc.
>>>I see a lot of flicker, how do I preven this flicker?
>>>Are there any rules of updating th composite in the painting.
>>>
>>>
>>>-chhil
>>
>>
|
|
|
Re: How to avoid Composite Flicker ? [message #454615 is a reply to message #454614] |
Mon, 25 April 2005 22:25 |
Eclipse User |
|
|
|
Originally posted by: aaa.domain.invalid
Emil,
Thanks for feedback/sample code
My code does not have any image manipulation using the graphic context.
The only image manipulation I have is the changing the fore ground and
background of the image once in the entire process and is saved for late
use.
My current problem is I have a grid of say 50x50 square (each square is
say 15x15 pixels) and based on criteria I may have to paint say an area
of 10x10 with a particular background /foreground usinf a graphic char
to place in it.
Since this happens in every paint call, the flicker seems to become very
visible. I may need some logic to determine what areas need to get
changed and some z order knowlege to not draw things that will get over
written.
I was hoping there was a way without having to add this additional logic.
|
|
| |
Re: How to avoid Composite Flicker ? [message #454617 is a reply to message #454616] |
Mon, 25 April 2005 23:16 |
Eclipse User |
|
|
|
Originally posted by: aaa.domain.invalid
Apologies...
The Image object misled me...
I think this will work out just fine...I will give it a try and let you
know how it worked out.
-chhil
Emil Crumhorn wrote:
> That code I posted does not have anything to do with image manipulation, it
> applies to any hand-drawn canvas which is what you're doing. All it does
> there is that when it redraws your canvas, (which is when you get flicker),
> is that it draws it into a buffer that you don't see, then draws the content
> of that buffer onto what you do see, thus, eliminating the flicker.
>
> Try it and see how it works.
>
> Emil
>
> "Chhil" <aaa@domain.invalid> wrote in message
> news:d4jqtf$lgv$3@news.eclipse.org...
>
>>Emil,
>>Thanks for feedback/sample code
>>
>>My code does not have any image manipulation using the graphic context.
>>The only image manipulation I have is the changing the fore ground and
>>background of the image once in the entire process and is saved for late
>>use.
>>
>>My current problem is I have a grid of say 50x50 square (each square is
>>say 15x15 pixels) and based on criteria I may have to paint say an area of
>>10x10 with a particular background /foreground usinf a graphic char to
>>place in it.
>>
>>Since this happens in every paint call, the flicker seems to become very
>>visible. I may need some logic to determine what areas need to get changed
>>and some z order knowlege to not draw things that will get over written.
>>
>>I was hoping there was a way without having to add this additional logic.
>
>
>
|
|
|
Re: How to avoid Composite Flicker ? [message #454618 is a reply to message #454617] |
Mon, 25 April 2005 23:57 |
Eclipse User |
|
|
|
Originally posted by: aaa.domain.invalid
Emil,
Worked out just fine....flicker free composite
Thanks..
-Chhil
Chhil wrote:
> Apologies...
> The Image object misled me...
> I think this will work out just fine...I will give it a try and let you
> know how it worked out.
> -chhil
>
>
> Emil Crumhorn wrote:
>
>> That code I posted does not have anything to do with image
>> manipulation, it applies to any hand-drawn canvas which is what you're
>> doing. All it does there is that when it redraws your canvas, (which
>> is when you get flicker), is that it draws it into a buffer that you
>> don't see, then draws the content of that buffer onto what you do see,
>> thus, eliminating the flicker.
>>
>> Try it and see how it works.
>>
>> Emil
>>
>> "Chhil" <aaa@domain.invalid> wrote in message
>> news:d4jqtf$lgv$3@news.eclipse.org...
>>
>>> Emil,
>>> Thanks for feedback/sample code
>>>
>>> My code does not have any image manipulation using the graphic
>>> context. The only image manipulation I have is the changing the fore
>>> ground and background of the image once in the entire process and is
>>> saved for late use.
>>>
>>> My current problem is I have a grid of say 50x50 square (each square
>>> is say 15x15 pixels) and based on criteria I may have to paint say an
>>> area of 10x10 with a particular background /foreground usinf a
>>> graphic char to place in it.
>>>
>>> Since this happens in every paint call, the flicker seems to become
>>> very visible. I may need some logic to determine what areas need to
>>> get changed and some z order knowlege to not draw things that will
>>> get over written.
>>>
>>> I was hoping there was a way without having to add this additional
>>> logic.
>>
>>
>>
>>
|
|
|
Re: How to avoid Composite Flicker ? [message #454622 is a reply to message #454618] |
Tue, 26 April 2005 04:40 |
Konstantin Scheglov Messages: 555 Registered: July 2009 |
Senior Member |
|
|
Chhil:
BTW, I see new style in SWT in 3.1:
/**
* Style constant to indicate double buffering (value is 1<<29).
* <p><b>Used By:</b><ul>
* <li><code>Control</code></li>
* </ul></p>
*
* @since 3.1
*/
public static final int DOUBLE_BUFFERED = 1 << 29;
and I saw in CVS, that it is used in Composite, so probably soon we
will able just specify this style without requirement to create image in
our code.
> Worked out just fine....flicker free composite
> Thanks..
> -Chhil
> Chhil wrote:
>
>> Apologies...
>> The Image object misled me...
>> I think this will work out just fine...I will give it a try and let
>> you know how it worked out.
>> -chhil
>>
>>
>> Emil Crumhorn wrote:
>>
>>> That code I posted does not have anything to do with image
>>> manipulation, it applies to any hand-drawn canvas which is what
>>> you're doing. All it does there is that when it redraws your canvas,
>>> (which is when you get flicker), is that it draws it into a buffer
>>> that you don't see, then draws the content of that buffer onto what
>>> you do see, thus, eliminating the flicker.
>>>
>>> Try it and see how it works.
>>>
>>> Emil
>>>
>>> "Chhil" <aaa@domain.invalid> wrote in message
>>> news:d4jqtf$lgv$3@news.eclipse.org...
>>>
>>>> Emil,
>>>> Thanks for feedback/sample code
>>>>
>>>> My code does not have any image manipulation using the graphic
>>>> context. The only image manipulation I have is the changing the fore
>>>> ground and background of the image once in the entire process and is
>>>> saved for late use.
>>>>
>>>> My current problem is I have a grid of say 50x50 square (each square
>>>> is say 15x15 pixels) and based on criteria I may have to paint say
>>>> an area of 10x10 with a particular background /foreground usinf a
>>>> graphic char to place in it.
>>>>
>>>> Since this happens in every paint call, the flicker seems to become
>>>> very visible. I may need some logic to determine what areas need to
>>>> get changed and some z order knowlege to not draw things that will
>>>> get over written.
>>>>
>>>> I was hoping there was a way without having to add this additional
>>>> logic.
>>>
>>>
>>>
>>>
>>>
--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)
Konstantin Scheglov,
Google, Inc.
|
|
|
Re: How to avoid Composite Flicker ? [message #454623 is a reply to message #454622] |
Tue, 26 April 2005 04:49 |
Eclipse User |
|
|
|
Originally posted by: aaa.domain.invalid
That would be very helpful...thanks for the update.
-chhil
Konstantin Scheglov wrote:
> Chhil:
>
> BTW, I see new style in SWT in 3.1:
>
> /**
> * Style constant to indicate double buffering (value is 1<<29).
> * <p><b>Used By:</b><ul>
> * <li><code>Control</code></li>
> * </ul></p>
> *
> * @since 3.1
> */
> public static final int DOUBLE_BUFFERED = 1 << 29;
>
> and I saw in CVS, that it is used in Composite, so probably soon we
> will able just specify this style without requirement to create image in
> our code.
>
>
>
>> Worked out just fine....flicker free composite
>> Thanks..
>> -Chhil
>> Chhil wrote:
>>
>>> Apologies...
>>> The Image object misled me...
>>> I think this will work out just fine...I will give it a try and let
>>> you know how it worked out.
>>> -chhil
>>>
>>>
>>> Emil Crumhorn wrote:
>>>
>>>> That code I posted does not have anything to do with image
>>>> manipulation, it applies to any hand-drawn canvas which is what
>>>> you're doing. All it does there is that when it redraws your canvas,
>>>> (which is when you get flicker), is that it draws it into a buffer
>>>> that you don't see, then draws the content of that buffer onto what
>>>> you do see, thus, eliminating the flicker.
>>>>
>>>> Try it and see how it works.
>>>>
>>>> Emil
>>>>
>>>> "Chhil" <aaa@domain.invalid> wrote in message
>>>> news:d4jqtf$lgv$3@news.eclipse.org...
>>>>
>>>>> Emil,
>>>>> Thanks for feedback/sample code
>>>>>
>>>>> My code does not have any image manipulation using the graphic
>>>>> context. The only image manipulation I have is the changing the
>>>>> fore ground and background of the image once in the entire process
>>>>> and is saved for late use.
>>>>>
>>>>> My current problem is I have a grid of say 50x50 square (each
>>>>> square is say 15x15 pixels) and based on criteria I may have to
>>>>> paint say an area of 10x10 with a particular background /foreground
>>>>> usinf a graphic char to place in it.
>>>>>
>>>>> Since this happens in every paint call, the flicker seems to become
>>>>> very visible. I may need some logic to determine what areas need to
>>>>> get changed and some z order knowlege to not draw things that will
>>>>> get over written.
>>>>>
>>>>> I was hoping there was a way without having to add this additional
>>>>> logic.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>
>
|
|
|
Goto Forum:
Current Time: Fri Apr 26 08:40:40 GMT 2024
Powered by FUDForum. Page generated in 0.02828 seconds
|