Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(948)

Side by Side Diff: src/base/ftcalc.c

Issue 23555005: Update freetype to the latest version of Android external/freetype (Closed) Base URL: https://chromium.googlesource.com/chromium/src/third_party/freetype.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/base/ftbitmap.c ('k') | src/base/ftglyph.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /***************************************************************************/ 1 /***************************************************************************/
2 /* */ 2 /* */
3 /* ftcalc.c */ 3 /* ftcalc.c */
4 /* */ 4 /* */
5 /* Arithmetic computations (body). */ 5 /* Arithmetic computations (body). */
6 /* */ 6 /* */
7 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */ 7 /* Copyright 1996-2006, 2008, 2012 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */ 9 /* */
10 /* This file is part of the FreeType project, and may only be used, */ 10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */ 11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */ 13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */ 14 /* understand and accept it fully. */
15 /* */ 15 /* */
16 /***************************************************************************/ 16 /***************************************************************************/
17 17
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 if ( r >= y ) 300 if ( r >= y )
301 return (FT_UInt32)0x7FFFFFFFL; 301 return (FT_UInt32)0x7FFFFFFFL;
302 302
303 i = 32; 303 i = 32;
304 do 304 do
305 { 305 {
306 r <<= 1; 306 r <<= 1;
307 q <<= 1; 307 q <<= 1;
308 r |= lo >> 31; 308 r |= lo >> 31;
309 309
310 if ( r >= (FT_UInt32)y ) 310 if ( r >= y )
311 { 311 {
312 r -= y; 312 r -= y;
313 q |= 1; 313 q |= 1;
314 } 314 }
315 lo <<= 1; 315 lo <<= 1;
316 } while ( --i ); 316 } while ( --i );
317 317
318 return q; 318 return q;
319 } 319 }
320 320
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 if ( a == 0 || b == c ) 366 if ( a == 0 || b == c )
367 return a; 367 return a;
368 368
369 s = a; a = FT_ABS( a ); 369 s = a; a = FT_ABS( a );
370 s ^= b; b = FT_ABS( b ); 370 s ^= b; b = FT_ABS( b );
371 s ^= c; c = FT_ABS( c ); 371 s ^= c; c = FT_ABS( c );
372 372
373 if ( a <= 46340L && b <= 46340L && c <= 176095L && c > 0 ) 373 if ( a <= 46340L && b <= 46340L && c <= 176095L && c > 0 )
374 a = ( a * b + ( c >> 1 ) ) / c; 374 a = ( a * b + ( c >> 1 ) ) / c;
375 375
376 else if ( c > 0 ) 376 else if ( (FT_Int32)c > 0 )
377 { 377 {
378 FT_Int64 temp, temp2; 378 FT_Int64 temp, temp2;
379 379
380 380
381 ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp ); 381 ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
382 382
383 temp2.hi = 0; 383 temp2.hi = 0;
384 temp2.lo = (FT_UInt32)(c >> 1); 384 temp2.lo = (FT_UInt32)(c >> 1);
385 FT_Add64( &temp, &temp2, &temp ); 385 FT_Add64( &temp, &temp2, &temp );
386 a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c ); 386 a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
(...skipping 18 matching lines...) Expand all
405 if ( a == 0 || b == c ) 405 if ( a == 0 || b == c )
406 return a; 406 return a;
407 407
408 s = a; a = FT_ABS( a ); 408 s = a; a = FT_ABS( a );
409 s ^= b; b = FT_ABS( b ); 409 s ^= b; b = FT_ABS( b );
410 s ^= c; c = FT_ABS( c ); 410 s ^= c; c = FT_ABS( c );
411 411
412 if ( a <= 46340L && b <= 46340L && c > 0 ) 412 if ( a <= 46340L && b <= 46340L && c > 0 )
413 a = a * b / c; 413 a = a * b / c;
414 414
415 else if ( c > 0 ) 415 else if ( (FT_Int32)c > 0 )
416 { 416 {
417 FT_Int64 temp; 417 FT_Int64 temp;
418 418
419 419
420 ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp ); 420 ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
421 a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c ); 421 a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
422 } 422 }
423 else 423 else
424 a = 0x7FFFFFFFL; 424 a = 0x7FFFFFFFL;
425 425
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 457
458 /* 458 /*
459 * This is a clever way of converting a signed number `a' into its 459 * This is a clever way of converting a signed number `a' into its
460 * absolute value (stored back into `a') and its sign. The sign is 460 * absolute value (stored back into `a') and its sign. The sign is
461 * stored in `sa'; 0 means `a' was positive or zero, and -1 means `a' 461 * stored in `sa'; 0 means `a' was positive or zero, and -1 means `a'
462 * was negative. (Similarly for `b' and `sb'). 462 * was negative. (Similarly for `b' and `sb').
463 * 463 *
464 * Unfortunately, it doesn't work (at least not portably). 464 * Unfortunately, it doesn't work (at least not portably).
465 * 465 *
466 * It makes the assumption that right-shift on a negative signed value 466 * It makes the assumption that right-shift on a negative signed value
467 * fills the leftmost bits by copying the sign bit. This is wrong. 467 * fills the leftmost bits by copying the sign bit. This is wrong.
468 * According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206, 468 * According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206,
469 * the result of right-shift of a negative signed value is 469 * the result of right-shift of a negative signed value is
470 * implementation-defined. At least one implementation fills the 470 * implementation-defined. At least one implementation fills the
471 * leftmost bits with 0s (i.e., it is exactly the same as an unsigned 471 * leftmost bits with 0s (i.e., it is exactly the same as an unsigned
472 * right shift). This means that when `a' is negative, `sa' ends up 472 * right shift). This means that when `a' is negative, `sa' ends up
473 * with the value 1 rather than -1. After that, everything else goes 473 * with the value 1 rather than -1. After that, everything else goes
474 * wrong. 474 * wrong.
475 */ 475 */
476 sa = ( a >> ( sizeof ( a ) * 8 - 1 ) ); 476 sa = ( a >> ( sizeof ( a ) * 8 - 1 ) );
477 a = ( a ^ sa ) - sa; 477 a = ( a ^ sa ) - sa;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 FT_Long b ) 537 FT_Long b )
538 { 538 {
539 FT_Int32 s; 539 FT_Int32 s;
540 FT_UInt32 q; 540 FT_UInt32 q;
541 541
542 542
543 /* XXX: this function does not allow 64-bit arguments */ 543 /* XXX: this function does not allow 64-bit arguments */
544 s = (FT_Int32)a; a = FT_ABS( a ); 544 s = (FT_Int32)a; a = FT_ABS( a );
545 s ^= (FT_Int32)b; b = FT_ABS( b ); 545 s ^= (FT_Int32)b; b = FT_ABS( b );
546 546
547 if ( b == 0 ) 547 if ( (FT_UInt32)b == 0 )
548 { 548 {
549 /* check for division by 0 */ 549 /* check for division by 0 */
550 q = (FT_UInt32)0x7FFFFFFFL; 550 q = (FT_UInt32)0x7FFFFFFFL;
551 } 551 }
552 else if ( ( a >> 16 ) == 0 ) 552 else if ( ( a >> 16 ) == 0 )
553 { 553 {
554 /* compute result directly */ 554 /* compute result directly */
555 q = (FT_UInt32)( (a << 16) + (b >> 1) ) / (FT_UInt32)b; 555 q = (FT_UInt32)( ( a << 16 ) + ( b >> 1 ) ) / (FT_UInt32)b;
556 } 556 }
557 else 557 else
558 { 558 {
559 /* we need more bits; we have to do it by hand */ 559 /* we need more bits; we have to do it by hand */
560 FT_Int64 temp, temp2; 560 FT_Int64 temp, temp2;
561 561
562 temp.hi = (FT_Int32) (a >> 16); 562
563 temp.lo = (FT_UInt32)(a << 16); 563 temp.hi = (FT_Int32) ( a >> 16 );
564 temp.lo = (FT_UInt32)( a << 16 );
564 temp2.hi = 0; 565 temp2.hi = 0;
565 temp2.lo = (FT_UInt32)( b >> 1 ); 566 temp2.lo = (FT_UInt32)( b >> 1 );
566 FT_Add64( &temp, &temp2, &temp ); 567 FT_Add64( &temp, &temp2, &temp );
567 q = ft_div64by32( temp.hi, temp.lo, (FT_Int32)b ); 568 q = ft_div64by32( temp.hi, temp.lo, (FT_Int32)b );
568 } 569 }
569 570
570 return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q ); 571 return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
571 } 572 }
572 573
573 574
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 ay = out_y + in_y; 949 ay = out_y + in_y;
949 if ( ay < 0 ) 950 if ( ay < 0 )
950 ay = -ay; 951 ay = -ay;
951 d_corner = ax + ay; 952 d_corner = ax + ay;
952 953
953 return ( d_in + d_out - d_corner ) < ( d_corner >> 4 ); 954 return ( d_in + d_out - d_corner ) < ( d_corner >> 4 );
954 } 955 }
955 956
956 957
957 /* END */ 958 /* END */
OLDNEW
« no previous file with comments | « src/base/ftbitmap.c ('k') | src/base/ftglyph.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698