The Trunk: MorphicExtras-ct.260.mcz

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

The Trunk: MorphicExtras-ct.260.mcz

commits-2
Marcel Taeumel uploaded a new version of MorphicExtras to project The Trunk:
http://source.squeak.org/trunk/MorphicExtras-ct.260.mcz

==================== Summary ====================

Name: MorphicExtras-ct.260
Author: ct
Time: 4 September 2019, 3:53:54.175698 pm
UUID: cab65f78-e646-cc40-9d0f-c16114d1bb44
Ancestors: MorphicExtras-mt.259

Refactor FrameRateMorph: Add accessors for updateInterval and expose measure data. Use TimeStamp instead of Time to avoid clock wrap around.

=============== Diff against MorphicExtras-mt.259 ===============

Item was changed:
  StringMorph subclass: #FrameRateMorph
+ instanceVariableNames: 'lastDisplayTime framesSinceLastDisplay updateInterval mSecsPerFrame framesPerSec'
- instanceVariableNames: 'lastDisplayTime framesSinceLastDisplay'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'MorphicExtras-Demo'!

Item was added:
+ ----- Method: FrameRateMorph>>framesPerSec (in category 'accessing') -----
+ framesPerSec
+
+ ^ framesPerSec!

Item was changed:
  ----- Method: FrameRateMorph>>initialize (in category 'initialization') -----
  initialize
  "initialize the state of the receiver"
  super initialize.
  ""
+ lastDisplayTime := TimeStamp new.
- lastDisplayTime := 0.
  framesSinceLastDisplay := 0.
+ self updateInterval: 500 milliSeconds.
  self font: (Preferences standardMenuFont emphasized: 1).
  !

Item was added:
+ ----- Method: FrameRateMorph>>mSecsPerFrame (in category 'accessing') -----
+ mSecsPerFrame
+
+ ^ mSecsPerFrame!

Item was changed:
  ----- Method: FrameRateMorph>>step (in category 'stepping and presenter') -----
  step
  "Compute and display (every half second or so) the current framerate"
 
+ | now timePassed newContents |
- | now mSecs mSecsPerFrame framesPerSec newContents |
  framesSinceLastDisplay := framesSinceLastDisplay + 1.
+ now := TimeStamp now.
+ timePassed := now - lastDisplayTime.
+ (timePassed > self updateInterval) ifTrue:
+ [| mSecs |
+ mSecs := timePassed asMilliSeconds.
+ mSecsPerFrame := mSecs // framesSinceLastDisplay.
- now := Time millisecondClockValue.
- mSecs := now - lastDisplayTime.
- (mSecs > 500 or: [mSecs < 0 "clock wrap-around"]) ifTrue:
- [mSecsPerFrame := mSecs // framesSinceLastDisplay.
  framesPerSec := (framesSinceLastDisplay * 1000) // mSecs.
  newContents := mSecsPerFrame printString, ' mSecs (', framesPerSec printString, ' frame', (framesPerSec = 1 ifTrue: [''] ifFalse: ['s']), '/sec)'.
  self contents: newContents.
  lastDisplayTime := now.
  framesSinceLastDisplay := 0]
  ifFalse:
  ["Ensure at least one pixel is drawn per frame"
  Preferences higherPerformance ifTrue: [self invalidRect: (self position extent: 1@1)]]!

Item was added:
+ ----- Method: FrameRateMorph>>updateInterval (in category 'accessing') -----
+ updateInterval
+
+ ^ updateInterval!

Item was added:
+ ----- Method: FrameRateMorph>>updateInterval: (in category 'accessing') -----
+ updateInterval: aNumber
+
+ updateInterval := aNumber!