@@ -7,10 +7,10 @@ use api::{LayoutSideOffsets, LayoutSizeAu, LayoutPrimitiveInfo, LayoutToDeviceSc
7
7
use api:: { DeviceVector2D , DevicePoint , LayoutRect , LayoutSize , NormalBorder , DeviceIntSize } ;
8
8
use api:: { AuHelpers , LayoutPoint , RepeatMode , TexelRect } ;
9
9
use ellipse:: Ellipse ;
10
- use euclid:: { SideOffsets2D , vec2} ;
10
+ use euclid:: vec2;
11
11
use display_list_flattener:: DisplayListFlattener ;
12
12
use gpu_types:: { BorderInstance , BorderSegment , BrushFlags } ;
13
- use prim_store:: { BorderSegmentInfo , BrushSegment } ;
13
+ use prim_store:: { BorderSegmentInfo , BrushSegment , NinePatchDescriptor } ;
14
14
use prim_store:: { EdgeAaSegmentMask , PrimitiveContainer , ScrollNodeAndClipChain } ;
15
15
use util:: { lerp, RectHelpers } ;
16
16
@@ -1130,51 +1130,44 @@ pub fn build_border_instances(
1130
1130
1131
1131
pub fn create_nine_patch_segments (
1132
1132
rect : & LayoutRect ,
1133
- widths : & LayoutSideOffsets ,
1134
- width : i32 ,
1135
- height : i32 ,
1136
- slice : SideOffsets2D < i32 > ,
1137
- fill : bool ,
1138
- repeat_horizontal : RepeatMode ,
1139
- repeat_vertical : RepeatMode ,
1140
- outset : SideOffsets2D < f32 > ,
1133
+ nine_patch : & NinePatchDescriptor ,
1141
1134
) -> Vec < BrushSegment > {
1142
1135
// Calculate the modified rect as specific by border-image-outset
1143
1136
let origin = LayoutPoint :: new (
1144
- rect. origin . x - outset. left ,
1145
- rect. origin . y - outset. top ,
1137
+ rect. origin . x - nine_patch . outset . left ,
1138
+ rect. origin . y - nine_patch . outset . top ,
1146
1139
) ;
1147
1140
let size = LayoutSize :: new (
1148
- rect. size . width + outset. left + outset. right ,
1149
- rect. size . height + outset. top + outset. bottom ,
1141
+ rect. size . width + nine_patch . outset . left + nine_patch . outset . right ,
1142
+ rect. size . height + nine_patch . outset . top + nine_patch . outset . bottom ,
1150
1143
) ;
1151
1144
let rect = LayoutRect :: new ( origin, size) ;
1152
1145
1153
1146
// Calculate the local texel coords of the slices.
1154
1147
let px0 = 0.0 ;
1155
- let px1 = slice. left as f32 ;
1156
- let px2 = width as f32 - slice. right as f32 ;
1157
- let px3 = width as f32 ;
1148
+ let px1 = nine_patch . slice . left as f32 ;
1149
+ let px2 = nine_patch . width as f32 - nine_patch . slice . right as f32 ;
1150
+ let px3 = nine_patch . width as f32 ;
1158
1151
1159
1152
let py0 = 0.0 ;
1160
- let py1 = slice. top as f32 ;
1161
- let py2 = height as f32 - slice. bottom as f32 ;
1162
- let py3 = height as f32 ;
1153
+ let py1 = nine_patch . slice . top as f32 ;
1154
+ let py2 = nine_patch . height as f32 - nine_patch . slice . bottom as f32 ;
1155
+ let py3 = nine_patch . height as f32 ;
1163
1156
1164
1157
let tl_outer = LayoutPoint :: new ( rect. origin . x , rect. origin . y ) ;
1165
- let tl_inner = tl_outer + vec2 ( widths. left , widths. top ) ;
1158
+ let tl_inner = tl_outer + vec2 ( nine_patch . widths . left , nine_patch . widths . top ) ;
1166
1159
1167
1160
let tr_outer = LayoutPoint :: new ( rect. origin . x + rect. size . width , rect. origin . y ) ;
1168
- let tr_inner = tr_outer + vec2 ( -widths. right , widths. top ) ;
1161
+ let tr_inner = tr_outer + vec2 ( -nine_patch . widths . right , nine_patch . widths . top ) ;
1169
1162
1170
1163
let bl_outer = LayoutPoint :: new ( rect. origin . x , rect. origin . y + rect. size . height ) ;
1171
- let bl_inner = bl_outer + vec2 ( widths. left , -widths. bottom ) ;
1164
+ let bl_inner = bl_outer + vec2 ( nine_patch . widths . left , -nine_patch . widths . bottom ) ;
1172
1165
1173
1166
let br_outer = LayoutPoint :: new (
1174
1167
rect. origin . x + rect. size . width ,
1175
1168
rect. origin . y + rect. size . height ,
1176
1169
) ;
1177
- let br_inner = br_outer - vec2 ( widths. right , widths. bottom ) ;
1170
+ let br_inner = br_outer - vec2 ( nine_patch . widths . right , nine_patch . widths . bottom ) ;
1178
1171
1179
1172
fn add_segment (
1180
1173
segments : & mut Vec < BrushSegment > ,
@@ -1254,13 +1247,13 @@ pub fn create_nine_patch_segments(
1254
1247
) ;
1255
1248
1256
1249
// Center
1257
- if fill {
1250
+ if nine_patch . fill {
1258
1251
add_segment (
1259
1252
& mut segments,
1260
1253
LayoutRect :: from_floats ( tl_inner. x , tl_inner. y , tr_inner. x , bl_inner. y ) ,
1261
1254
TexelRect :: new ( px1, py1, px2, py2) ,
1262
- repeat_horizontal,
1263
- repeat_vertical
1255
+ nine_patch . repeat_horizontal ,
1256
+ nine_patch . repeat_vertical
1264
1257
) ;
1265
1258
}
1266
1259
@@ -1271,15 +1264,15 @@ pub fn create_nine_patch_segments(
1271
1264
& mut segments,
1272
1265
LayoutRect :: from_floats ( tl_inner. x , tl_outer. y , tr_inner. x , tl_inner. y ) ,
1273
1266
TexelRect :: new ( px1, py0, px2, py1) ,
1274
- repeat_horizontal,
1267
+ nine_patch . repeat_horizontal ,
1275
1268
RepeatMode :: Stretch ,
1276
1269
) ;
1277
1270
// Bottom
1278
1271
add_segment (
1279
1272
& mut segments,
1280
1273
LayoutRect :: from_floats ( bl_inner. x , bl_inner. y , br_inner. x , bl_outer. y ) ,
1281
1274
TexelRect :: new ( px1, py2, px2, py3) ,
1282
- repeat_horizontal,
1275
+ nine_patch . repeat_horizontal ,
1283
1276
RepeatMode :: Stretch ,
1284
1277
) ;
1285
1278
// Left
@@ -1288,15 +1281,15 @@ pub fn create_nine_patch_segments(
1288
1281
LayoutRect :: from_floats ( tl_outer. x , tl_inner. y , tl_inner. x , bl_inner. y ) ,
1289
1282
TexelRect :: new ( px0, py1, px1, py2) ,
1290
1283
RepeatMode :: Stretch ,
1291
- repeat_vertical,
1284
+ nine_patch . repeat_vertical ,
1292
1285
) ;
1293
1286
// Right
1294
1287
add_segment (
1295
1288
& mut segments,
1296
1289
LayoutRect :: from_floats ( tr_inner. x , tr_inner. y , br_outer. x , br_inner. y ) ,
1297
1290
TexelRect :: new ( px2, py1, px3, py2) ,
1298
1291
RepeatMode :: Stretch ,
1299
- repeat_vertical,
1292
+ nine_patch . repeat_vertical ,
1300
1293
) ;
1301
1294
1302
1295
segments
0 commit comments