Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
nsQDFlushPort Class Reference

#include <nsQDFlushManager.h>

Inheritance diagram for nsQDFlushPort:
Inheritance graph
Collaboration diagram for nsQDFlushPort:
Collaboration graph

List of all members.

Public Member Functions

void notify (in nsITimer timer)

Protected Member Functions

 nsQDFlushPort (CGrafPtr aPort)
 ~nsQDFlushPort ()
void Init (CGrafPtr aPort)
void Destroy ()
void FlushPortBuffer (RgnHandle aRegion)
PRInt64 TimeUntilFlush (AbsoluteTime aNow)

Protected Attributes

CGrafPtr mPort
AbsoluteTime mLastFlushTime
nsCOMPtr< nsITimermFlushTimer
PRPackedBool mFlushTimerRunning

Static Protected Attributes

static const PRUint32 kRefreshRateHz = 30


class nsQDFlushManager

Detailed Description

Definition at line 58 of file nsQDFlushManager.h.

Constructor & Destructor Documentation

nsQDFlushPort::nsQDFlushPort ( CGrafPtr  aPort) [protected]

Definition at line 169 of file nsQDFlushManager.cpp.

: mNext(nsnull)
, mPort(aPort)
, mLastFlushTime((AbsoluteTime){0, 0})

Definition at line 178 of file nsQDFlushManager.cpp.

  // Everything should have been taken care of by Destroy().

Member Function Documentation

void nsQDFlushPort::Destroy ( void  ) [protected]

Definition at line 200 of file nsQDFlushManager.cpp.

void nsQDFlushPort::FlushPortBuffer ( RgnHandle  aRegion) [protected]

Definition at line 218 of file nsQDFlushManager.cpp.

  AbsoluteTime now = ::UpTime();
  PRInt64 timeUntilFlush = TimeUntilFlush(now);

  if (!mFlushTimerRunning && timeUntilFlush < 0)
    // If past the time for the next acceptable flush, flush now.
    ::QDFlushPortBuffer(mPort, aRegion);
    mLastFlushTime = now;
    // If it's not time for the next flush yet, or if the timer is running
    // indicating that an update is pending, just mark the dirty region.
    ::QDAddRegionToDirtyRegion(mPort, aRegion);

    if (!mFlushTimerRunning)
      // No flush scheduled?  No problem.
      if (!mFlushTimer)
        // No timer object?  No problem.
        nsresult err;
        mFlushTimer = do_CreateInstance(";1", &err);
        NS_ASSERTION(NS_SUCCEEDED(err), "Could not instantiate flush timer.");
      if (mFlushTimer)
        // Start the clock, with the timer firing at the already-calculated
        // time until the next flush.  Nanoseconds (1E-9) were used above,
        // but nsITimer is big on milliseconds (1E-3), so divide by 1E6.
        // Any time that was consumed between the ::UpTime call and now
        // will be lost.  That's not so bad in the usual case, it's a tiny
        // bit less not so bad if a timer object didn't exist yet and was
        // created.  It's better to update slightly less frequently than
        // the target than slightly more frequently.
        mFlushTimer->InitWithCallback(this, (PRUint32)(timeUntilFlush/1E6),
        mFlushTimerRunning = PR_TRUE;

Here is the call graph for this function:

void nsQDFlushPort::Init ( CGrafPtr  aPort) [protected]

Definition at line 189 of file nsQDFlushManager.cpp.

  mPort = aPort;
void nsITimerCallback::notify ( in nsITimer  timer) [inherited]
aTimerthe timer which has expired
PRInt64 nsQDFlushPort::TimeUntilFlush ( AbsoluteTime  aNow) [protected]

Definition at line 265 of file nsQDFlushManager.cpp.

  Nanoseconds elapsed = ::AbsoluteDeltaToNanoseconds(aNow, mLastFlushTime);

  // nano = 1E-9 and the desired refresh rate is in Hz, so 1E9/kRefreshRateHz
  // gives the interval between updates in nanoseconds.
  return S64Subtract(U64SetU(1E9/kRefreshRateHz),

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class nsQDFlushManager [friend]

Definition at line 61 of file nsQDFlushManager.h.

Member Data Documentation

const PRUint32 nsQDFlushPort::kRefreshRateHz = 30 [static, protected]

Definition at line 78 of file nsQDFlushManager.h.

Definition at line 84 of file nsQDFlushManager.h.

Definition at line 85 of file nsQDFlushManager.h.

AbsoluteTime nsQDFlushPort::mLastFlushTime [protected]

Definition at line 83 of file nsQDFlushManager.h.

Definition at line 81 of file nsQDFlushManager.h.

Definition at line 82 of file nsQDFlushManager.h.

The documentation for this class was generated from the following files: