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?

Fastest interop with GDI?


Fastest interop with GDI?

Postby Narin » Jan 7, 2009 @ 10:18pm

What's the best way to combine GapiDraw and GDI? I have to use GDI to do some things like drawing text.

Right now I'm creating surfaces with the default settings and using GetDC to "ship" my surface to GDI and draw on it, then ReleaseDC when finished. This is pretty slow when drawing onto large surfaces (say 480x480 pixels). All my "final" compositing is done using GapiDraw and GapiDraw owns the final back buffer.

What's really happening when calling GetDC? Do GapiDraw surfaces live in a totally different spot than GDI surfaces? And copying back and forth is always slow?

I've tried telling my surfaces to live in system memory vs. video memory but it doesn't make any difference (and I don't fully understand the difference).
Narin
pm Member
 
Posts: 11
Joined: Nov 21, 2008 @ 10:42am


Postby Johan » Jan 9, 2009 @ 8:38am

Hey,

Do GapiDraw surfaces live in a totally different spot than GDI surfaces? And copying back and forth is always slow?


Yes, this is how it is. Reasons are that:
1. Surfaces might exist in video memory, meaning they will not be GDI compatible.
2. Display or framebuffer on the device might be rotated, meaning that the pitch values will not match X=2 bytes. Meaning surface is not GDI compatible.
3. Surfaces might be created without having a window open, using CreateOffscrenDisplay. This won't work if all surfaces should have a DC.

If you however do not use video memory, and you are only using DirectDraw where frame buffer is not rotated, and you do not rotate the display using GapiDraw, and you always have a main window open, then you could add some simple code to the GapiDraw source code to always create all surfaces as DC compatible DIB's. Will probably take just a few hours. The reasons we did not is just that it's so simple to add for those that need it, and if we added it as standard it would impose usability issues as described above.

Send me your email as a PM and we can continue the discussion from there.

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 Narin » Jan 11, 2009 @ 12:23am

Johan wrote:If you however do not use video memory, and you are only using DirectDraw where frame buffer is not rotated, and you do not rotate the display using GapiDraw, and you always have a main window open, then you could add some simple code to the GapiDraw source code to always create all surfaces as DC compatible DIB's.


Actually all these assumptions are true for me - I'm using a gapi display opened in fullscreen mode, non-rotated, and all my surfaces could be in system memory (makes no difference to me, if there's no perf hit).

Could I just pass the GDI flag always when calling CreateSurface and achieve the same effect without modifying GapiDraw source?

(I tried to send a PM but it don't think it's working right)
Narin
pm Member
 
Posts: 11
Joined: Nov 21, 2008 @ 10:42am


Postby Narin » Jan 11, 2009 @ 4:11am

Oh I just realized a couple things:

It doesn't seem possible to create a GapiSurface with the GDSURFACE_GDI flag..I'm guessing that's why modifying the GapiDraw codebase is the only option for that?

Also, I'm using GapiRGBASurface extensively, and I'll bet there's no way to create such a thing as a DIB?
Narin
pm Member
 
Posts: 11
Joined: Nov 21, 2008 @ 10:42am


Postby Johan » Jan 11, 2009 @ 7:18pm

Narin wrote:It doesn't seem possible to create a GapiSurface with the GDSURFACE_GDI flag..I'm guessing that's why modifying the GapiDraw codebase is the only option for that?


This is correct. It's a small change however, in CreateSurface you just replace the malloc to allocate new surface memory with DIB allocation code.

Narin wrote:Also, I'm using GapiRGBASurface extensively, and I'll bet there's no way to create such a thing as a DIB?


No, but as above you can modify the code very easily to achieve 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

cron