File tree Expand file tree Collapse file tree 3 files changed +46
-7
lines changed
Expand file tree Collapse file tree 3 files changed +46
-7
lines changed Original file line number Diff line number Diff line change @@ -672,8 +672,9 @@ uniform vec2 vBboxSize;
672672attribute vec2 vAttrXY;
673673
674674void 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);
677678}" ;
678679
679680static 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
454454
455455 use rayon:: iter:: IntoParallelRefIterator ;
456456 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 < _ > > ( ) ;
457472
458473 let all_vertices = nodes
459474 . as_ref ( )
@@ -464,9 +479,27 @@ pub fn join_tessellated_nodes(nodes: &[TessellatedSvgNode]) -> TessellatedSvgNod
464479 let all_indices = nodes
465480 . as_ref ( )
466481 . 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+
468494 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+
469501 indices. push ( GL_RESTART_INDEX ) ;
502+
470503 indices
471504 } )
472505 . collect :: < Vec < _ > > ( ) ;
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ struct Dataset {
3434extern "C"
3535fn layout ( data : & mut RefAny , _: & mut LayoutCallbackInfo ) -> StyledDom {
3636 Dom :: body ( )
37- . with_inline_style ( "background: #ffffff00 ;" . into ( ) )
37+ . with_inline_style ( "background: #ffffff; padding: 10px ;" . into ( ) )
3838 . with_child (
3939 Dom :: image ( ImageRef :: callback ( data. clone ( ) , render_my_texture) )
4040 . with_inline_style ( "
@@ -131,7 +131,7 @@ fn startup_window_inner(data: &mut RefAny, info: &mut CallbackInfo) -> Option<()
131131 gl_context. clone ( )
132132 ) ) ;
133133
134- let mut col = ColorU :: from_str ( "#abc0cfdd " . into ( ) ) ;
134+ let mut col = ColorU :: from_str ( "#abc0cf " . into ( ) ) ;
135135
136136 data. texture = Some ( Texture :: allocate_rgba8 (
137137 gl_context. clone ( ) ,
@@ -163,12 +163,17 @@ fn parse_multipolygons(data: &str) -> Vec<SvgMultiPolygon> {
163163
164164 let mut current = SvgPoint { x : i[ 0 ] , y : i[ 1 ] } ;
165165 current. x -= 13.804493 ;
166- current. x *= 10000.0 ;
167166 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 ;
169173
170174 last = Some ( current) ;
171175 let last_point = last_point?;
176+
172177 Some ( SvgPathElement :: Line ( SvgLine { start : last_point, end : current } ) )
173178 } ) . collect :: < Vec < _ > > ( ) . into ( ) ,
174179 }
You can’t perform that action at this time.
0 commit comments