Closed Bug 563864 Opened 15 years ago Closed 15 years ago

Add window.mozPaintCount API

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: roc, Assigned: roc)

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

I would like chrome and even Web content to be able to easily and accurately measure frames-per-second graphics performance.

Therefore I propose adding a new API to the Window object: mozPaintCount, a readonly 'long long' attribute, accessible to Web content as well as chrome. This would simply return the number of times the presshell for the current document in the window has been rendered to the screen.

I have a patch to implement this. This makes it really easy for Web content to calculate frames-per-second. Currently, presshells that are clipped out or otherwise not visible do not get their counters updated. We might want to change that later so that there's only a per-toplevel-window counter, but I think that's fine.
So in practice this will never show framerates above 50Hz once we have painting also hooked up to refresh driver, right?
Yes, if there is no way to force synchronous repainting.

(Well, we might want to raise the refresh-driver limit to 60Hz or something.)
You can actually get the correct limit from the OS on most platforms.
Attached patch patch (deleted) — Splinter Review
OK, here it is.
Attachment #443566 - Flags: superreview?(vladimir)
Attachment #443566 - Flags: review?(Olli.Pettay)
Comment on attachment 443566 [details] [diff] [review]
patch


>+  /**
>+   * Keep track of how many times this presshell has been rendered to
>+   * a window.
>+   */
>+  PRUint64 GetFrameCount() { return mFrameCount; }
>+  void IncrementFrameCount() { ++mFrameCount; }
I would use some other names for these.
We have so many different "frames" (nsIFrame, <iframe> etc) already.
PaintCount() and IncrementPaintCount()?

Btw, GetXXX isn't IMO needed here, since the method returns always some
valid value.


>+  // Count of the number of times this presshell has been painted to
>+  // a window
>+  PRUint64                  mFrameCount;
mPaintCount? mRenderingCount?

>+++ b/layout/base/nsLayoutUtils.cpp
>@@ -1173,16 +1173,19 @@ nsLayoutUtils::PaintFrame(nsIRenderingCo
>   nsDisplayList list;
>   nsRect dirtyRect = aDirtyRegion.GetBounds();
>   if (aFlags & PAINT_IN_TRANSFORM) {
>     builder.SetInTransform(PR_TRUE);
>   }
>   if (aFlags & PAINT_SYNC_DECODE_IMAGES) {
>     builder.SetSyncDecodeImages(PR_TRUE);
>   }
>+  if (aFlags & PAINT_WIDGET_LAYERS) {
>+    builder.SetPaintingToWindow(PR_TRUE);
>+  }
I'm not at all familiar with this code, but vlad probably is.


mozPaintCount isn't quickstubbed, so I hope no one will use it in a tight loop.
Attachment #443566 - Flags: review?(Olli.Pettay) → review+
Comment on attachment 443566 [details] [diff] [review]
patch

I like smaug's suggestion of calling the internal API GetPaintCount as well, especially since the content-side is mozPaintCount.
Attachment #443566 - Flags: superreview?(vladimir) → superreview+
yeah. I renamed the external API because 'frame' is too overloaded, so I should change the internals to match.
Whiteboard: [needs landing]
http://hg.mozilla.org/mozilla-central/rev/c91fa12e51a4
Status: NEW → RESOLVED
Closed: 15 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [needs landing]
Now documented here:

https://developer.mozilla.org/en/DOM/window.mozPaintCount

With links added from the main DOM window reference page, and from Firefox 4 for developers.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: