@@ -18,7 +18,7 @@ use fnv::FnvHasher;
18
18
use gleam:: gl;
19
19
use internal_types:: { RendererFrame , ResultMsg , TextureUpdateOp } ;
20
20
use internal_types:: { TextureUpdateDetails , TextureUpdateList , PackedVertex , RenderTargetMode } ;
21
- use internal_types:: { ORTHO_NEAR_PLANE , ORTHO_FAR_PLANE , DevicePixel } ;
21
+ use internal_types:: { ORTHO_NEAR_PLANE , ORTHO_FAR_PLANE , DevicePoint } ;
22
22
use internal_types:: { PackedVertexForTextureCacheUpdate } ;
23
23
use internal_types:: { AxisDirection , TextureSampler , GLContextHandleWrapper } ;
24
24
use ipc_channel:: ipc;
@@ -76,7 +76,8 @@ const GPU_TAG_PRIM_COMPOSITE: GpuProfileTag = GpuProfileTag { label: "Composite"
76
76
const GPU_TAG_PRIM_TEXT_RUN : GpuProfileTag = GpuProfileTag { label : "TextRun" , color : ColorF { r : 0.0 , g : 0.0 , b : 1.0 , a : 1.0 } } ;
77
77
78
78
// Yellow / dark yellow
79
- const GPU_TAG_PRIM_ALIGNED_GRADIENT : GpuProfileTag = GpuProfileTag { label : "AlignedGradient" , color : ColorF { r : 1.0 , g : 1.0 , b : 0.0 , a : 1.0 } } ;
79
+ const GPU_TAG_PRIM_GRADIENT : GpuProfileTag = GpuProfileTag { label : "Gradient" , color : ColorF { r : 1.0 , g : 1.0 , b : 0.0 , a : 1.0 } } ;
80
+ const GPU_TAG_PRIM_GRADIENT_CLIP : GpuProfileTag = GpuProfileTag { label : "GradientClip" , color : ColorF { r : 1.0 , g : 1.0 , b : 0.0 , a : 1.0 } } ;
80
81
const GPU_TAG_PRIM_ANGLE_GRADIENT : GpuProfileTag = GpuProfileTag { label : "AngleGradient" , color : ColorF { r : 0.7 , g : 0.7 , b : 0.0 , a : 1.0 } } ;
81
82
82
83
// Cyan
@@ -328,7 +329,8 @@ pub struct Renderer {
328
329
ps_text_run : PrimitiveShader ,
329
330
ps_image : PrimitiveShader ,
330
331
ps_border : PrimitiveShader ,
331
- ps_aligned_gradient : PrimitiveShader ,
332
+ ps_gradient : PrimitiveShader ,
333
+ ps_gradient_clip : PrimitiveShader ,
332
334
ps_angle_gradient : PrimitiveShader ,
333
335
ps_box_shadow : PrimitiveShader ,
334
336
ps_rectangle_clip : PrimitiveShader ,
@@ -457,11 +459,17 @@ impl Renderer {
457
459
max_prim_instances,
458
460
& mut device,
459
461
options. precache_shaders ) ;
460
- let ps_aligned_gradient = PrimitiveShader :: new ( "ps_gradient_clip" ,
461
- max_ubo_vectors,
462
- max_prim_instances,
463
- & mut device,
464
- options. precache_shaders ) ;
462
+
463
+ let ps_gradient = PrimitiveShader :: new ( "ps_gradient" ,
464
+ max_ubo_vectors,
465
+ max_prim_instances,
466
+ & mut device,
467
+ options. precache_shaders ) ;
468
+ let ps_gradient_clip = PrimitiveShader :: new ( "ps_gradient_clip" ,
469
+ max_ubo_vectors,
470
+ max_prim_instances,
471
+ & mut device,
472
+ options. precache_shaders ) ;
465
473
let ps_angle_gradient = PrimitiveShader :: new ( "ps_angle_gradient" ,
466
474
max_ubo_vectors,
467
475
max_prim_instances,
@@ -641,8 +649,9 @@ impl Renderer {
641
649
ps_rectangle_clip : ps_rectangle_clip,
642
650
ps_image_clip : ps_image_clip,
643
651
ps_box_shadow : ps_box_shadow,
652
+ ps_gradient : ps_gradient,
653
+ ps_gradient_clip : ps_gradient_clip,
644
654
ps_angle_gradient : ps_angle_gradient,
645
- ps_aligned_gradient : ps_aligned_gradient,
646
655
ps_blend : ps_blend,
647
656
ps_composite : ps_composite,
648
657
max_clear_tiles : max_clear_tiles,
@@ -1265,8 +1274,8 @@ impl Renderer {
1265
1274
}
1266
1275
1267
1276
fn add_debug_rect ( & mut self ,
1268
- p0 : Point2D < DevicePixel > ,
1269
- p1 : Point2D < DevicePixel > ,
1277
+ p0 : DevicePoint ,
1278
+ p1 : DevicePoint ,
1270
1279
label : & str ,
1271
1280
c : & ColorF ) {
1272
1281
let tile_x0 = p0. x ;
@@ -1299,8 +1308,8 @@ impl Renderer {
1299
1308
tile_y1,
1300
1309
c) ;
1301
1310
if label. len ( ) > 0 {
1302
- self . debug . add_text ( ( tile_x0. 0 as f32 + tile_x1. 0 as f32 ) * 0.5 ,
1303
- ( tile_y0. 0 as f32 + tile_y1. 0 as f32 ) * 0.5 ,
1311
+ self . debug . add_text ( ( tile_x0 as f32 + tile_x1 as f32 ) * 0.5 ,
1312
+ ( tile_y0 as f32 + tile_y1 as f32 ) * 0.5 ,
1304
1313
label,
1305
1314
c) ;
1306
1315
}
@@ -1386,56 +1395,54 @@ impl Renderer {
1386
1395
gl:: clear ( gl:: COLOR_BUFFER_BIT ) ;
1387
1396
}
1388
1397
1389
- for batcher in & target. alpha_batchers {
1390
- for batch in & batcher. batches {
1391
- if batch. blending_enabled {
1392
- gl:: enable ( gl:: BLEND ) ;
1393
- } else {
1394
- gl:: disable ( gl:: BLEND ) ;
1395
- }
1398
+ for batch in & target. alpha_batcher . batches {
1399
+ if batch. blending_enabled {
1400
+ gl:: enable ( gl:: BLEND ) ;
1401
+ } else {
1402
+ gl:: disable ( gl:: BLEND ) ;
1403
+ }
1396
1404
1397
- match & batch. data {
1398
- & PrimitiveBatchData :: Blend ( ref ubo_data) => {
1399
- self . gpu_profile . add_marker ( GPU_TAG_PRIM_BLEND ) ;
1400
- let shader = self . ps_blend . get ( & mut self . device ) ;
1401
- self . device . bind_program ( shader, & projection) ;
1402
- self . device . bind_vao ( self . quad_vao_id ) ;
1405
+ match & batch. data {
1406
+ & PrimitiveBatchData :: Blend ( ref ubo_data) => {
1407
+ self . gpu_profile . add_marker ( GPU_TAG_PRIM_BLEND ) ;
1408
+ let shader = self . ps_blend . get ( & mut self . device ) ;
1409
+ self . device . bind_program ( shader, & projection) ;
1410
+ self . device . bind_vao ( self . quad_vao_id ) ;
1403
1411
1404
- for chunk in ubo_data. chunks ( self . max_prim_blends ) {
1405
- let ubos = gl:: gen_buffers ( 1 ) ;
1406
- let ubo = ubos[ 0 ] ;
1412
+ for chunk in ubo_data. chunks ( self . max_prim_blends ) {
1413
+ let ubos = gl:: gen_buffers ( 1 ) ;
1414
+ let ubo = ubos[ 0 ] ;
1407
1415
1408
- gl:: bind_buffer ( gl:: UNIFORM_BUFFER , ubo) ;
1409
- gl:: buffer_data ( gl:: UNIFORM_BUFFER , & chunk, gl:: STATIC_DRAW ) ;
1410
- gl:: bind_buffer_base ( gl:: UNIFORM_BUFFER , UBO_BIND_DATA , ubo) ;
1416
+ gl:: bind_buffer ( gl:: UNIFORM_BUFFER , ubo) ;
1417
+ gl:: buffer_data ( gl:: UNIFORM_BUFFER , & chunk, gl:: STATIC_DRAW ) ;
1418
+ gl:: bind_buffer_base ( gl:: UNIFORM_BUFFER , UBO_BIND_DATA , ubo) ;
1411
1419
1412
- self . device . draw_indexed_triangles_instanced_u16 ( 6 , chunk. len ( ) as gl:: GLint ) ;
1413
- self . profile_counters . vertices . add ( 6 * chunk. len ( ) ) ;
1414
- self . profile_counters . draw_calls . inc ( ) ;
1420
+ self . device . draw_indexed_triangles_instanced_u16 ( 6 , chunk. len ( ) as gl:: GLint ) ;
1421
+ self . profile_counters . vertices . add ( 6 * chunk. len ( ) ) ;
1422
+ self . profile_counters . draw_calls . inc ( ) ;
1415
1423
1416
- gl:: delete_buffers ( & ubos) ;
1417
- }
1424
+ gl:: delete_buffers ( & ubos) ;
1418
1425
}
1419
- & PrimitiveBatchData :: Composite ( ref ubo_data) => {
1420
- self . gpu_profile . add_marker ( GPU_TAG_PRIM_COMPOSITE ) ;
1421
- let shader = self . ps_composite . get ( & mut self . device ) ;
1422
- self . device . bind_program ( shader, & projection) ;
1423
- self . device . bind_vao ( self . quad_vao_id ) ;
1426
+ }
1427
+ & PrimitiveBatchData :: Composite ( ref ubo_data) => {
1428
+ self . gpu_profile . add_marker ( GPU_TAG_PRIM_COMPOSITE ) ;
1429
+ let shader = self . ps_composite . get ( & mut self . device ) ;
1430
+ self . device . bind_program ( shader, & projection) ;
1431
+ self . device . bind_vao ( self . quad_vao_id ) ;
1424
1432
1425
- for chunk in ubo_data. chunks ( self . max_prim_composites ) {
1426
- let ubos = gl:: gen_buffers ( 1 ) ;
1427
- let ubo = ubos[ 0 ] ;
1433
+ for chunk in ubo_data. chunks ( self . max_prim_composites ) {
1434
+ let ubos = gl:: gen_buffers ( 1 ) ;
1435
+ let ubo = ubos[ 0 ] ;
1428
1436
1429
- gl:: bind_buffer ( gl:: UNIFORM_BUFFER , ubo) ;
1430
- gl:: buffer_data ( gl:: UNIFORM_BUFFER , & chunk, gl:: STATIC_DRAW ) ;
1431
- gl:: bind_buffer_base ( gl:: UNIFORM_BUFFER , UBO_BIND_DATA , ubo) ;
1437
+ gl:: bind_buffer ( gl:: UNIFORM_BUFFER , ubo) ;
1438
+ gl:: buffer_data ( gl:: UNIFORM_BUFFER , & chunk, gl:: STATIC_DRAW ) ;
1439
+ gl:: bind_buffer_base ( gl:: UNIFORM_BUFFER , UBO_BIND_DATA , ubo) ;
1432
1440
1433
- self . device . draw_indexed_triangles_instanced_u16 ( 6 , chunk. len ( ) as gl:: GLint ) ;
1434
- self . profile_counters . vertices . add ( 6 * chunk. len ( ) ) ;
1435
- self . profile_counters . draw_calls . inc ( ) ;
1441
+ self . device . draw_indexed_triangles_instanced_u16 ( 6 , chunk. len ( ) as gl:: GLint ) ;
1442
+ self . profile_counters . vertices . add ( 6 * chunk. len ( ) ) ;
1443
+ self . profile_counters . draw_calls . inc ( ) ;
1436
1444
1437
- gl:: delete_buffers ( & ubos) ;
1438
- }
1445
+ gl:: delete_buffers ( & ubos) ;
1439
1446
}
1440
1447
}
1441
1448
& PrimitiveBatchData :: Rectangles ( ref ubo_data) => {
@@ -1531,9 +1538,9 @@ impl Renderer {
1531
1538
& projection) ;
1532
1539
}
1533
1540
}
1534
-
1535
- gl:: disable ( gl:: BLEND ) ;
1536
1541
}
1542
+
1543
+ gl:: disable ( gl:: BLEND ) ;
1537
1544
}
1538
1545
1539
1546
fn draw_tile_frame ( & mut self ,
0 commit comments