Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to avoid Composite Flicker ?
How to avoid Composite Flicker ? [message #454555] Sun, 24 April 2005 09:35 Go to next message
Eclipse UserFriend
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 #454605 is a reply to message #454555] Mon, 25 April 2005 10:36 Go to previous messageGo to next message
Eclipse UserFriend
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 #454608 is a reply to message #454605] Mon, 25 April 2005 11:18 Go to previous messageGo to next message
Eclipse UserFriend
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 17:28 Go to previous messageGo to next message
Eclipse UserFriend
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 18:25 Go to previous messageGo to next message
Eclipse UserFriend
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 #454616 is a reply to message #454615] Mon, 25 April 2005 18:44 Go to previous messageGo to next message
Eclipse UserFriend
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 #454617 is a reply to message #454616] Mon, 25 April 2005 19:16 Go to previous messageGo to next message
Eclipse UserFriend
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 19:57 Go to previous messageGo to next message
Eclipse UserFriend
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 00:40 Go to previous messageGo to next message
Eclipse UserFriend
Chhil:

BTW, I see new style in SWT in 3.1:

/**
* Style constant to indicate double buffering (value is 1&lt;&lt;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)
Re: How to avoid Composite Flicker ? [message #454623 is a reply to message #454622] Tue, 26 April 2005 00:49 Go to previous message
Eclipse UserFriend
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&lt;&lt;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.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>
>
Previous Topic:Tree and Table
Next Topic:Which function gets called first
Goto Forum:
  


Current Time: Mon Jul 28 12:04:40 EDT 2025

Powered by FUDForum. Page generated in 0.08520 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top