On Monday, October 31, 2011 23:43 CET, Eric Wasylishen <[email protected]> wrote: > Hi, > > Sorry, I wasn't really following this discussion. > > Regarding rint, it should be avoided because the behaviour with numbers > ending in .5 can be almost anything, and the default on a lot of platforms is > a really weird "banker's rounding" that rounds x.5 to the closest even > number. > > GSRoundTowardsInfinity implements the "normal" style of rounding: x is > rounded to the closest integer, or if there are two integers equally close, > it is rounded to the larger one.
I wasn't aware of the rint pitfalls. Updated the patch to use GSRoundTowardsInfinity, which was easy enough. It expects GCFloat, which is actually a double, like rint also used. This still makes the testsuite happy for me. > > It would be great if our -centerScanRect: exactly matched cocoa's. As Fred > says, the only way to do it is with a lot of testing. > > One thing to consider is whether the output of centerScanRect should totally > enclose the input. If it's being used for things like erasing the screen, I > think we want the output to totally enclose the input. If we simply round the > origin and round the size, the output rect might not enclose the input rect. I don't have a mac to test. The only thing I can do is to point out that tests from the testsuite are failing for me, and sometimes even can provide a patch, which is well, works for me, but is not tested on a mac. attached new patch using GSRoundTowardsInfinity. Sebastian > > > Eric > > > On 2011-10-31, at 4:03 PM, Fred Kiefer wrote: > > > On 31.10.2011 13:50, Sebastian Reitenbach wrote: > >> > >> On Sunday, October 30, 2011 22:28 CET, Fred Kiefer<[email protected]> > >> wrote: > >> > >>> On 30.10.2011 14:07, Sebastian Reitenbach wrote: > >>>> Hi, > >>>> > >>>> since -base tests are fine now for me, I'm back to -gui: The following > >>>> tests are still failing for me on OpenBSD i386 5.0 -current: > >>>> > >>>> > >>>> Testing lazy_copy.m... > >>>> Running gui/NSPasteboard/lazy_copy.m... > >>>> which happens to fail randomly. > >>>> > >>>> Testing setDelegate_reload.m... > >>>> Running gui/NSSavePanel/setDelegate_reload.m... > >>>> Failed test: browser initially contains all files > >>>> Failed test: browser is reloaded after -setDelegate: > >>>> Failed test: browser contains all files after resetting delegate > >>>> Failed test: browser is reloaded after -setDelegate: (2) > >>>> Completed file: setDelegate_reload.m > >>> > >>> The most likely reason for these tests to fail is that the .svn > >>> directory is missing. We should rewrite the test in a way that does not > >>> rely on the fact that the code includes the .svn directories. The will > >>> be gone in a while anyway when everybody switches to svn 1.7. > >>> And of course the test "browser contains all files after resetting > >>> delegate" fails on all systems. > >>> > >>>> Testing NSView_autoresize_and_rounding.m... > >>>> Running gui/NSView/NSView_autoresize_and_rounding.m... > >>>> Failed test: NSView autoresizing works > >>>> Passed test: NSView autoresizing corner cases work > >>>> Failed test: NSView autoresize rounding works > >>>> (1) expected frame (10 10)+(10 10), got (10 10)+(9 10) > >>>> (1) expected frame (10 10)+(10 10), got (9 9)+(9 9) > >>>> Completed file: NSView_autoresize_and_rounding.m > >>> > >>> These tests should work. Here you could try to add some NSLog statements > >>> to the code in NSView to find out what is actually going on. I remember > >>> that when you looked at that code in gdb you got unlikely results. > >> > >> A couple of hours later, I tracked down the first thing to happen in > >> [NSView centerScanRect:] > >> > >> - (NSRect) centerScanRect: (NSRect)aRect > >> { > >> NSAffineTransform *matrix; > >> > >> /* > >> * Hmm - we assume that the windows coordinate system is centered on > >> the > >> * pixels of the screen - this may not be correct of course. > >> * Plus - this is all pretty meaningless if we are not in a window! > >> */ > >> matrix = [self _matrixToWindow]; > >> NSLog(@"centerScanRect: matrix: %@", matrix); > >> aRect.origin = [matrix transformPoint: aRect.origin]; > >> aRect.size = [matrix transformSize: aRect.size]; > >> if (aRect.size.height< 0.0) > >> { > >> aRect.size.height = -aRect.size.height; > >> } > >> NSLog(@"centerScanRect: aRect before floor: %@", > >> NSStringFromRect(aRect)); > >> aRect.origin.x = floor(aRect.origin.x); > >> aRect.origin.y = floor(aRect.origin.y); > >> aRect.size.width = floor(aRect.size.width); > >> aRect.size.height = floor(aRect.size.height); > >> NSLog(@"centerScanRect: aRect after floor: %@", NSStringFromRect(aRect)); > >> > >> matrix = [self _matrixFromWindow]; > >> aRect.origin = [matrix transformPoint: aRect.origin]; > >> aRect.size = [matrix transformSize: aRect.size]; > >> if (aRect.size.height< 0.0) > >> { > >> aRect.size.height = -aRect.size.height; > >> } > >> > >> return aRect; > >> } > >> > >> here the output from the tests.log file for that test, most interesting > >> are the NSLog lines around the floor: > >> > >> 2011-10-30 22:55:24.847 NSView_autoresize_and_rounding[14247] WWW > >> container: h=--- v=---<NSView: 0x829ed504> f={x = 0; y = 0; width = 200; > >> height = 100} b={x = 0; y = 0; width = 200; height = 100} view1: h=-&- > >> v=---<NSView: 0x829ed904> f={x = 10; y = 10; width = > >> 110; height = 10} b={x = 0; y = 0; width = 110; height = 10} > >> 2011-10-30 22:55:24.847 NSView_autoresize_and_rounding[14247] > >> _is_rotated_or_scaled_from_base was NULL > >> 2011-10-30 22:55:24.847 NSView_autoresize_and_rounding[14247] > >> _setFrameAndClearAutoresizingError: Got this NSRect: {x = 0; y = 0; width > >> = 100; height = 100} > >> 2011-10-30 22:55:24.848 NSView_autoresize_and_rounding[14247] coordinates > >> are valid > >> 2011-10-30 22:55:24.848 NSView_autoresize_and_rounding[14247] > >> resetCursorRects doing nothing > >> 2011-10-30 22:55:24.848 NSView_autoresize_and_rounding[14247] going to > >> resizeSubviewsWithOldSize: width: 200.000000, height: 100.000000 > >> 2011-10-30 22:55:24.848 NSView_autoresize_and_rounding[14247] > >> resizeSubviewsWithOldSize: we have subviews: _rFlags.has_subviews > >> 2011-10-30 22:55:24.848 NSView_autoresize_and_rounding[14247] > >> resizeSubviewsWithOldSize: we did not return: _autoresizes_subviews was no > >> NO OR _is_rotated_from_base was not YES > >> 2011-10-30 22:55:24.848 NSView_autoresize_and_rounding[14247] subview o > >> before resizeWithOldSuperviewSize: h=-&- v=---<NSView: 0x829ed904> f={x > >> = 10; y = 10; width = 110; height = 10} b={x = 0; y = 0; width = 110; > >> height = 10} > >> 2011-10-30 22:55:24.848 NSView_autoresize_and_rounding[14247] > >> resizeWithOldSuperviewSize: _autoresizingMask != NSViewNotSizable > >> 2011-10-30 22:55:24.849 NSView_autoresize_and_rounding[14247] > >> resizeWithOldSuperviewSize: before rounding, newFrameRounded: {x = 10; y = > >> 10; width = 10; height = 10} > >> 2011-10-30 22:55:24.849 NSView_autoresize_and_rounding[14247] > >> centerScanRect: matrix: NSAffineTransform ((1.000000, 0.000000) (0.000000, > >> 1.000000) (0.000000, 0.000000)) > >> 2011-10-30 22:55:24.849 NSView_autoresize_and_rounding[14247] > >> centerScanRect: aRect before floor: {x = 10; y = 10; width = 10; height = > >> 10} > >> 2011-10-30 22:55:24.849 NSView_autoresize_and_rounding[14247] > >> centerScanRect: aRect after floor: {x = 10; y = 10; width = 9; height = 10} > >> 2011-10-30 22:55:24.849 NSView_autoresize_and_rounding[14247] > >> resizeWithOldSuperviewSize: performed rounding, newFrameRounded: {x = 10; > >> y = 10; width = 9; height = 10} > >> 2011-10-30 22:55:24.849 NSView_autoresize_and_rounding[14247] > >> _setFrameAndClearAutoresizingError: Got this NSRect: {x = 10; y = 10; > >> width = 9; height = 10} > >> 2011-10-30 22:55:24.850 NSView_autoresize_and_rounding[14247] > >> resetCursorRects doing nothing > >> 2011-10-30 22:55:24.850 NSView_autoresize_and_rounding[14247] subview o > >> after resizeWithOldSuperviewSize: h=-&- v=---<NSView: 0x829ed904> f={x = > >> 10; y = 10; width = 9; height = 10} b={x = 0; y = 0; width = 9; height = > >> 10} > >> 2011-10-30 22:55:24.850 NSView_autoresize_and_rounding[14247] XXX > >> container: h=--- v=---<NSView: 0x829ed504> f={x = 0; y = 0; width = 100; > >> height = 100} b={x = 0; y = 0; width = 100; height = 100} view1: h=-&- > >> v=---<NSView: 0x829ed904> f={x = 10; y = 10; width = > >> 9; height = 10} b={x = 0; y = 0; width = 9; height = 10} > >> > >> unfortunately, I don't see how the third floor rounds it down to 9???? > >> > >> and also the second failure seems to happen at the same place: > >> > >> 2011-10-30 22:55:24.912 NSView_autoresize_and_rounding[14247] > >> resizeSubviewsWithOldSize: we did not return: _autoresizes_subviews was no > >> NO OR _is_rotated_from_base was not YES > >> 2011-10-30 22:55:24.912 NSView_autoresize_and_rounding[14247] subview o > >> before resizeWithOldSuperviewSize: h=&&& v=&&& <NSView: 0x829ed904> > >> f={x = 3; y = 3; width = 3; height = 3} b={x = 0; y = 0; width = 3; height > >> = 3} > >> 2011-10-30 22:55:24.912 NSView_autoresize_and_rounding[14247] > >> resizeWithOldSuperviewSize: _autoresizingMask != NSViewNotSizable > >> 2011-10-30 22:55:24.913 NSView_autoresize_and_rounding[14247] > >> resizeWithOldSuperviewSize: !NSEqualRects(NSZeroRect, > >> _autoresizingFrameError): newFrame before _autoresizingFrameError: {x = 3; > >> y = 3; width = 3; height = 3} > >> 2011-10-30 22:55:24.913 NSView_autoresize_and_rounding[14247] > >> resizeWithOldSuperviewSize: !NSEqualRects(NSZeroRect, > >> _autoresizingFrameError): newFrame after _autoresizingFrameError: {x = > >> 3.3; y = 3.3; width = 3.3; height = 3.3} > >> 2011-10-30 22:55:24.913 NSView_autoresize_and_rounding[14247] > >> resizeWithOldSuperviewSize: before rounding, newFrameRounded: {x = 10; y = > >> 10; width = 10; height = 10} > >> 2011-10-30 22:55:24.913 NSView_autoresize_and_rounding[14247] > >> centerScanRect: matrix: NSAffineTransform ((1.000000, 0.000000) (0.000000, > >> 1.000000) (0.000000, 0.000000)) > >> 2011-10-30 22:55:24.913 NSView_autoresize_and_rounding[14247] > >> centerScanRect: aRect before floor: {x = 10; y = 10; width = 10; height = > >> 10} > >> 2011-10-30 22:55:24.913 NSView_autoresize_and_rounding[14247] > >> centerScanRect: aRect after floor: {x = 9; y = 9; width = 9; height = 9} > >> 2011-10-30 22:55:24.914 NSView_autoresize_and_rounding[14247] > >> resizeWithOldSuperviewSize: performed rounding, newFrameRounded: {x = 9; y > >> = 9; width = 9; height = 9} > >> 2011-10-30 22:55:24.914 NSView_autoresize_and_rounding[14247] > >> _setFrameAndClearAutoresizingError: Got this NSRect: {x = 9; y = 9; width > >> = 9; height = 9} > >> 2011-10-30 22:55:24.914 NSView_autoresize_and_rounding[14247] > >> resetCursorRects doing nothing > >> 2011-10-30 22:55:24.914 NSView_autoresize_and_rounding[14247] subview o > >> after resizeWithOldSuperviewSize: h=&&& v=&&& <NSView: 0x829ed904> > >> f={x = 9; y = 9; width = 9; height = 9} b={x = 0; y = 0; width = 9; height > >> = 9} > >> 2011-10-30 22:55:24.914 NSView_autoresize_and_rounding[14247] container: > >> h=--- v=---<NSView: 0x829ed504> f={x = 0; y = 0; width = 100; height = > >> 100} b={x = 0; y = 0; width = 100; height = 100} > >> 2011-10-30 22:55:24.915 NSView_autoresize_and_rounding[14247] counter: 19: > >> got view: h=&&& v=&&& <NSView: 0x829ed904> f={x = 9; y = 9; width = 9; > >> height = 9} b={x = 0; y = 0; width = 9; height = 9}, got frame: > >> 2011-10-30 22:55:24.915 NSView_autoresize_and_rounding[14247] > >> _setFrameAndClearAutoresizingError: Got this NSRect: {x = 1.5; y = 1.5; > >> width = 1.5; height = 1.5} > >> 2011-10-30 22:55:24.915 NSView_autoresize_and_rounding[14247] > >> resetCursorRects doing nothing > >> 2011-10-30 22:55:24.915 NSView_autoresize_and_rounding[14247] counter: 20: > >> got view: h=&&& v=&&& <NSView: 0x829ed904> f={x = 1.5; y = 1.5; width > >> = 1.5; height = 1.5} b={x = 0; y = 0; width = 1.5; height = 1.5}, got > >> frame: > >> > >> But here, I don't see why floor rounds down to 9. Then I exchanged the %g > >> with %f in NSStringFromRect, and I got: > >> > >> > >> 2011-10-30 23:24:52.009 NSView_autoresize_and_rounding[16728] going to > >> resizeSubviewsWithOldSize: width: 200.000000, height: 100.000000 > >> 2011-10-30 23:24:52.009 NSView_autoresize_and_rounding[16728] > >> resizeSubviewsWithOldSize: we have subviews: _rFlags.has_subviews > >> 2011-10-30 23:24:52.009 NSView_autoresize_and_rounding[16728] > >> resizeSubviewsWithOldSize: we did not return: _autoresizes_subviews was no > >> NO OR _is_rotated_from_base was not YES > >> 2011-10-30 23:24:52.010 NSView_autoresize_and_rounding[16728] subview o > >> before resizeWithOldSuperviewSize: h=-&- v=---<NSView: 0x7c4abe04> f={x > >> = 10.000000; y = 10.000000; width = 110.000000; height = 10.000000} b={x = > >> 0.000000; y = 0.000000; width = 110.000000; h > >> eight = 10.000000} > >> 2011-10-30 23:24:52.010 NSView_autoresize_and_rounding[16728] > >> resizeWithOldSuperviewSize: _autoresizingMask != NSViewNotSizable > >> 2011-10-30 23:24:52.010 NSView_autoresize_and_rounding[16728] > >> resizeWithOldSuperviewSize: before rounding, newFrameRounded: {x = > >> 10.000000; y = 10.000000; width = 9.999997; height = 10.000000} > >> 2011-10-30 23:24:52.010 NSView_autoresize_and_rounding[16728] > >> centerScanRect: matrix: NSAffineTransform ((1.000000, 0.000000) (0.000000, > >> 1.000000) (0.000000, 0.000000)) > >> 2011-10-30 23:24:52.010 NSView_autoresize_and_rounding[16728] > >> centerScanRect: aRect before floor: {x = 10.000000; y = 10.000000; width = > >> 9.999997; height = 10.000000} > >> 2011-10-30 23:24:52.010 NSView_autoresize_and_rounding[16728] > >> centerScanRect: aRect after floor: {x = 10.000000; y = 10.000000; width = > >> 9.000000; height = 10.000000} > >> 2011-10-30 23:24:52.011 NSView_autoresize_and_rounding[16728] > >> resizeWithOldSuperviewSize: performed rounding, newFrameRounded: {x = > >> 10.000000; y = 10.000000; width = 9.000000; height = 10.000000} > >> 2011-10-30 23:24:52.011 NSView_autoresize_and_rounding[16728] > >> _setFrameAndClearAutoresizingError: Got this NSRect: {x = 10.000000; y = > >> 10.000000; width = 9.000000; height = 10.000000} > >> 2011-10-30 23:24:52.011 NSView_autoresize_and_rounding[16728] > >> resetCursorRects doing nothing > >> 2011-10-30 23:24:52.011 NSView_autoresize_and_rounding[16728] subview o > >> after resizeWithOldSuperviewSize: h=-&- v=---<NSView: 0x7c4abe04> f={x = > >> 10.000000; y = 10.000000; width = 9.000000; height = 10.000000} b={x = > >> 0.000000; y = 0.000000; width = 9.000000; height > >> = 10.000000} > >> 2011-10-30 23:24:52.011 NSView_autoresize_and_rounding[16728] XXX > >> container: h=--- v=---<NSView: 0x7c4ab104> f={x = 0.000000; y = > >> 0.000000; width = 100.000000; height = 100.000000} b={x = 0.000000; y = > >> 0.000000; width = 100.000000; height = 100.000000} view1: h=- > >> &- v=---<NSView: 0x7c4abe04> f={x = 10.000000; y = 10.000000; width = > >> 9.000000; height = 10.000000} b={x = 0.000000; y = 0.000000; width = > >> 9.000000; height = 10.000000} > >> 2011-10-30 23:24:52.012 NSView_autoresize_and_rounding[16728] counter: 7: > >> got view: h=-&- v=---<NSView: 0x7c4abe04> f={x = 10.000000; y = > >> 10.000000; width = 9.000000; height = 10.000000} b={x = 0.000000; y = > >> 0.000000; width = 9.000000; height = 10.000000}, got fra > >> me: > >> > >> way more interesting numbers, and they now explain, why things happen. > >> > >> with attached patch, all three tests in NSView_aotresize_and_rounding.m > >> pass for me. > >> > >> But I've no idea, if this is the right fix ;) > > > > You definitely would get more support for that patch from Eric if you used > > GSRoundTowardsInfinity instead of rint. He removed that function from > > GNUstep gui a few months ago and re-introducing it via a patch isn't a good > > idea. > > > > Whether the achieved behaviour is correct, can only be tested by comparing > > a lot of cases to the results on a Mac. > > > > _______________________________________________ > > Discuss-gnustep mailing list > > [email protected] > > https://lists.gnu.org/mailman/listinfo/discuss-gnustep > > > _______________________________________________ > Discuss-gnustep mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/discuss-gnustep
patch-Source_NSView_m
Description: Binary data
_______________________________________________ Discuss-gnustep mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnustep
