@@ -15,10 +15,10 @@ use gpu_types::{PrimitiveInstanceData, RasterizationSpace, GlyphInstance};
15
15
use gpu_types:: { PrimitiveHeader , PrimitiveHeaderIndex , TransformPaletteId , TransformPalette } ;
16
16
use internal_types:: { FastHashMap , SavedTargetIndex , TextureSource } ;
17
17
use picture:: { Picture3DContext , PictureCompositeMode , PicturePrimitive , PictureSurface } ;
18
- use prim_store:: { BrushKind , BrushPrimitive , DeferredResolve , PrimitiveTemplateKind , PrimitiveDataStore } ;
18
+ use prim_store:: { DeferredResolve , PrimitiveTemplateKind , PrimitiveDataStore } ;
19
19
use prim_store:: { EdgeAaSegmentMask , ImageSource , PrimitiveInstanceKind } ;
20
20
use prim_store:: { VisibleGradientTile , PrimitiveInstance , PrimitiveOpacity , SegmentInstanceIndex } ;
21
- use prim_store:: { BrushSegment , ClipMaskKind , ClipTaskIndex , PrimitiveDetails } ;
21
+ use prim_store:: { BrushSegment , ClipMaskKind , ClipTaskIndex } ;
22
22
use render_task:: { RenderTaskAddress , RenderTaskId , RenderTaskTree } ;
23
23
use renderer:: { BlendMode , ImageBufferKind , ShaderColorMode } ;
24
24
use renderer:: BLOCKS_PER_UV_RECT ;
@@ -909,6 +909,7 @@ impl AlphaBatchBuilder {
909
909
PrimitiveInstanceKind :: YuvImage { .. } |
910
910
PrimitiveInstanceKind :: Image { .. } |
911
911
PrimitiveInstanceKind :: LinearGradient { .. } |
912
+ PrimitiveInstanceKind :: RadialGradient { .. } |
912
913
PrimitiveInstanceKind :: Clear => {
913
914
unreachable ! ( ) ;
914
915
}
@@ -1401,102 +1402,9 @@ impl AlphaBatchBuilder {
1401
1402
}
1402
1403
}
1403
1404
(
1404
- PrimitiveInstanceKind :: LegacyPrimitive { prim_index } ,
1405
+ PrimitiveInstanceKind :: LegacyPrimitive { .. } ,
1405
1406
PrimitiveTemplateKind :: Unused ,
1406
1407
) => {
1407
- let prim = & ctx. prim_store . primitives [ prim_index. 0 ] ;
1408
-
1409
- // If the primitive is internally decomposed into multiple sub-primitives we may not
1410
- // use some of the per-primitive data and get it from each sub-primitive instead.
1411
- let is_multiple_primitives = match prim. details {
1412
- PrimitiveDetails :: Brush ( ref brush) => {
1413
- match brush. kind {
1414
- BrushKind :: RadialGradient { visible_tiles_range, .. } => !visible_tiles_range. is_empty ( ) ,
1415
- }
1416
- }
1417
- } ;
1418
-
1419
- let specified_blend_mode = BlendMode :: PremultipliedAlpha ;
1420
-
1421
- match prim. details {
1422
- PrimitiveDetails :: Brush ( ref brush) => {
1423
- let non_segmented_blend_mode = if !brush. opacity . is_opaque ||
1424
- prim_instance. clip_task_index != ClipTaskIndex :: INVALID ||
1425
- transform_kind == TransformedRectKind :: Complex
1426
- {
1427
- specified_blend_mode
1428
- } else {
1429
- BlendMode :: None
1430
- } ;
1431
-
1432
- let prim_cache_address = if is_multiple_primitives {
1433
- GpuCacheAddress :: invalid ( )
1434
- } else {
1435
- gpu_cache. get_address ( & brush. gpu_location )
1436
- } ;
1437
-
1438
- let prim_header = PrimitiveHeader {
1439
- local_rect : prim. local_rect ,
1440
- local_clip_rect : prim_instance. combined_local_clip_rect ,
1441
- task_address,
1442
- specific_prim_address : prim_cache_address,
1443
- clip_task_address,
1444
- transform_id,
1445
- } ;
1446
-
1447
- if prim_instance. is_chased ( ) {
1448
- println ! ( "\t task target {:?}" , self . target_rect) ;
1449
- println ! ( "\t {:?}" , prim_header) ;
1450
- }
1451
-
1452
- match brush. kind {
1453
- BrushKind :: RadialGradient { ref stops_handle, visible_tiles_range, .. } if !visible_tiles_range. is_empty ( ) => {
1454
- let visible_tiles = & ctx. scratch . gradient_tiles [ visible_tiles_range] ;
1455
-
1456
- add_gradient_tiles (
1457
- visible_tiles,
1458
- stops_handle,
1459
- BrushBatchKind :: RadialGradient ,
1460
- specified_blend_mode,
1461
- bounding_rect,
1462
- clip_task_address,
1463
- gpu_cache,
1464
- & mut self . batch_list ,
1465
- & prim_header,
1466
- prim_headers,
1467
- z_id,
1468
- ) ;
1469
- }
1470
- _ => {
1471
- if let Some ( params) = brush. get_batch_params (
1472
- gpu_cache,
1473
- ) {
1474
- let prim_header_index = prim_headers. push ( & prim_header, z_id, params. prim_user_data ) ;
1475
- if prim_instance. is_chased ( ) {
1476
- println ! ( "\t {:?} {:?}, task relative bounds {:?}" ,
1477
- params. batch_kind, prim_header_index, bounding_rect) ;
1478
- }
1479
-
1480
- self . add_segmented_prim_to_batch (
1481
- brush. segment_desc . as_ref ( ) . map ( |desc| desc. segments . as_slice ( ) ) ,
1482
- brush. opacity ,
1483
- & params,
1484
- specified_blend_mode,
1485
- non_segmented_blend_mode,
1486
- prim_header_index,
1487
- clip_task_address,
1488
- bounding_rect,
1489
- transform_kind,
1490
- render_tasks,
1491
- z_id,
1492
- prim_instance. clip_task_index ,
1493
- ctx,
1494
- ) ;
1495
- }
1496
- }
1497
- }
1498
- }
1499
- }
1500
1408
}
1501
1409
(
1502
1410
PrimitiveInstanceKind :: ImageBorder { .. } ,
@@ -1964,6 +1872,89 @@ impl AlphaBatchBuilder {
1964
1872
) ;
1965
1873
}
1966
1874
}
1875
+ (
1876
+ PrimitiveInstanceKind :: RadialGradient { visible_tiles_range, .. } ,
1877
+ PrimitiveTemplateKind :: RadialGradient { stops_handle, ref brush_segments, .. }
1878
+ ) => {
1879
+ let specified_blend_mode = BlendMode :: PremultipliedAlpha ;
1880
+
1881
+ let mut prim_header = PrimitiveHeader {
1882
+ local_rect : prim_data. prim_rect ,
1883
+ local_clip_rect : prim_instance. combined_local_clip_rect ,
1884
+ task_address,
1885
+ specific_prim_address : GpuCacheAddress :: invalid ( ) ,
1886
+ clip_task_address,
1887
+ transform_id,
1888
+ } ;
1889
+
1890
+ if visible_tiles_range. is_empty ( ) {
1891
+ let non_segmented_blend_mode = if !prim_data. opacity . is_opaque ||
1892
+ prim_instance. clip_task_index != ClipTaskIndex :: INVALID ||
1893
+ transform_kind == TransformedRectKind :: Complex
1894
+ {
1895
+ specified_blend_mode
1896
+ } else {
1897
+ BlendMode :: None
1898
+ } ;
1899
+
1900
+ let batch_params = BrushBatchParameters :: shared (
1901
+ BrushBatchKind :: RadialGradient ,
1902
+ BatchTextures :: no_texture ( ) ,
1903
+ [
1904
+ stops_handle. as_int ( gpu_cache) ,
1905
+ 0 ,
1906
+ 0 ,
1907
+ ] ,
1908
+ 0 ,
1909
+ ) ;
1910
+
1911
+ prim_header. specific_prim_address = gpu_cache. get_address ( & prim_data. gpu_cache_handle ) ;
1912
+
1913
+ let prim_header_index = prim_headers. push (
1914
+ & prim_header,
1915
+ z_id,
1916
+ batch_params. prim_user_data ,
1917
+ ) ;
1918
+
1919
+ let segments = if brush_segments. is_empty ( ) {
1920
+ None
1921
+ } else {
1922
+ Some ( brush_segments. as_slice ( ) )
1923
+ } ;
1924
+
1925
+ self . add_segmented_prim_to_batch (
1926
+ segments,
1927
+ prim_data. opacity ,
1928
+ & batch_params,
1929
+ specified_blend_mode,
1930
+ non_segmented_blend_mode,
1931
+ prim_header_index,
1932
+ clip_task_address,
1933
+ bounding_rect,
1934
+ transform_kind,
1935
+ render_tasks,
1936
+ z_id,
1937
+ prim_instance. clip_task_index ,
1938
+ ctx,
1939
+ ) ;
1940
+ } else {
1941
+ let visible_tiles = & ctx. scratch . gradient_tiles [ * visible_tiles_range] ;
1942
+
1943
+ add_gradient_tiles (
1944
+ visible_tiles,
1945
+ stops_handle,
1946
+ BrushBatchKind :: RadialGradient ,
1947
+ specified_blend_mode,
1948
+ bounding_rect,
1949
+ clip_task_address,
1950
+ gpu_cache,
1951
+ & mut self . batch_list ,
1952
+ & prim_header,
1953
+ prim_headers,
1954
+ z_id,
1955
+ ) ;
1956
+ }
1957
+ }
1967
1958
_ => {
1968
1959
unreachable ! ( ) ;
1969
1960
}
@@ -2295,28 +2286,6 @@ impl BrushBatchParameters {
2295
2286
}
2296
2287
}
2297
2288
2298
- impl BrushPrimitive {
2299
- fn get_batch_params (
2300
- & self ,
2301
- gpu_cache : & mut GpuCache ,
2302
- ) -> Option < BrushBatchParameters > {
2303
- match self . kind {
2304
- BrushKind :: RadialGradient { ref stops_handle, .. } => {
2305
- Some ( BrushBatchParameters :: shared (
2306
- BrushBatchKind :: RadialGradient ,
2307
- BatchTextures :: no_texture ( ) ,
2308
- [
2309
- stops_handle. as_int ( gpu_cache) ,
2310
- 0 ,
2311
- 0 ,
2312
- ] ,
2313
- 0 ,
2314
- ) )
2315
- }
2316
- }
2317
- }
2318
- }
2319
-
2320
2289
impl PrimitiveInstance {
2321
2290
pub fn is_cacheable (
2322
2291
& self ,
@@ -2345,6 +2314,7 @@ impl PrimitiveInstance {
2345
2314
PrimitiveInstanceKind :: ImageBorder { .. } |
2346
2315
PrimitiveInstanceKind :: Rectangle { .. } |
2347
2316
PrimitiveInstanceKind :: LinearGradient { .. } |
2317
+ PrimitiveInstanceKind :: RadialGradient { .. } |
2348
2318
PrimitiveInstanceKind :: Clear => {
2349
2319
return true ;
2350
2320
}
0 commit comments