@@ -47,6 +47,7 @@ enum QuadRenderStrategy {
47
47
NinePatch {
48
48
radius : LayoutVector2D ,
49
49
clip_rect : LayoutRect ,
50
+ mode : ClipMode ,
50
51
} ,
51
52
/// Split the primitive into coarse tiles so that each tile independently
52
53
/// has the opportunity to be drawn directly in the destination target or
@@ -260,19 +261,36 @@ pub fn push_quad(
260
261
& scratch. quad_segments ,
261
262
) ;
262
263
}
263
- QuadRenderStrategy :: NinePatch { clip_rect, radius } => {
264
+ QuadRenderStrategy :: NinePatch { clip_rect, radius, mode } => {
264
265
let unclipped_surface_rect = surface
265
266
. map_to_device_rect ( & clip_chain. pic_coverage_rect , frame_context. spatial_tree ) ;
266
267
267
- let local_corner_0 = LayoutRect :: new (
268
- clip_rect. min ,
269
- clip_rect. min + radius,
270
- ) ;
271
-
272
- let local_corner_1 = LayoutRect :: new (
273
- clip_rect. max - radius,
274
- clip_rect. max ,
275
- ) ;
268
+ let ( local_corner_0, local_corner_1) = match mode {
269
+ ClipMode :: Clip => {
270
+ (
271
+ LayoutRect :: new (
272
+ clip_rect. min ,
273
+ clip_rect. min + radius,
274
+ ) ,
275
+ LayoutRect :: new (
276
+ clip_rect. max - radius,
277
+ clip_rect. max ,
278
+ ) ,
279
+ )
280
+ }
281
+ ClipMode :: ClipOut => {
282
+ (
283
+ LayoutRect :: new (
284
+ local_rect. min ,
285
+ clip_rect. min + radius,
286
+ ) ,
287
+ LayoutRect :: new (
288
+ clip_rect. max - radius,
289
+ local_rect. max ,
290
+ ) ,
291
+ )
292
+ }
293
+ } ;
276
294
277
295
let pic_corner_0 = pic_state. map_local_to_pic . map ( & local_corner_0) . unwrap ( ) ;
278
296
let pic_corner_1 = pic_state. map_local_to_pic . map ( & local_corner_1) . unwrap ( ) ;
@@ -316,8 +334,19 @@ pub fn push_quad(
316
334
continue ;
317
335
}
318
336
319
- // Only create render tasks for the corners.
320
- let create_task = x != 1 && y != 1 ;
337
+ let create_task = match mode {
338
+ ClipMode :: Clip => {
339
+ // Only create render tasks for the corners.
340
+ x != 1 && y != 1
341
+ }
342
+ ClipMode :: ClipOut => {
343
+ if x == 1 && y == 1 {
344
+ continue ;
345
+ }
346
+
347
+ true
348
+ }
349
+ } ;
321
350
322
351
let rect = DeviceIntRect :: new ( point2 ( x0, y0) , point2 ( x1, y1) ) ;
323
352
@@ -389,7 +418,7 @@ fn get_prim_render_strategy(
389
418
let clip_instance = clip_store. get_instance_from_range ( & clip_chain. clips_range , 0 ) ;
390
419
let clip_node = & interned_clips[ clip_instance. handle ] ;
391
420
392
- if let ClipItemKind :: RoundedRectangle { ref radius, mode : ClipMode :: Clip , rect, .. } = clip_node. item . kind {
421
+ if let ClipItemKind :: RoundedRectangle { ref radius, mode, rect, .. } = clip_node. item . kind {
393
422
let max_corner_width = radius. top_left . width
394
423
. max ( radius. bottom_left . width )
395
424
. max ( radius. top_right . width )
@@ -419,6 +448,7 @@ fn get_prim_render_strategy(
419
448
return QuadRenderStrategy :: NinePatch {
420
449
radius : LayoutVector2D :: new ( max_corner_width, max_corner_height) ,
421
450
clip_rect : rect,
451
+ mode,
422
452
} ;
423
453
}
424
454
}
0 commit comments