[cairo] DDB vs. DIB vs. Image: the tower of similarity
Owen Taylor
otaylor at redhat.com
Fri Jan 21 12:36:47 PST 2005
When the user creates a Win32 surface, the target of the surface is
under their control. It could be a window, a Device-Dependent Bitmap,
or a Device-Independent-Bitmap. Our ability to render to these targets
varies ... for a window or a DDB, we must go through GDI. For a DIB,
we can get the bits of the DIB directly and create a pixman_image_t
corresponding to the DIB.
For cairo_surface_create_similar(), on the other hand, we have the
choice of what we create. We could (if the original target is a
window or DDB) create a DDB. We could create a DIB/pixman_image_t
pair. Or we could create a pixman_image_t without an accompanying
DIB. (The advantage of avoiding the DIB is that we don't have to
create two windows resources... a DIB and a Device Context.)
The appropriate choice is probably:
For a Window/DDB create a DIB
For a DIB, create an image
For a image, create an image
For most types of drawing, a DIB for a destination has no advantage
over an image for a destination. Assuming that we libpixman is well
optimized, using GDI has no advantage for software rendering. Except
for text. The details of text rendering are still not clear in my
mind, but it's conceivable that with surface=DIB, format=RGB24, we
want to create another DIB rather than an image so we can render text
to it directly.
Using a DIB as a source does have an advantage... given a DIB as a
source, we can simply draw to another drawable using BitBlt(). With a
raw buffer of bits, we can, in some cases, use SetDIBits(), but there
are a considerable number of restrictions on its usage. This is why
create_similar() on a DIB or Window should give a DIB.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050121/2425c847/attachment.pgp
More information about the cairo
mailing list