Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

GetDC() is really slow.


GetDC() is really slow.

Postby perrs » Oct 19, 2009 @ 11:52am

As I mentioned in an earlier thread I've been working on rendering text with a Device Context. Everything is working fine now, but it would seem that the GetDC() function is really slow. This wouldn't be a problem if I only had to call it once per frame, but apparently I'm not allowed to blit from the surface before I have released the Device Context. If I try I get an exception with the content "One or more surfaces are locked, preventing operation". This means that I will have to get and release the Device Context each time I need to draw some text, and seeing that this process easily takes about 25 ms this quickly becomes a major problem. Is there any way to blit from a surface without releasing the Device Context? If not, can you think of any other way to make this run faster?

Thanks in advance.

Per Rasmussen.
perrs
pm Member
 
Posts: 4
Joined: Sep 16, 2009 @ 8:35pm


Postby Johan » Oct 22, 2009 @ 6:47pm

Hello Per!

If you need to use Device Contexts on every frame, you could do as follows:

1. Modify GapiApplication so you call CGapiDisplay::CreateOffscreenDisplay instead of CGapiDisplay::OpenDisplay. This means that your backbuffer will be stored as a Device Context DIB image. You then blit the backbuffer to the display using DC BitBlt instead of CGapiDisplay::Flip.

2. Modify the code inside CGapiSurface (assuming you have a GapiDraw source code license) so that each surface memory is allocated as a DC DIB image instead of just a memory block. You can then change the GetDC function of CGapiSurface so that it then just returns the handle to the DIB image that the surface represents.

All this is fairly simple to implement and could probably be done within an hour or so, assuming you have access to a source code license. The results would be a slightly slower final blit to the screen (since DC is used instead of DirectDraw) but all GetDC operations would be done with zero overhead.

Sincerely
Johan
Johan Sanneblad, M.Sc, Ph.D
GapiDraw Systems Architect
[http://www.gapidraw.com]
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby perrs » Oct 24, 2009 @ 4:17pm

Hi Johan,

Thank you for your reply. Honestly, I'm afraid the source code license is a bit outside of my budget. Is there no way to do this with the binary license?

Per Rasmussen.
perrs
pm Member
 
Posts: 4
Joined: Sep 16, 2009 @ 8:35pm


Postby Johan » Oct 24, 2009 @ 8:40pm

Hi Per,

Can you send me a PM and we'll see how we can resolve this.

Sincerely
Johan
Johan Sanneblad, M.Sc, Ph.D
GapiDraw Systems Architect
[http://www.gapidraw.com]
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum