Reducing screen flicker

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Reducing screen flicker

Frank Sonnemans-3
I wrote a small app that displays a large digital clock. The display is
updated once per second using a trigger send by the app's model. The
display is a standard read-only text presenter.

I would like to get more smoooth screen updates. Especially when my
system is busy with other applications the screen starts to flicker. Is
there an "easy" way to improve this?

Regards,


Frank


Reply | Threaded
Open this post in threaded view
|

Re: Reducing screen flicker

Ian Bartholomew-6
Frank,

> I wrote a small app that displays a large digital clock. The display is
> updated once per second using a trigger send by the app's model. The
> display is a standard read-only text presenter.
>
> I would like to get more smoooth screen updates. Especially when my
> system is busy with other applications the screen starts to flicker. Is
> there an "easy" way to improve this?

I'm quite surprised that the screen flickers if you are only updating once a
second, that's the sort of thing you might see if you were continually
updating. It might be worth checking, just put a "Sound bell." immediately
before the trigger statement in your model and check you only get one beep
per sec.

It's amazing how much useful debugging you can do with the system speaker
;-)

If that was not the problem then I don't really know what might be causing
it. You could try either lowering the priority of the update (so that it was
only attempted when nothing else was happening) or raising the priority (so
it took precedence over other operations). That would only relate to
precedence within Dolphin though, I don't know if that would have any effect
between applications and how much processor time Dolphin was given.

If all else fails then you could post your code here and we could try to
spot a problem?

Regards
    Ian


Reply | Threaded
Open this post in threaded view
|

Re: Reducing screen flicker

Blair McGlashan
In reply to this post by Frank Sonnemans-3
"Frank" <[hidden email]> wrote in message
news:[hidden email]...
> I wrote a small app that displays a large digital clock. The display is
> updated once per second using a trigger send by the app's model. The
> display is a standard read-only text presenter.
>
> I would like to get more smoooth screen updates. Especially when my
> system is busy with other applications the screen starts to flicker. Is
> there an "easy" way to improve this?

I would go along with what Ian says; it seems odd that an update once per
second is causing flicker, so perhaps it is happening a lot more frequently
than that.

BTW: When doing this sort of timer based repaint it is generally better to
just invalidate the view, and have it repaint when CPU time is available,
than to attempt to repaint it synchronously in response to a trigger.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: Reducing screen flicker

Frank Sonnemans-3
The updates are done once per second as follows:

In the clock model:
run

    updater := [ [ self step.

    (Delay forMilliseconds: 1000) wait. ] repeat ] forkAt: Processor
userInterruptPriority.



step

"Private - execute update step"

    time := Time now.

    self trigger: #clockUpdated.


In the presenter:
createComponents

    super createComponents.

    timePresenter := self add: TimePresenter new name: 'timeView'.

model: aClock

    super model: aClock.

    timePresenter model: (aClock aspectValue: #time).

    timePresenter model aspectTriggers: #clockUpdated.



However the clock display is in Arial 72 points. I think that is the cause
of the problem. When the system is loaded you start noticing the update of
the large text.



I have similar problems with an app that triggers an update 5 times per
second on many presenters. I will try to do things the other way around,
having the shell object invalidate it's view once per second and see if this
works better.





"Blair McGlashan" <[hidden email]> wrote in message
news:a42vm9$1bqn02$[hidden email]...

> "Frank" <[hidden email]> wrote in message
> news:[hidden email]...
> > I wrote a small app that displays a large digital clock. The display is
> > updated once per second using a trigger send by the app's model. The
> > display is a standard read-only text presenter.
> >
> > I would like to get more smoooth screen updates. Especially when my
> > system is busy with other applications the screen starts to flicker. Is
> > there an "easy" way to improve this?
>
> I would go along with what Ian says; it seems odd that an update once per
> second is causing flicker, so perhaps it is happening a lot more
frequently

> than that.
>
> BTW: When doing this sort of timer based repaint it is generally better to
> just invalidate the view, and have it repaint when CPU time is available,
> than to attempt to repaint it synchronously in response to a trigger.
>
> Regards
>
> Blair
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Reducing screen flicker

Ian Bartholomew-6
Frank,

> However the clock display is in Arial 72 points. I think that is the cause
> of the problem. When the system is loaded you start noticing the update of
> the large text.

I can see the flicker you are talking about. In the little app I set up it
occurs for three consecutive updates with intervals of around 25 to 30
seconds between occurrences.  It seems too regular to be random and looks a
bit like a high priority, background Windows process that interferes with
the redraw.  On my machine, and it may _only_ be my machine, if you change
the Delay count in 1 mS steps you can see the flicker interval pattern
change.

I've no idea how (if) you can solve it though, nothing I tried seems to make
a difference. Sorry.

Regards
    Ian


Reply | Threaded
Open this post in threaded view
|

Re: Reducing screen flicker

Frank Sonnemans-3
Ian,

The screen flicker is something I would like to resolve. Especially since I
am looking at Dolphin for a project at work, which is providing a UI for
laser welding systems. In the latter, I will have many textpresenters which
need to be updated at least once per second. The only solution I see is to
do something like this:

- Create textviews which check once every second if their model is changed.
If so they will invalidate their view to execute an update.

- The textview will need to draw in a background buffer and bitblt the new
view into the main screen.

I think this can be done by just subclassing some standard views to create
"double buffered" views with a user selectable update frequency. What I
don't know is how to draw offscreen in Dolphin. Do you have any pointers to
examples?

Regards,


Frank

"Ian Bartholomew" <[hidden email]> wrote in message
news:jdh98.5246$k91.272767@wards...
> Frank,
>
> > However the clock display is in Arial 72 points. I think that is the
cause
> > of the problem. When the system is loaded you start noticing the update
of
> > the large text.
>
> I can see the flicker you are talking about. In the little app I set up it
> occurs for three consecutive updates with intervals of around 25 to 30
> seconds between occurrences.  It seems too regular to be random and looks
a
> bit like a high priority, background Windows process that interferes with
> the redraw.  On my machine, and it may _only_ be my machine, if you change
> the Delay count in 1 mS steps you can see the flicker interval pattern
> change.
>
> I've no idea how (if) you can solve it though, nothing I tried seems to
make
> a difference. Sorry.
>
> Regards
>     Ian
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Reducing screen flicker

Ian Bartholomew-6
Frank,

> The screen flicker is something I would like to resolve. Especially since
I
> am looking at Dolphin for a project at work, which is providing a UI for
> laser welding systems.

I don't think, although I could well be wrong, that this is a Dolphin
problem. Tracing through the code it is Windows that seems to be
interrupting the visual update.  I suppose the only way of checking would to
be to implement the same thing is another environment (Smalltalk or
something else).

> I think this can be done by just subclassing some standard views to create
> "double buffered" views with a user selectable update frequency. What I
> don't know is how to draw offscreen in Dolphin. Do you have any pointers
to
> examples?

I was going to suggest the graphics route but didn't as I thought it might
get a bit too "messy" for you. Anyway, you don't need subclass views as you
can just blit the contents of a bitmap onto an ImagePresenter view, as in
the attached bare bones package. It seems to work without flickering on my
box but you will have to fiddle with the window sizes/background a bit.

Regards
    Ian












begin 666 Test.pac
M?"!P86-K86=E('P-"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F5S;W5R
M8V5S(B$-"@T**%)E<V]U<F-E261E;G1I9FEE<B!C;&%S<SH@5&5S=%-H96QL
M(&YA;64Z("=$969A=6QT('9I97<G*2!A<W-I9VXZ("A/8FIE8W0@9G)O;4)I
M;F%R>5-T;W)E0GET97,Z#0HH0GET94%R<F%Y(&9R;VU(97A3=')I;F<Z("<R
M,34S-30T,C(P,S R,#0V,#(P0S P,#$P,# P,# U-C8Y-C4W-S4R-C4W,S9&
M-S4W,C8S-C4P,# P,# P,#!%,#$R-# P-3,U-#0R-3(V-3<S-D8W-3<R-C,V
M-34S-30T,C0R-SDW-#8U-#$W,C<R-C$W.30Q-C,V,S8U-S,W,S9&-S(U,#<R
M-D8W.#<Y,# P,# P,# S-C P,#DP,#0R-SDW-#8U-#$W,C<R-C$W.3@U,#0P
M,# P,C$U,S4T-#(R,#,P,C T13 X,$,P,#!!,# P,# P-3,U-#0R-38V.38U
M-S<U,#<R-D8W.#<Y,# P,# P,# T13 R,$0P,# Q,# P,# P-3,U-#0R-#,V
M0S8Q-S,W,S4P-S(V1C<X-SDP,# P,# P,#,V,# P-C P-3,W-#<R-CDV138W
M,#<P,# P,# T-#9&-D,W,#8X-CDV13DR,# P,# P,#DP,# P,# U,S8X-C4V
M0S9#-38V.38U-S<R-C P,#4P,#0Q-S(W,C8Q-SDQ0C P,# P,# P,# P,# P
M,# P,# P,#!#,C P,# P,# R,# P,# P,#$P,#E%,#$P,3 P,#(P,#8P,# P
M,# P,# P,# P,# P,# P,# P,# P,# P,# P,#<P,C P,# P,# P,# P,# P
M,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,$4P,C%!,# U,S4T-#(T
M.38T-C4V13<T-CDW-#<Y-#0V.38S-S0V.39&-D4V,3<R-SDU,#<R-D8W.#<Y
M,# P,# P,# W03 P,# P,# P,# P,# P03 P,# P,# Y,C P,# P,#$R,# P
M,# P-#DV-#8U-D4W-#8Y-S0W.30T-CDV,S<T-CDV1C9%-C$W,C<Y0S(P,# P
M,# P,C P,# P,#5!,# P,# P,# P,# P,# W03 P,# P,# P,# P,# P03 P
M,# P,# Y,C P,# P,#!#,# P,# P-3,W-#8Q-S0V.38S-#(V.3<T-D0V,3<P
M0S(P,# P,# Q,3 P,# P,# P,# P,# P-C P,# P,#!#,C P,# P,# R,# P
M,# P,S8P,#!#,# T0S8Q-S(V-S8U-#DV13<T-C4V-S8U-S(P-# P,# P,#!%
M,#$X,#0T,#$P,# P,# T,# Q,# P,#0V,#0P0C P,#(P,# P,# U-C8Q-D,W
M-38U-#@V1C9#-C0V-3<R,# P,# P,# P,# P,# P,# P,# P,# P,#8P,3$P
M,# T,S9&-D0W,#8Q-S(V.3<S-D8V134P-D8V0S8Y-C,W.3 P,# P,# P,#8P
M,C W,# T1#8U-S,W,S8Q-C<V-3 P,# P,# P,$4P,3!%,# U,S4T-#(U,S<Y
M-D0V,C9&-D,U,#<R-D8W.#<Y,# P,# P,# Y,C P,# P,# R,# P,# P,T0S
M1$,R,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P-S P
M,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# Y
M,C Q,# P,# T,# P,# P1D5&,T0U-S<P-C R,$0P,#1%-S4V0S9#-#,V1C9%
M-S8V-3<R-S0V-3<R,# P,# P,# P,# P,# P,# P,# P,# P,C P,# P,# P
M,# P,# P,# V,#$P1C P-$0V-3<S-S,V,38W-C4U,S8U-S$W-38U-D4V,S8U
M,# P,# P,# P13 R,3(P,#4S-30T,C0S-D8V0S9#-C4V,S<T-CDV1C9%-3 W
M,C9&-S@W.3 P,# P,# P-T$P,# P,# P,# P,# P,$$P,# P,# P.3(P,# P
M,# Q,3 P,# P,#1&-S(V-#8U-S(V-38T-#,V1C9#-D,V-38S-S0V.39&-D5#
M,C P,# P,# Q,# P,# P,#8P,S!",# T1#8U-S,W,S8Q-C<V-34S-C4V138T
M,# P,# P,# Q03 R,# P,# P,# P,# P.3(P,# P,# Q,# P,# P,#8S-S(V
M-38Q-S0V-30Q-S0S038U-S@W-#8U-D4W-#-!0S(P,# P,# P,C P,# P,# V
M,#(P-3 P-3 V1C8Y-D4W-# P,# P,# P,48P,# P,# Q-3 P,# P,#0R,#,P
M,# P,# P,# P,# V-S S,# P,#1",#$P,# P-# P,3 P,# P-C Q,$8P,#4W
M-#DT130T-$8U-S4P-$,T,30S-#4T1#0U-$4U-# P,# P,# P,S8P,# Y,# T
M,C<Y-S0V-30Q-S(W,C8Q-SDR0S P,# P,#)#,# P,# P,# P,# P,# P,3 P
M,# P,$9&1D9&1D9&1D9&1D9&1D9&1D9&1D9&1D9&1D9&1D9&,$8P,# P,# P
M03 P,# P,$,R,#$P,# P048P,# P,#!!03 R,# P,# P,# P,# P0S P,C P
M,#!#,C P,# P,# P,# P,# P-#(P,S P,# P,# P,# P,$,Q,# P,# P0S$P
M,# P,# P,# P,# P,#$S,# P,# P.3(P,# P,# P-3 P,# P,#8Y-D0V,38W
M-C4P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,#$P
M,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# P,# Q,# P,# P
M,# P,# P,# P,# P,# P,#@R,#(P,# P,# P,# P,#!!03 R,# P,# P,# P
M,# P0S P,C P,#!#,C P,# P,# R,# P,# P1C(P,C P,# P,# P,# P,#$P
M,#,P,# P0S(P,# P,# P,C P,# P,#0R,#,P,# P,# P,# P,# P0C P,# P
M,#!",# P,# P-#(P,S P,# P,# P,# P,$$S,#0P,# P0S<P,3 P,# V,# P
M,# P,$8R,#(P,# P,# P,# P,# Q03 R,# P,# P,# P,# P.3(P,# P,# P
M.# P,# P,#9$-C4V13<U-#(V,3<R,T%#,C P,# P,# Q,# P,# P,# P,# P
M,# V,# P,# P,#<R,#,P,# P,# P,# P,# Y,C S,# P,#)#,# P,# P,D,P
M,# P,# P,# P,# P,# P,# P,# P1D9&1D9&1D9&1D9&1D9&1D9&1D9&1D9&
M1D9&1D9&1D8P-3 P,# P,# U,# P,# P-38P,C P,#!%.# P,# P,$%!,#(P
M,# P,# P,# P,#!#,# R,# P,$,R,# P,# P,#$P,# P,# T,# Q,# P,$0P
M,#,P,# P,# P,# P,# Q-3 P,# P,#0V,#4P-# P,#,P,# P,# T.38S-D8V
M13 P,# P,# P,# P,# P,# Q,# P,# P,#!%,#(Q,3 P-3,U-#0R-3,V.39%
M-C<V0S8U-S0V1C9%-3 W,C9&-S@W.3 P,# P,# P-$4P,C!$,# P,3 P,# P
M,#4S-30T,C0S-D,V,3<S-S,U,#<R-D8W.#<Y,# P,# P,# S-C P,#8P,#4S
M-S0W,C8Y-D4V-S W,# P,# P-#0V1C9#-S V.#8Y-D4Q,C Q,# P,#$X,# P
M,# P-#DV1#8Q-C<V-34R-C4V0S8Q-S0V.3<V-C4T-C8Y-D,V-31#-D8V,S8Q
M-S0V1C<R,$4P,3!%,# U,S4T-#(U,S<Y-D0V,C9&-D,U,#<R-D8W.#<Y,# P
M,# P,# Q,C Q,# P,# W,# P,# P-C,W-3<R-S(V-39%-S0Q,C Q,# P,#!$
M,# P,# P-3,V.#8U-D,V0S4V-CDV-3<W,D4V.38S-D8P13 R,48P,#4S-30T
M,C0U-S@W-#8U-S(V138Q-D,U,C8U-S,V1C<U-S(V,S8U-$,V.38R-S(V,3<R
M-SDU,#<R-D8W.#<Y,# P,# P,# Q,C Q,# P,#$P,# P,# P-C0V1C9#-S V
G.#8Y-D4V-#<R,S S,#,T,D4V-#9#-D,P,# P,# P,"<I*2$-"@T*
`
end


Reply | Threaded
Open this post in threaded view
|

Re: Reducing screen flicker

Randy Manning
In reply to this post by Frank Sonnemans-3
"Frank" <[hidden email]> wrote in message
news:[hidden email]...

> I wrote a small app that displays a large digital clock. The display is
> updated once per second using a trigger send by the app's model. The
> display is a standard read-only text presenter.
>
> I would like to get more smoooth screen updates. Especially when my
> system is busy with other applications the screen starts to flicker. Is
> there an "easy" way to improve this?
>
> Regards,
>
>
> Frank
>

Frank, I recreated and solved your flickering problem.

In the Model:
*************************************

Model subclass: #SimpleClockModel
 instanceVariableNames: 'time updater'
 classVariableNames: ''
 poolDictionaries: ''
 classInstanceVariableNames: ''

run

 updater := [[ self step.
 (Delay forMilliseconds: 1000) wait. ] repeat ] forkAt: Processor
userInterruptPriority.

step
 "execute update step"

 self time: Time now.
 self trigger: #clockUpdated.

time
 "Answer the value of the receiver's ''time'' instance variable."

 ^time

time: aTime
 "Set the value of the receiver's ''time'' instance variable to the
argument, aTime."

 time := aTime

**************************************
Make sure to uncheck the Private box on the #run #time and methods, they
must be Public methods.


In the Presenter:
I put two presenters in a ShellView (for compairison). In the ViewComposer -
A read only TextPresenter and an
ImagePresenter(Basic image) not (Default view).
Your ImagePresenter, in the ViewComposer must be an instance of ImageView
not StaticBitmap. If it is not,
then mutate it to an ImageView.
**************************************

Shell subclass: #SimpleClockShell
 instanceVariableNames: 'timePresenter imagePresenter bitmap'
 classVariableNames: ''
 poolDictionaries: ''
 classInstanceVariableNames: ''

bitmap
 "Private - Answer the value of the receiver's ''bitmap'' instance
variable."

 ^bitmap

bitmap: aBitmap
 "Private - Set the value of the receiver's ''bitmap'' instance variable to
the argument, aBitmap."

 bitmap := aBitmap

createComponents

 super createComponents.

 timePresenter := self add: TextPresenter new name: 'timeView'.
 imagePresenter := self add: ImagePresenter new name: 'drawView'.

createSchematicWiring
 "Create the trigger wiring for the receiver. At this stage the
initialization
 is complete and the view is open"

 super createSchematicWiring.

 self model when: #clockUpdated send: #updateTimeDisplay to: self.

drawText: aString atClientPoint: aClientPoint

 | bmpCnvs |
 bmpCnvs := self bitmap canvas.   "get the canvas"
 bmpCnvs setTextColor: Color black.
 bmpCnvs setBkMode: TRANSPARENT.
 "erase the bitmap to its backcolor"
 bmpCnvs erase.
 "draw the text into the cleared bitmap"
 bmpCnvs text: aString at: aClientPoint.

model: aClock

 super model: aClock.
 timePresenter model: (aClock aspectValue: #time).
 timePresenter model aspectTriggers: #clockUpdated.

onViewOpened
 "Handler for view opened. use this method instead of # initialize."

 | cnvs bmpCnvs |
 super onViewOpened.

 "create the view's bitmap and store it in the bitmap instance variable."
 cnvs := imagePresenter view canvas.
 self bitmap: (Bitmap compatible: cnvs extent: imagePresenter view
clientRectangle extent).
 imagePresenter value: self bitmap.

 "set the font"
 self bitmap canvas font:  (Font name: 'Arial' pixelSize: 72) beBold.
 "set the bitmap's backcolor"
 bmpCnvs := self bitmap canvas.
 "a default backcolor"
 bmpCnvs backcolor: Color  gray.
 "erase the bitmap to its backcolor"
 bmpCnvs erase.

 model run.

updateTimeDisplay

 |cnvs rect |
 Sound bell.
 "draw text to the bitmap - so that the ImageView can repaint
 its view from it as necessary - moving overlapping windows ect..."
 self drawText: (self model time) displayString atClientPoint: 0@0.
 "If we invalidate here, instead of doing the bitBlt below, we get the
 screen flicker (flickering appears to be caused by the invalidation
sequence.)"
 "imagePresenter view invalidate."

 "instead, bitBlt from the bitmap to the view - We get no screen flicker
here!"
 cnvs := imagePresenter view canvas.
 rect := imagePresenter view clientRectangle.
 self bitmap drawOn: cnvs at: rect origin from: rect origin extent: rect
extent.

***************************************


Good Luck
 Randy


Reply | Threaded
Open this post in threaded view
|

Re: Reducing screen flicker

Randy Manning
In reply to this post by Frank Sonnemans-3
"Frank" <[hidden email]> wrote in message
news:[hidden email]...

> I wrote a small app that displays a large digital clock. The display is
> updated once per second using a trigger send by the app's model. The
> display is a standard read-only text presenter.
>
> I would like to get more smoooth screen updates. Especially when my
> system is busy with other applications the screen starts to flicker. Is
> there an "easy" way to improve this?
>
> Regards,
>
>
> Frank
>

Frank,

Forgot to mention this step in my presenter code:
****************************

SimpleClockShell class>>defaultModel
 "Answer a default model to be assigned to the receiver when it
 is initialized."

 ^SimpleClockModel new

****************************

In a WorkSpace, evaluate:

 SimpleClockShell show.


Regards
 Randy