Gecko:Image Snapping and Rendering: Difference between revisions

Jump to navigation Jump to search
Line 42: Line 42:
* Compute device pixel fill rectangle by snapping the logical fill rectangle to device pixels, preserving device pixel centers, thus ensuring requirement 3.
* Compute device pixel fill rectangle by snapping the logical fill rectangle to device pixels, preserving device pixel centers, thus ensuring requirement 3.
* Compute device pixel draw rectangle by intersecting the device pixel fill rectangle with the dirty rectangle scaled to device pixels and rounded out. This is the area to cairo_fill.
* Compute device pixel draw rectangle by intersecting the device pixel fill rectangle with the dirty rectangle scaled to device pixels and rounded out. This is the area to cairo_fill.
* Map the anchor point back to image space (using the initial rect) and call the result P. Let P' be the anchor point transformed by the same transform that maps the logical fill rectangle to the device pixel fill rectangle. Then the transformation from image space to device space is the transformation whose scale factors are the ratio of initial rectangle size in device pixels to image size in pixels, and which transforms P to P'.
* Map the anchor point back to image space (using the initial rect), snap to the nearest pixel boundary and call the result P. Let P' be the anchor point transformed by the same transform that maps the logical fill rectangle to the device pixel fill rectangle, then snapped to the nearest device pixel. Then the transformation from image space to device space is the transformation whose scale factors are the ratio of initial rectangle size in device pixels to image size in pixels, and which transforms P to P'.


Requirement 2 is obviously satisfied since the dirty rect is only used to constrain the filled area and does not affect the mapping from image space to device space. Requirements 3, 4, 5 and 6 are satisfied by construction.
Requirement 2 is obviously satisfied since the dirty rect is only used to constrain the filled area and does not affect the mapping from image space to device space. Requirements 3, 4, 5 and 6 are satisfied by construction.


This is really the only sensible algorithm that could satisfy the above requirements.
This is really the only sensible algorithm that could satisfy the above requirements.
1,295

edits

Navigation menu