Re: [PATCH] Use NEAREST filter when possible

Bill Spitzak <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
I think using CAIRO_SCALING_EPSILON if it is 0.00015 will work. The 
example I have fails after adding M_PI_2 together 12 times and sending 
the result to cairo_rotate. Adjusting these seems to make no difference 
so I now think it is causing the translate factors to fail.

Will post another patch using the constant.

On 08/11/2014 11:31 PM, Chris Wilson wrote:
> On Mon, Aug 11, 2014 at 08:27:22PM -0700, Bill Spitzak wrote:
>> diff --git a/src/cairo-matrix.c b/src/cairo-matrix.c
>> index ba975be..ba73b53 100644
>> --- a/src/cairo-matrix.c
>> +++ b/src/cairo-matrix.c
>> @@ -748,23 +748,26 @@ _cairo_matrix_is_integer_translation (const cairo_matrix_t *matrix,
>>       return FALSE;
>>   }
>>
>> +/* This only returns true if the matrix is 90 degree rotations or
>> + * flips. It appears calling code is relying on this. It will return
>> + * false for other rotations even if the scale is one. Approximations
>> + * are allowed to handle matricies filled in using trig functions
>> + * such as sin(M_PI_2).
>> + */
>>   cairo_bool_t
>>   _cairo_matrix_has_unity_scale (const cairo_matrix_t *matrix)
>>   {
>> -    if (matrix->xy == 0.0 && matrix->yx == 0.0) {
>> -	if (! (matrix->xx == 1.0 || matrix->xx == -1.0))
>> -	    return FALSE;
>> -	if (! (matrix->yy == 1.0 || matrix->yy == -1.0))
>> -	    return FALSE;
>> -    } else if (matrix->xx == 0.0 && matrix->yy == 0.0) {
>> -	if (! (matrix->xy == 1.0 || matrix->xy == -1.0))
>> -	    return FALSE;
>> -	if (! (matrix->yx == 1.0 || matrix->yx == -1.0))
>> -	    return FALSE;
>> -    } else
>> -	return FALSE;
>> +    /* check that the determinant is near +/-1 */
>> +    double v = matrix->xx * matrix->yy - matrix->xy * matrix->yx;
>> +    v = v * v;
>> +    if (v < 0.99999 || v > 1.00001) return FALSE;
>>
>> -    return TRUE;
>> +    /* check that one axis is close to zero */
>> +    if (fabs (matrix->xy) < 0.0001  &&  fabs (matrix->yx) < 0.0001)
>> +	return TRUE;
>> +    if (fabs (matrix->xx) < 0.0001  &&  fabs (matrix->yy) < 0.0001)
>> +	return TRUE;
>> +    return FALSE;
>>   }
>
> Nice fixes below, This worries me slightly for the hardcoded constants.
> I would use CAIRO_FIXED_TO_DOUBLE(1) instead, which is 1.5e-5 about 1/6
> of your epsilon. Either way,
> #define CAIRO_SCALING_EPSILON (CAIRO_FIXED_TO_DOUBLE(1))
> -Chris
>
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.