@@ -124,22 +124,31 @@ def _convert_paths_slow(ctx, paths, transforms, clip=None):
124
124
125
125
126
126
def _convert_paths_fast (ctx , paths , transforms , clip = None ):
127
+ # We directly convert to the internal representation used by cairo, for
128
+ # which ABI compatibility is guaranteed. The layout is for each item is
129
+ # --CODE(4)-- -LENGTH(4)- ---------PAD(8)---------
130
+ # ----------X(8)---------- ----------Y(8)----------
131
+ # with the size in bytes in parentheses, and (X, Y) repeated as many times
132
+ # as there are points for the current code.
127
133
ffi = cairo .ffi
128
134
cleaneds = [path .cleaned (transform = transform , clip = clip )
129
135
for path , transform in zip (paths , transforms )]
130
136
vertices = np .concatenate ([cleaned .vertices for cleaned in cleaneds ])
131
137
codes = np .concatenate ([cleaned .codes for cleaned in cleaneds ])
132
138
133
- # TODO: Implement Bezier degree elevation formula. Note that the "slow"
134
- # implementation is, in fact, also incorrect...
139
+ # TODO: Implement Bezier degree elevation formula. For now, fall back to
140
+ # the "slow" implementation, though note that that implementation is, in
141
+ # fact, also incorrect...
135
142
if np .any (codes == Path .CURVE3 ):
136
143
raise NotImplementedError ("Quadratic Bezier curves are not supported" )
144
+
137
145
# Remove unused vertices and convert to cairo codes. Note that unlike
138
146
# cairo_close_path, we do not explicitly insert an extraneous MOVE_TO after
139
147
# CLOSE_PATH, so our resulting buffer may be smaller.
140
148
vertices = vertices [(codes != Path .STOP ) & (codes != Path .CLOSEPOLY )]
141
149
codes = codes [codes != Path .STOP ]
142
150
codes = _MPL_TO_CAIRO_PATH_TYPE [codes ]
151
+
143
152
# Where are the headers of each cairo portions?
144
153
cairo_type_sizes = _CAIRO_PATH_TYPE_SIZES [codes ]
145
154
cairo_type_positions = np .insert (np .cumsum (cairo_type_sizes ), 0 , 0 )
@@ -301,6 +310,7 @@ def _draw_paths():
301
310
return
302
311
gc_vars , rgb_fc = reuse_key
303
312
gc = copy .copy (gc0 )
313
+ # We actually need to call the setters to reset the internal state.
304
314
vars (gc ).update (gc_vars )
305
315
for k , v in gc_vars .items ():
306
316
try :
0 commit comments