mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 10:43:24 +00:00
added DEBUG code to measure redraw time if control key is held down during an update.
This commit is contained in:
parent
649fc7265e
commit
18a5529ed4
@ -32,7 +32,9 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsIEnumerator.h"
|
||||
|
||||
#include <Appearance.h>
|
||||
#include <Timer.h>
|
||||
|
||||
#include "nsplugindefs.h"
|
||||
#include "nsMacEventHandler.h"
|
||||
@ -823,6 +825,19 @@ NS_IMETHODIMP nsWindow::Update()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static Boolean control_key_down()
|
||||
{
|
||||
EventRecord event;
|
||||
::OSEventAvail(0, &event);
|
||||
return (event.modifiers & controlKey) != 0;
|
||||
}
|
||||
|
||||
static long long microseconds()
|
||||
{
|
||||
unsigned long long micros;
|
||||
Microseconds((UnsignedWide*)µs);
|
||||
return micros;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// HandleUpdateEvent
|
||||
@ -874,9 +889,24 @@ nsresult nsWindow::HandleUpdateEvent()
|
||||
::OffsetRect(&macRect, -bounds.x, -bounds.y);
|
||||
rect.SetRect(macRect.left, macRect.top, macRect.right - macRect.left, macRect.bottom - macRect.top);
|
||||
|
||||
#if DEBUG
|
||||
// measure the time it takes to refresh the window, if the control key is down.
|
||||
unsigned long long start, finish;
|
||||
Boolean measure_duration = control_key_down();
|
||||
if (measure_duration)
|
||||
start = microseconds();
|
||||
#endif
|
||||
|
||||
// update the widget
|
||||
UpdateWidget(rect, renderingContext);
|
||||
|
||||
#if DEBUG
|
||||
if (measure_duration) {
|
||||
finish = microseconds();
|
||||
printf("update took %g microseconds.\n", double(finish - start));
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_RELEASE(renderingContext);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user