1
-
2
1
/* This Source Code Form is subject to the terms of the Mozilla Public
3
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -1267,7 +1266,7 @@ impl<'a> DisplayListFlattener<'a> {
1267
1266
PrimitiveInstanceKind :: Picture { ref mut pic_index, ..} => * pic_index = current_pic_index,
1268
1267
_ => unreachable ! ( )
1269
1268
} ;
1270
-
1269
+
1271
1270
if cur_instance. is_chased ( ) {
1272
1271
println ! ( "\t is a composite picture for a stacking context with {:?}" , filter) ;
1273
1272
}
@@ -1304,7 +1303,7 @@ impl<'a> DisplayListFlattener<'a> {
1304
1303
PrimitiveInstanceKind :: Picture { ref mut pic_index, ..} => * pic_index = current_pic_index,
1305
1304
_ => unreachable ! ( )
1306
1305
} ;
1307
-
1306
+
1308
1307
if cur_instance. is_chased ( ) {
1309
1308
println ! ( "\t is a mix-blend picture for a stacking context with {:?}" , mix_blend_mode) ;
1310
1309
}
@@ -1602,42 +1601,10 @@ impl<'a> DisplayListFlattener<'a> {
1602
1601
match item {
1603
1602
// TODO(djg): ugh. de-duplicate this code.
1604
1603
ShadowItem :: Primitive ( ref pending_primitive) => {
1605
- // Offset the local rect and clip rect by the shadow offset.
1606
- let mut info = pending_primitive. info . clone ( ) ;
1607
- info. rect = info. rect . translate ( & pending_shadow. shadow . offset ) ;
1608
- info. clip_rect = info. clip_rect . translate ( & pending_shadow. shadow . offset ) ;
1609
-
1610
- // Construct and add a primitive for the given shadow.
1611
- let shadow_prim_instance = self . create_primitive (
1612
- & info,
1613
- pending_primitive. clip_and_scroll . clip_chain_id ,
1614
- pending_primitive. clip_and_scroll . spatial_node_index ,
1615
- pending_primitive. prim . create_shadow (
1616
- & pending_shadow. shadow ,
1617
- ) ,
1618
- ) ;
1619
-
1620
- // Add the new primitive to the shadow picture.
1621
- prims. push ( shadow_prim_instance) ;
1604
+ self . add_shadow_prim ( & pending_shadow, pending_primitive, & mut prims)
1622
1605
}
1623
1606
ShadowItem :: TextRun ( ref pending_text_run) => {
1624
- // Offset the local rect and clip rect by the shadow offset.
1625
- let mut info = pending_text_run. info . clone ( ) ;
1626
- info. rect = info. rect . translate ( & pending_shadow. shadow . offset ) ;
1627
- info. clip_rect = info. clip_rect . translate ( & pending_shadow. shadow . offset ) ;
1628
-
1629
- // Construct and add a primitive for the given shadow.
1630
- let shadow_prim_instance = self . create_primitive (
1631
- & info,
1632
- pending_text_run. clip_and_scroll . clip_chain_id ,
1633
- pending_text_run. clip_and_scroll . spatial_node_index ,
1634
- pending_text_run. prim . create_shadow (
1635
- & pending_shadow. shadow ,
1636
- ) ,
1637
- ) ;
1638
-
1639
- // Add the new primitive to the shadow picture.
1640
- prims. push ( shadow_prim_instance) ;
1607
+ self . add_shadow_prim ( & pending_shadow, pending_text_run, & mut prims)
1641
1608
}
1642
1609
_ => { }
1643
1610
}
@@ -1704,31 +1671,10 @@ impl<'a> DisplayListFlattener<'a> {
1704
1671
}
1705
1672
}
1706
1673
ShadowItem :: Primitive ( pending_primitive) => {
1707
- // For a normal primitive, if it has alpha > 0, then we add this
1708
- // as a normal primitive to the parent picture.
1709
- if pending_primitive. prim . is_visible ( ) {
1710
- self . add_prim_to_draw_list (
1711
- & pending_primitive. info ,
1712
- pending_primitive. clip_and_scroll . clip_chain_id ,
1713
- pending_primitive. clip_and_scroll ,
1714
- pending_primitive. prim ,
1715
- ) ;
1716
- }
1674
+ self . add_shadow_prim_to_draw_list ( pending_primitive)
1717
1675
} ,
1718
1676
ShadowItem :: TextRun ( pending_text_run) => {
1719
- // For a normal primitive, if it has alpha > 0, then we add this
1720
- // as a normal primitive to the parent picture.
1721
- //
1722
- // TODO(djg): Can this be cleaned up? It looks identical to
1723
- // another piece of code.
1724
- if pending_text_run. prim . is_visible ( ) {
1725
- self . add_prim_to_draw_list (
1726
- & pending_text_run. info ,
1727
- pending_text_run. clip_and_scroll . clip_chain_id ,
1728
- pending_text_run. clip_and_scroll ,
1729
- pending_text_run. prim ,
1730
- ) ;
1731
- }
1677
+ self . add_shadow_prim_to_draw_list ( pending_text_run)
1732
1678
} ,
1733
1679
}
1734
1680
}
@@ -1737,6 +1683,54 @@ impl<'a> DisplayListFlattener<'a> {
1737
1683
self . pending_shadow_items = items;
1738
1684
}
1739
1685
1686
+ fn add_shadow_prim < P > (
1687
+ & mut self ,
1688
+ pending_shadow : & PendingShadow ,
1689
+ pending_primitive : & PendingPrimitive < P > ,
1690
+ prims : & mut Vec < PrimitiveInstance > ,
1691
+ )
1692
+ where
1693
+ P : Internable < InternData =PrimitiveSceneData > + CreateShadow ,
1694
+ P :: Source : AsInstanceKind < Handle < P :: Marker > > + BuildKey < P > ,
1695
+ DocumentResources : InternerMut < P > ,
1696
+ {
1697
+ // Offset the local rect and clip rect by the shadow offset.
1698
+ let mut info = pending_primitive. info . clone ( ) ;
1699
+ info. rect = info. rect . translate ( & pending_shadow. shadow . offset ) ;
1700
+ info. clip_rect = info. clip_rect . translate ( & pending_shadow. shadow . offset ) ;
1701
+
1702
+ // Construct and add a primitive for the given shadow.
1703
+ let shadow_prim_instance = self . create_primitive (
1704
+ & info,
1705
+ pending_primitive. clip_and_scroll . clip_chain_id ,
1706
+ pending_primitive. clip_and_scroll . spatial_node_index ,
1707
+ pending_primitive. prim . create_shadow (
1708
+ & pending_shadow. shadow ,
1709
+ ) ,
1710
+ ) ;
1711
+
1712
+ // Add the new primitive to the shadow picture.
1713
+ prims. push ( shadow_prim_instance) ;
1714
+ }
1715
+
1716
+ fn add_shadow_prim_to_draw_list < P > ( & mut self , pending_primitive : PendingPrimitive < P > )
1717
+ where
1718
+ P : Internable < InternData = PrimitiveSceneData > + IsVisible ,
1719
+ P :: Source : AsInstanceKind < Handle < P :: Marker > > + BuildKey < P > ,
1720
+ DocumentResources : InternerMut < P > ,
1721
+ {
1722
+ // For a normal primitive, if it has alpha > 0, then we add this
1723
+ // as a normal primitive to the parent picture.
1724
+ if pending_primitive. prim . is_visible ( ) {
1725
+ self . add_prim_to_draw_list (
1726
+ & pending_primitive. info ,
1727
+ pending_primitive. clip_and_scroll . clip_chain_id ,
1728
+ pending_primitive. clip_and_scroll ,
1729
+ pending_primitive. prim ,
1730
+ ) ;
1731
+ }
1732
+ }
1733
+
1740
1734
#[ cfg( debug_assertions) ]
1741
1735
fn register_chase_primitive_by_rect (
1742
1736
& mut self ,
0 commit comments