×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    6

    Fast Drawing to Screen, How to use CDirectScreenBitmap properly ?

    Hello
    I'm currently in the process of trying to draw to screen as fast as possible on a S60 5th device, my ultimate dream is to get my app running at constant 60fps.

    So I wanted to draw directly to the frame buffer, but looks like there is no way to do that in S60 5th. I heard that a good workaround is to use CDirectScreenBitmap, so I tried using it, with this example : http://wiki.forum.nokia.com/index.ph...ctScreenBitmap

    It's working but there are few issues :

    -when running the app the first time, the drawing is correctly synchronized with the screen refresh rate, the app run at a constant 30 fps (one frame out of two, which makes sense),
    But, if the phone goes into sleep mode when the apps is running, either by a press to the keyguard switch or after a while, when it resumes the drawing is NOT synchronized with the screen refresh rate anymore, and there is some tearing, plus the app is now running at 38 fps. Even if I restart the app, the problem remains, the only way to get things back to normal (with sync screen) is to reboot the phone.
    Anyone experienced this before ? is it a symbian os bug or is there something wrong with my app ?

    oh and the Vsync never works when the app run under the windows emulator, is this normal too ?

    -Now comes the performance issue :
    I only get 30fps at max while the screen refresh rate is 60Hz (one frame out of two).
    I tried to draw something very simple in order to use the less time as possible while drawing to the backbuffer, but I still get the same results. Actually, the whole process of :
    getting backbufferadress
    writing data to the backbuffer
    call EndUpdate
    takes less than 5ms (on the phone, because for some reasons EndUpdate takes much more time on the emulator)

    but the wait for the Update to finish takes lot of time,I think that's weird, because, correct me if I'm wrong, but if the backbuffer is copied to the screenbuffer while trying to avoid tearing, this means that it needs to be copied during the Vblank, ie while the screen is not using the screen buffer, maybe I'm wrong but in any case it should take less than a screen refresh time . so why does it looks like it takes more than 1/60 sec to do it, I know it waits for the Vblank to start copy (hence the "anti-tearing"), but even if I write very few pixels to the buffer (which takes no time) and start to render the frame immediately after one copy is completed, I can't get over 30fps


    -In the example quoted above, it is stated that start processing the next frame in RunL (which is called when the copy of the frame is completed) is slow, but if I use a Cperiodic timer to process frame it is even slower, no matter what the Interval time is.

    It is also stated that there is a delay between CDirectScreenBitmap::EndUpdate() and the completion of screen refresh , this may explain the problem I talked about before, but it doesn't says how to avoid it.

    but I'm not really sure of how all this stuff is working, is it really a copy from the backbuffer to the screenbuffer ? (a buffer switching would have been faster)
    or maybe it copy to the screen at the same speed the screen is being refresh, meaning this leaves only the Vblank time to write to the backbuffer. I don't know so if someone knows something about that, but any kind of help is appreciated.



    Thank your if you can find some time to help me.

  2. #2
    Registered User
    Join Date
    Oct 2009
    Posts
    6

    Re: Fast Drawing to Screen, How to use CDirectScreenBitmap properly ?

    I managed to solve the first issue, there is actually a big mistake in the sample from the wiki,in this example when restart is called, the directscreenbitamp is created with this :

    PHP Code:
    iDSBitmap->Create(
            
    TRect(00KMpScreenWidthKMpScreenHeight), CDirectScreenBitmap::EDoubleBuffer); 
    it is created with a full screen TRect without even caring about what the drawing region is, and that's the main problem, because it is clearly stated that :
    Creates a CDirectScreenBitmap object which can be used for drawing to
    a region of the screen indicated by aScreenRect. This region must have
    previously been 'claimed' via the Window Servers Direct Screen Access API.
    in particular, when the phone goes into sleep mode Restart is called with an empty region to draw(don't know why but that's the way it is), and I think that's the reason why the drawing gets off sync.

    In order to get it work, what I do, is that I only create the directscreenbitmap and draw to screen when the region to draw is the whole screen :

    PHP Code:
    //...
    //start DSA, get the region
    //...


    if(!(region->BoundingRect() == TRect(00KMpScreenWidthKMpScreenHeight)  && region->Count()==1))//only draw if region is full screen 
            
    return;

    //...
    //create the directscreenbitmap, start drawing
    //... 
    I know it's not really a good way to do it, because when only some part of the screen needs to be drawn(eg : when a popup message appear), nothing is drawn, but it's not really important for me


    so know it's working quite fine, still at 30fps, which is not really enough for what I'm trying to do, but I'll try to deal with it for now

Similar Threads

  1. Replies: 6
    Last Post: 2009-10-28, 19:16
  2. Drawing screen dynamically
    By jinuthomas in forum Symbian User Interface
    Replies: 5
    Last Post: 2009-09-24, 13:54
  3. UI: Full Screen Mode
    By GENERAL_INFO in forum Symbian User Interface
    Replies: 3
    Last Post: 2004-11-22, 06:27
  4. Just to let you all know about screen drawing
    By ljioannou in forum Mobile Java General
    Replies: 0
    Last Post: 2003-08-12, 01:30
  5. Replies: 0
    Last Post: 1970-01-01, 02:00

Posting Permissions

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