×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    2

    getting slower periodically when drawing to canvas

    Hello,
    I'm using 5800 XpressMusic and writing some program that uses canvas with pys60
    Although its drawing functionality seems very fast, I'm suffering a problem that updating gets slower periodically.

    When I first update canvas, it just takes less than 0.01 sec to call e32.ao_yield() but when I update canvas several times in a while respectively, it gets slower and then takes more than 0.1 sec to call e32.ao_yield(). It's too slow for smooth scrolling or games.

    Even "ball.py" example provided by nokia or other sources using canvas seem to have same problem,
    and examples using gles doesn't seem to have such a problem.

    Following is my test problem. It constantly updates canvas and prints time spent in e32.ao_yield().

    Code:
    import appuifw, e32, graphics, time
    
    def quit():
    	global running
    	running=0
    
    def dout(str):
    	global dmsg
    	dmsg.append(str)
    	if len(dmsg) > 20: del(dmsg[0])
    
    def handle_redraw(rect):
    	global img, app1
    	if img:
    		app1.blit(img)
    
    app1 = appuifw.Canvas(redraw_callback=handle_redraw)
    appuifw.app.directional_pad = False
    appuifw.app.body = app1
    appuifw.app.title = u"Canvas Test v0.0"
    appuifw.app.screen = "normal"
    appuifw.app.menu = [(u"Exit", quit)]
    
    appuifw.app.exit_key_handler = quit
    
    running = 1
    dmsg = []
    count = 0
    
    img = graphics.Image.new(size=(app1.size[0], app1.size[1]))
    
    while running:
    	redraw = True
    	if redraw:
    		img.clear(0xffffff)
    		for i in xrange(0, len(dmsg)):
    			img.text((1, 20*i), unicode(dmsg[i]), fill=0x000000, font=None)
    
    	count = count + 1
    
    #	if count % 10 == 0: handle_redraw(())
    	handle_redraw(())
    
    	beginTime = time.time()
    
    	e32.ao_yield()
    #	e32.ao_sleep(0.02)
    
    	endTime = time.time()
    
    	dout("count %d duration %.2f" % (count, endTime-beginTime))
    And output is like following:

    Code:
    count 3 duration 0.03
    count 4 duration 0.04
    count 5 duration 0.05
    count 6 duration 0.06
    count 7 duration 0.06
    count 8 duration 0.07
    count 9 duration 0.08
    count 10 duration 0.09
    count 11 duration 0.10
    count 12 duration 0.11
    count 13 duration 0.12
    count 14 duration 0.15
    count 15 duration 0.03
    count 16 duration 0.04
    count 17 duration 0.05
    count 18 duration 0.06
    count 19 duration 0.06
    Is it problem of pys60? or 5800 XpressMusic? (or Korean version of 5800 XpressMusic) or symbian? or am I using in wrong way?

  2. #2
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: getting slower periodically when drawing to canvas

    No, I can not help you

    But I think canvas object should have some function to be called when you want a repainting instead calling this repainting by myself. I had problem with redraw() concurrency (my own calls to redraw() and canvas calls to redraw(), from O.S.). However, you are already using double buffer and only blit() at redraw (minimal intersection).

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    2

    Re: getting slower periodically when drawing to canvas

    I found the solution by myself.

    unless called by redraw_handler, it should call begin_redraw and end_redraw to redraw the canvas,
    so following code solved everything, now it's working very fast!


    Code:
    	app1.begin_redraw()
    	handle_redraw(())
    	app1.end_redraw()
    Hope it helps to someone,
    Happy new year!

  4. #4
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: getting slower periodically when drawing to canvas

    Quote Originally Posted by innover View Post
    I found the solution by myself.

    unless called by redraw_handler, it should call begin_redraw and end_redraw to redraw the canvas,
    so following code solved everything, now it's working very fast!
    You have created a critical section, right ? Perfect, it is a good solution. Thanks for sharing it and happy new year !

Similar Threads

  1. Problem while drawing on canvas
    By knights123 in forum Mobile Java General
    Replies: 31
    Last Post: 2009-08-27, 12:12
  2. Drawing on video canvas
    By t1amir@walla.co.il in forum Mobile Java Media (Graphics & Sounds)
    Replies: 7
    Last Post: 2008-07-17, 17:14
  3. Replies: 7
    Last Post: 2008-07-11, 06:41
  4. Drawing on canvas close to edge is clipping
    By james_levander in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2004-02-03, 21:53
  5. Major problem with delegation to Canvas
    By bartekn in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2003-10-08, 17:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×