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

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

Issue 89753003: Update freetype to latest version of ASOP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src/third_party/freetype.git@master
Patch Set: Created 7 years 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/ftstream.c ('k') | src/base/ftsynth.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 /* ftstroke.c */ 3 /* ftstroke.c */
4 /* */ 4 /* */
5 /* FreeType path stroker (body). */ 5 /* FreeType path stroker (body). */
6 /* */ 6 /* */
7 /* Copyright 2002-2006, 2008-2011 by */ 7 /* Copyright 2002-2006, 2008-2011, 2013 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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 782
783 } FT_StrokerRec; 783 } FT_StrokerRec;
784 784
785 785
786 /* documentation is in ftstroke.h */ 786 /* documentation is in ftstroke.h */
787 787
788 FT_EXPORT_DEF( FT_Error ) 788 FT_EXPORT_DEF( FT_Error )
789 FT_Stroker_New( FT_Library library, 789 FT_Stroker_New( FT_Library library,
790 FT_Stroker *astroker ) 790 FT_Stroker *astroker )
791 { 791 {
792 FT_Error error; 792 FT_Error error; /* assigned in FT_NEW */
793 FT_Memory memory; 793 FT_Memory memory;
794 FT_Stroker stroker = NULL; 794 FT_Stroker stroker = NULL;
795 795
796 796
797 if ( !library ) 797 if ( !library )
798 return FT_Err_Invalid_Argument; 798 return FT_THROW( Invalid_Argument );
799 799
800 memory = library->memory; 800 memory = library->memory;
801 801
802 if ( !FT_NEW( stroker ) ) 802 if ( !FT_NEW( stroker ) )
803 { 803 {
804 stroker->library = library; 804 stroker->library = library;
805 805
806 ft_stroke_border_init( &stroker->borders[0], memory ); 806 ft_stroke_border_init( &stroker->borders[0], memory );
807 ft_stroke_border_init( &stroker->borders[1], memory ); 807 ft_stroke_border_init( &stroker->borders[1], memory );
808 } 808 }
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 1119
1120 1120
1121 /* compute middle point */ 1121 /* compute middle point */
1122 FT_Vector_From_Polar( &middle, 1122 FT_Vector_From_Polar( &middle,
1123 FT_MulFix( radius, stroker->miter_limit ), 1123 FT_MulFix( radius, stroker->miter_limit ),
1124 phi ); 1124 phi );
1125 middle.x += stroker->center.x; 1125 middle.x += stroker->center.x;
1126 middle.y += stroker->center.y; 1126 middle.y += stroker->center.y;
1127 1127
1128 /* compute first angle point */ 1128 /* compute first angle point */
1129 length = FT_MulFix( radius, 1129 length = FT_MulDiv( radius, 0x10000L - sigma,
1130 FT_DivFix( 0x10000L - sigma, 1130 ft_pos_abs( FT_Sin( theta ) ) );
1131 ft_pos_abs( FT_Sin( theta ) ) ) );
1132 1131
1133 FT_Vector_From_Polar( &delta, length, phi + rotate ); 1132 FT_Vector_From_Polar( &delta, length, phi + rotate );
1134 delta.x += middle.x; 1133 delta.x += middle.x;
1135 delta.y += middle.y; 1134 delta.y += middle.y;
1136 1135
1137 error = ft_stroke_border_lineto( border, &delta, FALSE ); 1136 error = ft_stroke_border_lineto( border, &delta, FALSE );
1138 if ( error ) 1137 if ( error )
1139 goto Exit; 1138 goto Exit;
1140 1139
1141 /* compute second angle point */ 1140 /* compute second angle point */
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y ); 1487 gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y );
1489 1488
1490 bvec.x = end.x - start.x; 1489 bvec.x = end.x - start.x;
1491 bvec.y = end.y - start.y; 1490 bvec.y = end.y - start.y;
1492 1491
1493 blen = FT_Vector_Length( &bvec ); 1492 blen = FT_Vector_Length( &bvec );
1494 1493
1495 sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) ); 1494 sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) );
1496 sinB = ft_pos_abs( FT_Sin( beta - gamma ) ); 1495 sinB = ft_pos_abs( FT_Sin( beta - gamma ) );
1497 1496
1498 alen = FT_DivFix( FT_MulFix( blen, sinA ), sinB ); 1497 alen = FT_MulDiv( blen, sinA, sinB );
1499 1498
1500 FT_Vector_From_Polar( &delta, alen, beta ); 1499 FT_Vector_From_Polar( &delta, alen, beta );
1501 delta.x += start.x; 1500 delta.x += start.x;
1502 delta.y += start.y; 1501 delta.y += start.y;
1503 1502
1504 /* circumnavigate the negative sector backwards */ 1503 /* circumnavigate the negative sector backwards */
1505 border->movable = FALSE; 1504 border->movable = FALSE;
1506 error = ft_stroke_border_lineto( border, &delta, FALSE ); 1505 error = ft_stroke_border_lineto( border, &delta, FALSE );
1507 if ( error ) 1506 if ( error )
1508 goto Exit; 1507 goto Exit;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y ); 1694 gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y );
1696 1695
1697 bvec.x = end.x - start.x; 1696 bvec.x = end.x - start.x;
1698 bvec.y = end.y - start.y; 1697 bvec.y = end.y - start.y;
1699 1698
1700 blen = FT_Vector_Length( &bvec ); 1699 blen = FT_Vector_Length( &bvec );
1701 1700
1702 sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) ); 1701 sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) );
1703 sinB = ft_pos_abs( FT_Sin( beta - gamma ) ); 1702 sinB = ft_pos_abs( FT_Sin( beta - gamma ) );
1704 1703
1705 alen = FT_DivFix( FT_MulFix( blen, sinA ), sinB ); 1704 alen = FT_MulDiv( blen, sinA, sinB );
1706 1705
1707 FT_Vector_From_Polar( &delta, alen, beta ); 1706 FT_Vector_From_Polar( &delta, alen, beta );
1708 delta.x += start.x; 1707 delta.x += start.x;
1709 delta.y += start.y; 1708 delta.y += start.y;
1710 1709
1711 /* circumnavigate the negative sector backwards */ 1710 /* circumnavigate the negative sector backwards */
1712 border->movable = FALSE; 1711 border->movable = FALSE;
1713 error = ft_stroke_border_lineto( border, &delta, FALSE ); 1712 error = ft_stroke_border_lineto( border, &delta, FALSE );
1714 if ( error ) 1713 if ( error )
1715 goto Exit; 1714 goto Exit;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 FT_StrokerBorder border, 1947 FT_StrokerBorder border,
1949 FT_UInt *anum_points, 1948 FT_UInt *anum_points,
1950 FT_UInt *anum_contours ) 1949 FT_UInt *anum_contours )
1951 { 1950 {
1952 FT_UInt num_points = 0, num_contours = 0; 1951 FT_UInt num_points = 0, num_contours = 0;
1953 FT_Error error; 1952 FT_Error error;
1954 1953
1955 1954
1956 if ( !stroker || border > 1 ) 1955 if ( !stroker || border > 1 )
1957 { 1956 {
1958 error = FT_Err_Invalid_Argument; 1957 error = FT_THROW( Invalid_Argument );
1959 goto Exit; 1958 goto Exit;
1960 } 1959 }
1961 1960
1962 error = ft_stroke_border_get_counts( stroker->borders + border, 1961 error = ft_stroke_border_get_counts( stroker->borders + border,
1963 &num_points, &num_contours ); 1962 &num_points, &num_contours );
1964 Exit: 1963 Exit:
1965 if ( anum_points ) 1964 if ( anum_points )
1966 *anum_points = num_points; 1965 *anum_points = num_points;
1967 1966
1968 if ( anum_contours ) 1967 if ( anum_contours )
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 char* tags; 2053 char* tags;
2055 2054
2056 FT_Error error; 2055 FT_Error error;
2057 2056
2058 FT_Int n; /* index of contour in outline */ 2057 FT_Int n; /* index of contour in outline */
2059 FT_UInt first; /* index of first point in contour */ 2058 FT_UInt first; /* index of first point in contour */
2060 FT_Int tag; /* current point's state */ 2059 FT_Int tag; /* current point's state */
2061 2060
2062 2061
2063 if ( !outline || !stroker ) 2062 if ( !outline || !stroker )
2064 return FT_Err_Invalid_Argument; 2063 return FT_THROW( Invalid_Argument );
2065 2064
2066 FT_Stroker_Rewind( stroker ); 2065 FT_Stroker_Rewind( stroker );
2067 2066
2068 first = 0; 2067 first = 0;
2069 2068
2070 for ( n = 0; n < outline->n_contours; n++ ) 2069 for ( n = 0; n < outline->n_contours; n++ )
2071 { 2070 {
2072 FT_UInt last; /* index of last point in contour */ 2071 FT_UInt last; /* index of last point in contour */
2073 2072
2074 2073
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 2231
2233 first = last + 1; 2232 first = last + 1;
2234 } 2233 }
2235 2234
2236 return FT_Err_Ok; 2235 return FT_Err_Ok;
2237 2236
2238 Exit: 2237 Exit:
2239 return error; 2238 return error;
2240 2239
2241 Invalid_Outline: 2240 Invalid_Outline:
2242 return FT_Err_Invalid_Outline; 2241 return FT_THROW( Invalid_Outline );
2243 } 2242 }
2244 2243
2245 2244
2246 /* declare an extern to access `ft_outline_glyph_class' globally */ 2245 /* declare an extern to access `ft_outline_glyph_class' globally */
2247 /* allocated in `ftglyph.c', and use the FT_OUTLINE_GLYPH_CLASS_GET */ 2246 /* allocated in `ftglyph.c', and use the FT_OUTLINE_GLYPH_CLASS_GET */
2248 /* macro to access it when FT_CONFIG_OPTION_PIC is defined */ 2247 /* macro to access it when FT_CONFIG_OPTION_PIC is defined */
2249 #ifndef FT_CONFIG_OPTION_PIC 2248 #ifndef FT_CONFIG_OPTION_PIC
2250 extern const FT_Glyph_Class ft_outline_glyph_class; 2249 extern const FT_Glyph_Class ft_outline_glyph_class;
2251 #endif 2250 #endif
2252 #include "basepic.h" 2251 #include "basepic.h"
2253 2252
2254 2253
2255 /* documentation is in ftstroke.h */ 2254 /* documentation is in ftstroke.h */
2256 2255
2257 FT_EXPORT_DEF( FT_Error ) 2256 FT_EXPORT_DEF( FT_Error )
2258 FT_Glyph_Stroke( FT_Glyph *pglyph, 2257 FT_Glyph_Stroke( FT_Glyph *pglyph,
2259 FT_Stroker stroker, 2258 FT_Stroker stroker,
2260 FT_Bool destroy ) 2259 FT_Bool destroy )
2261 { 2260 {
2262 FT_Error error = FT_Err_Invalid_Argument; 2261 FT_Error error = FT_ERR( Invalid_Argument );
2263 FT_Glyph glyph = NULL; 2262 FT_Glyph glyph = NULL;
2264 FT_Library library = stroker->library; 2263 FT_Library library = stroker->library;
2265 2264
2266 FT_UNUSED( library ); 2265 FT_UNUSED( library );
2267 2266
2268 2267
2269 if ( pglyph == NULL ) 2268 if ( pglyph == NULL )
2270 goto Exit; 2269 goto Exit;
2271 2270
2272 glyph = *pglyph; 2271 glyph = *pglyph;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 2327
2329 2328
2330 /* documentation is in ftstroke.h */ 2329 /* documentation is in ftstroke.h */
2331 2330
2332 FT_EXPORT_DEF( FT_Error ) 2331 FT_EXPORT_DEF( FT_Error )
2333 FT_Glyph_StrokeBorder( FT_Glyph *pglyph, 2332 FT_Glyph_StrokeBorder( FT_Glyph *pglyph,
2334 FT_Stroker stroker, 2333 FT_Stroker stroker,
2335 FT_Bool inside, 2334 FT_Bool inside,
2336 FT_Bool destroy ) 2335 FT_Bool destroy )
2337 { 2336 {
2338 FT_Error error = FT_Err_Invalid_Argument; 2337 FT_Error error = FT_ERR( Invalid_Argument );
2339 FT_Glyph glyph = NULL; 2338 FT_Glyph glyph = NULL;
2340 FT_Library library = stroker->library; 2339 FT_Library library = stroker->library;
2341 2340
2342 FT_UNUSED( library ); 2341 FT_UNUSED( library );
2343 2342
2344 2343
2345 if ( pglyph == NULL ) 2344 if ( pglyph == NULL )
2346 goto Exit; 2345 goto Exit;
2347 2346
2348 glyph = *pglyph; 2347 glyph = *pglyph;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 2409
2411 if ( !destroy ) 2410 if ( !destroy )
2412 *pglyph = NULL; 2411 *pglyph = NULL;
2413 2412
2414 Exit: 2413 Exit:
2415 return error; 2414 return error;
2416 } 2415 }
2417 2416
2418 2417
2419 /* END */ 2418 /* END */
OLDNEW
« no previous file with comments | « src/base/ftstream.c ('k') | src/base/ftsynth.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698