[Pixman] FAST_PATH_SAMPLES_COVER_CLIP flag & fast_composite_scaled_nearest_*
siarhei.siamashka at gmail.com
Mon Jul 19 05:17:06 PDT 2010
Currently there is a discrepancy between how FAST_PATH_SAMPLES_COVER_CLIP flag
is calculated and the actual implementation in fast_composite_scaled_nearest_*
Function 'pixman_transform_bounds' which is used for deciding whether to set
FAST_PATH_SAMPLES_COVER_CLIP flag, uses 'pixman_transform_point' call.
While 'fast_composite_scaled_nearest_*' functions do initial addition of
'pixman_fixed_1 / 2', call to 'pixman_transform_point_3d' and subtraction of
Moreover, both 'pixman_transform_point' and 'pixman_transform_point_3d'
functions are truncating low order bits in intermediate calculations, losing
precision. This does not have any effect on the initial "top left corner"
point, but still may cause differences on the other end of the bounding box
(the scaler implementations use "unit_x"/"unit_y" increments on each iteration,
while 'pixman_transform_bounds' tries to calculate the end result with
'pixman_transform_point' which is not perfectly precise).
As a result, there are two problems possible:
1. Invalid memory accesses when fast_composite_scaled_nearest_* functions try
to fetch pixels outside the source image (confirmed, a testcase will be
2. FAST_PATH_SAMPLES_COVER_CLIP not being set for the scaling cases, when there
is actually no need to access pixels outside the source image and reducing
performance (I do not have a testcase for this yet, but have reports about the
nearest scaling fast path not being used when it should).
I see two ways to fix this problem:
1. Try to ensure that FAST_PATH_SAMPLES_COVER_CLIP is set exactly when needed
by NEAREST scaling fast paths.
2. Drop FAST_PATH_SAMPLES_COVER_CLIP flag altogether and update nearest scaling
fast paths to also work correctly when sampling of the pixels outside the
source image is needed (NORMAL repeat already can do this).
I also expected the possibility of this problem earlier , but somehow forgot
to do the proper code review and tests for the FAST_PATH_SAMPLES_COVER_CLIP
More information about the Pixman