Closed Bug 464811 Opened 16 years ago Closed 16 years ago

Fix anchor point snapping to guarantee that the source rect intersects the subimage region

Categories

(Core :: Layout, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9.1b2

People

(Reporter: roc, Assigned: roc)

References

Details

(Keywords: fixed1.9.1, regression)

Attachments

(2 files, 5 obsolete files)

The current approach to anchor point snapping, which I did in bug 463204, isn't quite right. Sometimes the transform from the logical fill rect to the device pixel fill rect can be weird; for example [0.4, 0.6] snaps to [0,1], which is a scale-up by 5, but we don't want to scale an anchor offset of 10 by a factor of 5.

Also, I've been investigating how to guarantee that nsLayoutUtils::DrawImage will generate parameters to nsThebesImage::Draw so that the fill rectangle, transformed to image space, intersects the subimage rectangle.

It turns out a new approach to anchor point snapping solves both of these problems. The approach is:
1) start with the anchor point in user space
2) map it back to image space via the "ideal" transformation defined by the initial rectangle, and snap it to some image pixel corner. Any one will do, the nearest one makes most sense.
3) map that corner forward through the "ideal" transformation back to device space, and snap to the nearest device pixel corner.
4) the device-space-to-image-space transformation's translation is chosen to map the device pixel corner from step 3 to the image pixel corner from step 2.

I've updated
https://wiki.mozilla.org/Gecko:Image_Snapping_and_Rendering
with the adjusted requirements and algorithm. I've also added a proof there that the resulting algorithm ensures the source and subimage rectangles intersect. The proof is not trivial and it's fairly "tight" --- alternative choices in the algorithm would likely break the proof and fail to satisfy the requirement.
Attached file testcase
This testcase shows the actual bug. We try to display a sliver of the image and display completely the wrong slice. The column of pixels in the second DIV should match the column of pixels above it in the first DIV.
Attached patch fix (obsolete) — Splinter Review
This fixes it, as described here and in the wiki page.
Attachment #348127 - Flags: superreview?(dbaron)
Attachment #348127 - Flags: review?(dbaron)
Attached patch fix v1.1 (obsolete) — Splinter Review
With the tests included.
Attachment #348127 - Attachment is obsolete: true
Attachment #348128 - Flags: superreview?(dbaron)
Attachment #348128 - Flags: review?(dbaron)
Attachment #348127 - Flags: superreview?(dbaron)
Attachment #348127 - Flags: review?(dbaron)
Attached patch fix v1.2 (obsolete) — Splinter Review
433640-1-ref.html needs to be reverted back to its pre-bug-463204 state.
Attachment #348132 - Flags: superreview?(dbaron)
Attachment #348132 - Flags: review?(dbaron)
Attachment #348128 - Attachment is obsolete: true
Attachment #348128 - Flags: superreview?(dbaron)
Attachment #348128 - Flags: review?(dbaron)
dbaron thought this should block beta in light of bug 464606.
Flags: blocking1.9.1?
Comment on attachment 348132 [details] [diff] [review]
fix v1.2

I don't quite follow the whole thing, but what I understand makes sense.  r+sr=dbaron

But could you add some comments before MapToFloatImagePixels / MapToFloatUserPixels saying what they do?
Attachment #348132 - Flags: superreview?(dbaron)
Attachment #348132 - Flags: superreview+
Attachment #348132 - Flags: review?(dbaron)
Attachment #348132 - Flags: review+
Attached patch fix v1.3 (obsolete) — Splinter Review
Updated for comments
Attachment #348132 - Attachment is obsolete: true
Attachment #348482 - Flags: superreview+
Attachment #348482 - Flags: review+
Comment on attachment 348482 [details] [diff] [review]
fix v1.3

Another image rendering regression fix
Attachment #348482 - Flags: approval1.9.1b2?
Whiteboard: [needs approval/landing]
Flags: in-testsuite?
Keywords: regression
Target Milestone: --- → mozilla1.9.1b2
Hmmm, we agreed this was blocking in our triage spreadsheet yesterday; I'm not sure why roc didn't mark this one.

Beltzner says we (as the layout triage team) have the authority to mark things as beta2 blockers if we think they're really blockers (although the non-blocker approval queue is still triaged by the release drivers).  So I'm marking this as such; although I'm not sure whether roc's comment 6 counts as agreement with my assertion that it should block.  If not, he can change the target milestone back.
Flags: blocking1.9.1? → blocking1.9.1+
That's cool. I'll land
Pushed 0ced86fbf8ed
Status: NEW → RESOLVED
Closed: 16 years ago
Flags: in-testsuite? → in-testsuite+
Resolution: --- → FIXED
Whiteboard: [needs approval/landing]
Backed out. Reftests failed, which is weird. Maybe some interaction between this patch and other changes that landed in the past few days.
Status: RESOLVED → REOPENED
Flags: in-testsuite+
Resolution: FIXED → ---
Comment on attachment 348482 [details] [diff] [review]
fix v1.3

>diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list
[snip]
>+== 464811-1.html 464811-1-ref.thml

That needs a s/thml/html  (though that doesn't fix the other reftest failures)
Attached patch fix v1.4 (obsolete) — Splinter Review
Because I am stupid, I lost a "anchorPoint.Round()" while rebasing the patch to trunk. This patch passes reftests.
Attachment #348686 - Flags: superreview+
Attachment #348686 - Flags: review+
Priority: -- → P1
Whiteboard: [needs landing]
Comment on attachment 348686 [details] [diff] [review]
fix v1.4

And because I am doubly stupid, I attached the wrong patch.
Attachment #348686 - Attachment is obsolete: true
Attached patch fix v1.4Splinter Review
Attachment #348482 - Attachment is obsolete: true
Attachment #348722 - Flags: superreview+
Attachment #348722 - Flags: review+
Re-pushed d328fec034c5
Status: REOPENED → RESOLVED
Closed: 16 years ago16 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [needs landing]
Both of my duplicate bugs, bug 464606 and bug 464603, are verified FIXED in the nightlies.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: