File tree 3 files changed +44
-5
lines changed
3 files changed +44
-5
lines changed Original file line number Diff line number Diff line change @@ -672,8 +672,9 @@ uniform vec2 vBboxSize;
672
672
attribute vec2 vAttrXY;
673
673
674
674
void main() {
675
- gl_Position = vec4(vAttrXY / vBboxSize - vec2(1.0), 1.0, 1.0);
676
- gl_PointSize = 1.0;
675
+ vec2 vCalc = vAttrXY / vBboxSize;
676
+ vec2 vCalc1 = vCalc - vec2(1.0, 1.0);
677
+ gl_Position = vec4(vCalc1, 0.0, 1.0);
677
678
}" ;
678
679
679
680
static SVG_FRAGMENT_SHADER : & [ u8 ] = b"#version 150
Original file line number Diff line number Diff line change @@ -454,6 +454,21 @@ pub fn join_tessellated_nodes(nodes: &[TessellatedSvgNode]) -> TessellatedSvgNod
454
454
455
455
use rayon:: iter:: IntoParallelRefIterator ;
456
456
use rayon:: iter:: ParallelIterator ;
457
+ use rayon:: iter:: IndexedParallelIterator ;
458
+ use rayon:: iter:: IntoParallelRefMutIterator ;
459
+
460
+ let mut index_offset = 0 ;
461
+
462
+ // note: can not be parallelized!
463
+ let all_index_offsets = nodes
464
+ . as_ref ( )
465
+ . iter ( )
466
+ . map ( |t| {
467
+ let i = index_offset;
468
+ index_offset += t. vertices . len ( ) ;
469
+ i
470
+ } )
471
+ . collect :: < Vec < _ > > ( ) ;
457
472
458
473
let all_vertices = nodes
459
474
. as_ref ( )
@@ -464,9 +479,27 @@ pub fn join_tessellated_nodes(nodes: &[TessellatedSvgNode]) -> TessellatedSvgNod
464
479
let all_indices = nodes
465
480
. as_ref ( )
466
481
. par_iter ( )
467
- . flat_map ( |t| {
482
+ . enumerate ( )
483
+ . flat_map ( |( buffer_index, t) | {
484
+
485
+ // since the vertex buffers are now joined,
486
+ // offset the indices by the vertex buffers lengths
487
+ // encountered so far
488
+ let vertex_buffer_offset: u32 = all_index_offsets
489
+ . get ( buffer_index)
490
+ . copied ( )
491
+ . unwrap_or ( 0 )
492
+ . min ( core:: u32:: MAX as usize ) as u32 ;
493
+
468
494
let mut indices = t. indices . clone ( ) . into_library_owned_vec ( ) ;
495
+ if vertex_buffer_offset != 0 {
496
+ indices
497
+ . par_iter_mut ( )
498
+ . for_each ( |i| { * i += vertex_buffer_offset; } ) ;
499
+ }
500
+
469
501
indices. push ( GL_RESTART_INDEX ) ;
502
+
470
503
indices
471
504
} )
472
505
. collect :: < Vec < _ > > ( ) ;
Original file line number Diff line number Diff line change @@ -163,12 +163,17 @@ fn parse_multipolygons(data: &str) -> Vec<SvgMultiPolygon> {
163
163
164
164
let mut current = SvgPoint { x : i[ 0 ] , y : i[ 1 ] } ;
165
165
current. x -= 13.804493 ;
166
- current. x *= 10000.0 ;
167
166
current. y -= 51.05264 ;
168
- current. y *= 10000.0 ;
167
+ current. x *= 50000.0 ;
168
+ current. y *= 50000.0 ;
169
+ current. x += 500.0 ;
170
+ current. y += 500.0 ;
171
+ current. x *= 2.0 ;
172
+ current. y *= 2.0 ;
169
173
170
174
last = Some ( current) ;
171
175
let last_point = last_point?;
176
+
172
177
Some ( SvgPathElement :: Line ( SvgLine { start : last_point, end : current } ) )
173
178
} ) . collect :: < Vec < _ > > ( ) . into ( ) ,
174
179
}
You can’t perform that action at this time.
0 commit comments