Page 1 of 1

VectorDrawing slowness

Posted: Sat Jul 03, 2021 1:33 pm
by Lima
Why is the first run so slow?
Is there any way to solve this?
My thanks to anyone who can help.
(If you have already run some software that uses the same library, the delay is not that great.)

Code: Select all



Procedure TestVectorOutput()
  Static i=0
  i+1
  LoadFont(0,"",8,#PB_Font_Bold)
  
              CreateImage(0,100,100,24,$808080)
time=ElapsedMilliseconds()
  StartVectorDrawing(ImageVectorOutput(0))
 
     VectorFont(FontID(0),16)
;
       MovePathCursor(5,5)

        DrawVectorText("test "+Str(i))
        StopVectorDrawing()
   
        
        ImageGadget(0,200,120,0,0, ImageID(0))
        
        SetGadgetText(2,Str(ElapsedMilliseconds()-time))
        
      EndProcedure
      
      
   OpenWindow(0, 0, 0, 600, 720, "test",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
       
   TextGadget(1,200,20,90,25,"Elapsed time :")
   StringGadget(2,300,20,100,25,"")
   ButtonGadget(3,200,600,140,25,"Run program")
   
   TestVectorOutput()
   
   Repeat
     
     Event = WaitWindowEvent()
     
     Select Event
     
       Case #PB_Event_Gadget
         Select EventGadget()
           Case 3 

                FreeGadget(0)
              
                  TestVectorOutput()
              
         EndSelect

       EndSelect
     Until Event = #PB_Event_CloseWindow  

Re: VectorDrawing slowness

Posted: Sat Jul 03, 2021 1:57 pm
by mk-soft
Still goes fast here, but
it is better not to create a new image and ImageGadget every time. That saves a lot of time.

Code: Select all

Procedure TestVectorOutput()
  Static i=0
  i+1
  LoadFont(0,"",8,#PB_Font_Bold)
  
  time=ElapsedMilliseconds()
  StartVectorDrawing(ImageVectorOutput(0))
  
  VectorSourceColor($FF808080)
  FillVectorOutput()
  
  VectorFont(FontID(0),16)
  VectorSourceColor($FF00FDFD)
  ;
  MovePathCursor(5,5)
  
  DrawVectorText("test "+Str(i))
  StopVectorDrawing()
  
  SetGadgetState(0, ImageID(0))
  
  SetGadgetText(2,Str(ElapsedMilliseconds()-time))
  
EndProcedure


OpenWindow(0, 0, 0, 600, 720, "test",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)

ImageGadget(0,200,120,0,0, 0)
TextGadget(1,200,20,90,25,"Elapsed time :")
StringGadget(2,300,20,100,25,"")
ButtonGadget(3,200,600,140,25,"Run program")

CreateImage(0,100,100,24,$808080)

TestVectorOutput()

Repeat
  
  Event = WaitWindowEvent()
  
  Select Event
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 3 
          TestVectorOutput()
          
      EndSelect
      
  EndSelect
Until Event = #PB_Event_CloseWindow  

Re: VectorDrawing slowness

Posted: Sat Jul 03, 2021 8:22 pm
by STARGĂ…TE
Since I am using Windows 10, the first call of StartVectorDrawing() is also on my system very slow, probably due to some background initialization of the GDI+ lib. Some times it takes 1 second to see the drawing (e.g. in a canvas gadget). But just the first call during a windows session.

Re: VectorDrawing slowness

Posted: Tue Jul 06, 2021 6:37 pm
by Lima
The changes introduced by mk-soft have not changed the situation, the execution after the computer starts is still very long.
(Windows 7 and 10, PB 5.73)

Thank you all.