[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pixel-aligned autoresizing

From: Eric Wasylishen
Subject: Pixel-aligned autoresizing
Date: Tue, 5 Jul 2011 14:15:04 -0600


In the last month I was looking in to making GS's drawing output match cocoa 
exactly, in particular, getting rid of rounding in the backends. 

One of the problems I encountered is GS can give autoresizing views fractional 
positions/sizes, whereas when Cocoa autoresizes views it only ever sizes them 
to pixel-aligned rects. The problem with GS's current behaviour is it will make 
UI elements blurry if we get rid of rounding in the backend. 

Attached is a preliminary patch* which switches to Cocoa's behaviour. I wanted 
to ask for feedback as to whether this is a reasonable patch to apply.

The patch has to do a bit more than simply adding rounding to - (void) 
resizeWithOldSuperviewSize: (NSSize)oldSize, because if we just round _frame, 
we will lose track of where a view originally was. I add a new ivar 
_autoresizingFrameError which stores the difference between the rounded _frame, 
and what _frame would be without rounding. The only slightly messy bit of the 
patch is that any parts of the code that modify _frame directly should also set 
_autoresizingFrameError to {0, 0}.


Attachment: AutoresizeRoudning1.diff
Description: Binary data

[*] One thing I would change in the patch is instead of rounding using floor(), 
I would call -centerScanRect: so that the pixel-alignment takes in to account 
the transformation matrix of the current view.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]