Closed Bug 898228 Opened 11 years ago Closed 11 years ago

Wasted work in gfxContext::ClipContainsRect()

Categories

(Core :: Graphics, defect)

x86_64
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: pchang9, Assigned: pchang9)

Details

(Keywords: perf, Whiteboard: patch)

Attachments

(1 file, 3 obsolete files)

Attached patch Suggested patch (obsolete) — Splinter Review
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0 (Beta/Release)
Build ID: 20130116073211

Steps to reproduce:

The problem appears in changeset 138350:18467a85acf6. I have attached a simple one-line patch that fixes it.

In method gfxContext::ClipContainsRect() in gfx/thebes/gfxContext.cpp, the loop in line 1232 keeps overriding "lastReset" with "i" when "mStateStack[i].clipWasReset" is true. Therefore, only the last written value is visible out of the loop and all the other writes and iterations are not necessary. The patch iterates from the start of "lastReset" and breaks the first time when "i" is set.

Similar problems also appear in loops at line 2073 and 2184, function gfxContext::PushClipsToDT() and gfxContext::ChangeTransform().
Keywords: perf
OS: Windows 7 → All
Version: 18 Branch → Trunk
Component: Untriaged → Graphics
Product: Firefox → Core
Whiteboard: patch
Attachment #781387 - Attachment is patch: true
Attached patch 898228.patch (obsolete) — Splinter Review
Attachment #784375 - Flags: review?(jmuizelaar)
Attachment #784375 - Flags: review?(jmuizelaar) → review?(bas)
Comment on attachment 784375 [details] [diff] [review]
898228.patch

Review of attachment 784375 [details] [diff] [review]:
-----------------------------------------------------------------

Ouch! I think the current behavior is actually wrong! We're currently catching the first reset instead of the last one. This is a very nice catch, but the right solution is inserting a break in the existing loops without changing the loops itself. I'm actually surprised this hasn't caused any bugs, I suppose we don't often have multiple resets in a clip stack. When we fix this we should keep a careful eye open on whether nothing breaks.
Attachment #784375 - Flags: review?(bas) → review-
Attached patch 898228-1.patch (obsolete) — Splinter Review
Attachment #781387 - Attachment is obsolete: true
Attachment #784375 - Attachment is obsolete: true
Attachment #784394 - Flags: review?(bas)
Comment on attachment 784394 [details] [diff] [review]
898228-1.patch

Review of attachment 784394 [details] [diff] [review]:
-----------------------------------------------------------------

This looks like a great change!
Attachment #784394 - Flags: review?(bas) → review+
(In reply to Bas Schouten (:bas.schouten) from comment #5)
> Comment on attachment 784394 [details] [diff] [review]
> 898228-1.patch
> 
> Review of attachment 784394 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> This looks like a great change!

Thanks! Could you be my voucher so that I can test on try servers ?
Landed on try server:
https://tbpl.mozilla.org/?tree=Try&rev=75b0a15266b3
Keywords: checkin-needed
Attachment #784394 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/d215826d8637
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: