@@ -14,6 +14,7 @@ use crate::gpu_types::{BrushFlags, BrushInstance, PrimitiveHeaders, ZBufferId, Z
14
14
use crate :: gpu_types:: { ClipMaskInstance , SplitCompositeInstance , BrushShaderKind } ;
15
15
use crate :: gpu_types:: { PrimitiveInstanceData , RasterizationSpace , GlyphInstance } ;
16
16
use crate :: gpu_types:: { PrimitiveHeader , PrimitiveHeaderIndex , TransformPaletteId , TransformPalette } ;
17
+ use crate :: gpu_types:: { ImageBrushData , get_shader_opacity} ;
17
18
use crate :: internal_types:: { FastHashMap , SavedTargetIndex , Swizzle , TextureSource , Filter } ;
18
19
use crate :: picture:: { Picture3DContext , PictureCompositeMode , PicturePrimitive } ;
19
20
use crate :: prim_store:: { DeferredResolve , EdgeAaSegmentMask , PrimitiveInstanceKind , PrimitiveVisibilityIndex , PrimitiveVisibilityMask } ;
@@ -849,12 +850,12 @@ impl BatchBuilder {
849
850
850
851
let batch_params = BrushBatchParameters :: instanced (
851
852
BrushBatchKind :: Image ( ImageBufferKind :: Texture2DArray ) ,
852
- [
853
- ShaderColorMode :: Image as i32 | ( ( AlphaType :: PremultipliedAlpha as i32 ) << 16 ) ,
854
- RasterizationSpace :: Local as i32 ,
855
- get_shader_opacity ( 1.0 ) ,
856
- 0 ,
857
- ] ,
853
+ ImageBrushData {
854
+ color_mode : ShaderColorMode :: Image ,
855
+ alpha_type : AlphaType :: PremultipliedAlpha ,
856
+ raster_space : RasterizationSpace :: Local ,
857
+ opacity : 1. 0,
858
+ } . encode ( ) ,
858
859
segment_data,
859
860
) ;
860
861
@@ -1004,12 +1005,12 @@ impl BatchBuilder {
1004
1005
1005
1006
for glyph in glyphs {
1006
1007
batch. push ( base_instance. build (
1007
- ( ( render_task_address. 0 as i32 ) << 16 )
1008
- | clip_task_address. unwrap ( ) . 0 as i32 ,
1009
- ( subpx_dir as u32 as i32 ) << 24
1010
- | ( color_mode as u32 as i32 ) << 16
1011
- | glyph. index_in_text_run ,
1012
- glyph . uv_rect_address . as_int ( ) ,
1008
+ render_task_address,
1009
+ clip_task_address. unwrap ( ) ,
1010
+ subpx_dir,
1011
+ glyph . index_in_text_run ,
1012
+ glyph. uv_rect_address ,
1013
+ color_mode ,
1013
1014
) ) ;
1014
1015
}
1015
1016
}
@@ -1035,12 +1036,12 @@ impl BatchBuilder {
1035
1036
(
1036
1037
BrushBatchKind :: Image ( get_buffer_kind ( cache_item. texture_id ) ) ,
1037
1038
textures,
1038
- [
1039
- ShaderColorMode :: Image as i32 | ( ( AlphaType :: PremultipliedAlpha as i32 ) << 16 ) ,
1040
- RasterizationSpace :: Local as i32 ,
1041
- get_shader_opacity ( 1.0 ) ,
1042
- 0 ,
1043
- ] ,
1039
+ ImageBrushData {
1040
+ color_mode : ShaderColorMode :: Image ,
1041
+ alpha_type : AlphaType :: PremultipliedAlpha ,
1042
+ raster_space : RasterizationSpace :: Local ,
1043
+ opacity : 1. 0,
1044
+ } . encode ( ) ,
1044
1045
cache_item. uv_rect_handle . as_int ( gpu_cache) ,
1045
1046
)
1046
1047
}
@@ -1248,12 +1249,16 @@ impl BatchBuilder {
1248
1249
non_segmented_blend_mode,
1249
1250
textures,
1250
1251
) ;
1251
- let prim_header_index = prim_headers. push ( & prim_header, z_id, [
1252
- ShaderColorMode :: Image as i32 | ( ( AlphaType :: PremultipliedAlpha as i32 ) << 16 ) ,
1253
- RasterizationSpace :: Screen as i32 ,
1254
- get_shader_opacity ( 1.0 ) ,
1255
- 0 ,
1256
- ] ) ;
1252
+ let prim_header_index = prim_headers. push (
1253
+ & prim_header,
1254
+ z_id,
1255
+ ImageBrushData {
1256
+ color_mode : ShaderColorMode :: Image ,
1257
+ alpha_type : AlphaType :: PremultipliedAlpha ,
1258
+ raster_space : RasterizationSpace :: Screen ,
1259
+ opacity : 1.0 ,
1260
+ } . encode ( ) ,
1261
+ ) ;
1257
1262
1258
1263
self . add_brush_instance_to_batches (
1259
1264
key,
@@ -1323,12 +1328,16 @@ impl BatchBuilder {
1323
1328
..prim_header
1324
1329
} ;
1325
1330
1326
- let shadow_prim_header_index = prim_headers. push ( & shadow_prim_header, z_id, [
1327
- ShaderColorMode :: Alpha as i32 | ( ( AlphaType :: PremultipliedAlpha as i32 ) << 16 ) ,
1328
- RasterizationSpace :: Screen as i32 ,
1329
- get_shader_opacity ( 1.0 ) ,
1330
- 0 ,
1331
- ] ) ;
1331
+ let shadow_prim_header_index = prim_headers. push (
1332
+ & shadow_prim_header,
1333
+ z_id,
1334
+ ImageBrushData {
1335
+ color_mode : ShaderColorMode :: Alpha ,
1336
+ alpha_type : AlphaType :: PremultipliedAlpha ,
1337
+ raster_space : RasterizationSpace :: Screen ,
1338
+ opacity : 1.0 ,
1339
+ } . encode ( ) ,
1340
+ ) ;
1332
1341
1333
1342
self . add_brush_instance_to_batches (
1334
1343
shadow_key,
@@ -1346,12 +1355,16 @@ impl BatchBuilder {
1346
1355
}
1347
1356
let z_id_content = z_generator. next ( ) ;
1348
1357
1349
- let content_prim_header_index = prim_headers. push ( & prim_header, z_id_content, [
1350
- ShaderColorMode :: Image as i32 | ( ( AlphaType :: PremultipliedAlpha as i32 ) << 16 ) ,
1351
- RasterizationSpace :: Screen as i32 ,
1352
- get_shader_opacity ( 1.0 ) ,
1353
- 0 ,
1354
- ] ) ;
1358
+ let content_prim_header_index = prim_headers. push (
1359
+ & prim_header,
1360
+ z_id_content,
1361
+ ImageBrushData {
1362
+ color_mode : ShaderColorMode :: Image ,
1363
+ alpha_type : AlphaType :: PremultipliedAlpha ,
1364
+ raster_space : RasterizationSpace :: Screen ,
1365
+ opacity : 1.0 ,
1366
+ } . encode ( ) ,
1367
+ ) ;
1355
1368
1356
1369
self . add_brush_instance_to_batches (
1357
1370
content_key,
@@ -1525,12 +1538,16 @@ impl BatchBuilder {
1525
1538
BlendMode :: Advanced ( mode) ,
1526
1539
textures,
1527
1540
) ;
1528
- let prim_header_index = prim_headers. push ( & prim_header, z_id, [
1529
- ShaderColorMode :: Image as i32 | ( ( AlphaType :: PremultipliedAlpha as i32 ) << 16 ) ,
1530
- RasterizationSpace :: Local as i32 ,
1531
- get_shader_opacity ( 1.0 ) ,
1532
- 0 ,
1533
- ] ) ;
1541
+ let prim_header_index = prim_headers. push (
1542
+ & prim_header,
1543
+ z_id,
1544
+ ImageBrushData {
1545
+ color_mode : ShaderColorMode :: Image ,
1546
+ alpha_type : AlphaType :: PremultipliedAlpha ,
1547
+ raster_space : RasterizationSpace :: Local ,
1548
+ opacity : 1.0 ,
1549
+ } . encode ( ) ,
1550
+ ) ;
1534
1551
1535
1552
self . add_brush_instance_to_batches (
1536
1553
key,
@@ -1607,12 +1624,12 @@ impl BatchBuilder {
1607
1624
let batch_params = BrushBatchParameters :: shared (
1608
1625
BrushBatchKind :: Image ( ImageBufferKind :: Texture2DArray ) ,
1609
1626
textures,
1610
- [
1611
- ShaderColorMode :: Image as i32 | ( ( AlphaType :: PremultipliedAlpha as i32 ) << 16 ) ,
1612
- RasterizationSpace :: Screen as i32 ,
1613
- get_shader_opacity ( 1.0 ) ,
1614
- 0 ,
1615
- ] ,
1627
+ ImageBrushData {
1628
+ color_mode : ShaderColorMode :: Image ,
1629
+ alpha_type : AlphaType :: PremultipliedAlpha ,
1630
+ raster_space : RasterizationSpace :: Screen ,
1631
+ opacity : 1. 0,
1632
+ } . encode ( ) ,
1616
1633
uv_rect_address,
1617
1634
) ;
1618
1635
@@ -1680,12 +1697,16 @@ impl BatchBuilder {
1680
1697
non_segmented_blend_mode,
1681
1698
textures,
1682
1699
) ;
1683
- let prim_header_index = prim_headers. push ( & prim_header, z_id, [
1684
- ShaderColorMode :: Image as i32 | ( ( AlphaType :: PremultipliedAlpha as i32 ) << 16 ) ,
1685
- RasterizationSpace :: Screen as i32 ,
1686
- get_shader_opacity ( 1.0 ) ,
1687
- 0 ,
1688
- ] ) ;
1700
+ let prim_header_index = prim_headers. push (
1701
+ & prim_header,
1702
+ z_id,
1703
+ ImageBrushData {
1704
+ color_mode : ShaderColorMode :: Image ,
1705
+ alpha_type : AlphaType :: PremultipliedAlpha ,
1706
+ raster_space : RasterizationSpace :: Screen ,
1707
+ opacity : 1.0 ,
1708
+ } . encode ( ) ,
1709
+ ) ;
1689
1710
1690
1711
self . add_brush_instance_to_batches (
1691
1712
key,
@@ -1759,12 +1780,12 @@ impl BatchBuilder {
1759
1780
let batch_params = BrushBatchParameters :: shared (
1760
1781
BrushBatchKind :: Image ( get_buffer_kind ( cache_item. texture_id ) ) ,
1761
1782
textures,
1762
- [
1763
- ShaderColorMode :: Image as i32 | ( ( AlphaType :: PremultipliedAlpha as i32 ) << 16 ) ,
1764
- RasterizationSpace :: Local as i32 ,
1765
- get_shader_opacity ( 1.0 ) ,
1766
- 0 ,
1767
- ] ,
1783
+ ImageBrushData {
1784
+ color_mode : ShaderColorMode :: Image ,
1785
+ alpha_type : AlphaType :: PremultipliedAlpha ,
1786
+ raster_space : RasterizationSpace :: Local ,
1787
+ opacity : 1. 0,
1788
+ } . encode ( ) ,
1768
1789
cache_item. uv_rect_handle . as_int ( gpu_cache) ,
1769
1790
) ;
1770
1791
@@ -1976,12 +1997,12 @@ impl BatchBuilder {
1976
1997
rendering : image_data. image_rendering ,
1977
1998
tile : None ,
1978
1999
} ;
1979
- let prim_user_data = [
1980
- ShaderColorMode :: Image as i32 | ( ( image_data . alpha_type as i32 ) << 16 ) ,
1981
- RasterizationSpace :: Local as i32 ,
1982
- get_shader_opacity ( opacity_binding ) ,
1983
- 0 ,
1984
- ] ;
2000
+ let prim_user_data = ImageBrushData {
2001
+ color_mode : ShaderColorMode :: Image ,
2002
+ alpha_type : image_data . alpha_type ,
2003
+ raster_space : RasterizationSpace :: Local ,
2004
+ opacity : opacity_binding ,
2005
+ } . encode ( ) ;
1985
2006
1986
2007
if image_instance. visible_tiles . is_empty ( ) {
1987
2008
let cache_item = match image_data. source {
@@ -2156,12 +2177,13 @@ impl BatchBuilder {
2156
2177
2157
2178
let textures = BatchTextures :: color ( cache_item. texture_id ) ;
2158
2179
let batch_kind = BrushBatchKind :: Image ( get_buffer_kind ( cache_item. texture_id ) ) ;
2159
- let prim_user_data = [
2160
- ShaderColorMode :: Image as i32 | ( ( AlphaType :: PremultipliedAlpha as i32 ) << 16 ) ,
2161
- RasterizationSpace :: Local as i32 ,
2162
- get_shader_opacity ( 1.0 ) ,
2163
- 0 ,
2164
- ] ;
2180
+ let prim_user_data = ImageBrushData {
2181
+ color_mode : ShaderColorMode :: Image ,
2182
+ alpha_type : AlphaType :: PremultipliedAlpha ,
2183
+ raster_space : RasterizationSpace :: Local ,
2184
+ opacity : 1.0 ,
2185
+ } . encode ( ) ;
2186
+
2165
2187
let specific_resource_address = cache_item. uv_rect_handle . as_int ( gpu_cache) ;
2166
2188
prim_header. specific_prim_address = gpu_cache. get_address ( & ctx. globals . default_image_handle ) ;
2167
2189
@@ -2451,12 +2473,12 @@ impl BatchBuilder {
2451
2473
let prim_header_index = prim_headers. push (
2452
2474
& prim_header,
2453
2475
z_id,
2454
- [
2455
- ShaderColorMode :: Image as i32 | ( ( AlphaType :: PremultipliedAlpha as i32 ) << 16 ) ,
2456
- RasterizationSpace :: Screen as i32 ,
2457
- get_shader_opacity ( 1.0 ) ,
2458
- 0
2459
- ] ,
2476
+ ImageBrushData {
2477
+ color_mode : ShaderColorMode :: Image ,
2478
+ alpha_type : AlphaType :: PremultipliedAlpha ,
2479
+ raster_space : RasterizationSpace :: Screen ,
2480
+ opacity : 1.0 ,
2481
+ } . encode ( ) ,
2460
2482
) ;
2461
2483
2462
2484
self . add_brush_instance_to_batches (
@@ -3219,10 +3241,6 @@ fn get_buffer_kind(texture: TextureSource) -> ImageBufferKind {
3219
3241
}
3220
3242
}
3221
3243
3222
- fn get_shader_opacity ( opacity : f32 ) -> i32 {
3223
- ( opacity * 65535.0 ) . round ( ) as i32
3224
- }
3225
-
3226
3244
impl < ' a , ' rc > RenderTargetContext < ' a , ' rc > {
3227
3245
/// Retrieve the GPU task address for a given clip task instance.
3228
3246
/// Returns None if the segment was completely clipped out.
0 commit comments