Bug 5845

Summary: win32 AlphaBlend should be used for ARGB32 destinations, not just RGB24
Product: cairo Reporter: Vladimir Vukicevic <vladimir>
Component: win32 backendAssignee: Owen Taylor <otaylor>
Status: RESOLVED FIXED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: high CC: cworth
Version: 1.1.1   
Hardware: x86 (IA32)   
OS: Windows (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: cairo-win32-alphablend.patch

Description Vladimir Vukicevic 2006-02-09 12:24:26 UTC
The current win32 surface only uses AlphaBlend with RGB24 destination surfaces;
it should be used for ARGB32 destinations as well.
Comment 1 Vladimir Vukicevic 2006-02-09 12:25:49 UTC
Created attachment 4587 [details] [review]
cairo-win32-alphablend.patch

Patch that changes this; the patch also adds cairo_win32_surface_get_dc for
extracting out the HDC from a win32 surface (so that a surface created via
create_similar can have its DC pulled out for non-cairo operations).
Comment 2 Owen Taylor 2006-02-09 12:46:26 UTC
Is the Win32 software implementation noticeably faster than the
libpixman one? Is the libpixman implementation you are using
compiled with or without fbmmx?

(As far as I remember, a surface with destination alpha is always
a memory surface.)

Is there any documentation that AlphaBlend handles destination
alpha? I see nothing about that in the msdn docs.
Comment 3 Vladimir Vukicevic 2006-02-09 13:11:32 UTC
The docs for BLENDFUNCTION
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_3b3m.asp)
imply that it handles it; that is, it explicitly talks about "If the destination
bitmap has an alpha channel, then the blend is as follows [...]".

No MMX compiled; so far the mmx code only works with gcc, but I'll be
integrating the mmx patches for vs at some point soon.  As for whether it's
faster, that I can't tell you; it certainly doesn't feel any slower, and it
seems like we should use it if it's available, especially since it might be
hardware accelerated.
Comment 4 Owen Taylor 2006-02-09 14:03:36 UTC
Hmm. Yeah. Though it's sort of weird to say "if the destination bitmap
has an alpha channel" since the only representation of alpha in GDI
drawing calls *at all* is being a source for AlphaBlend... 

But if it experimentally works, we can use it until someone has problems...

The other point I was making is that this case always involves the 
destination surface being a DIB, so hardware acceleration isn't
a factor. Thus, you are just replacing the cross-platform software
code (fastish, but not super-optmized except for the fbmmx code) with
Microsoft's code.

That's why I was interested if you had any speed comparisons.
Comment 5 Behdad Esfahbod 2006-10-25 14:13:08 UTC
Wasn't this discussed in detail on the mailing list recently?  Close?
Comment 6 Chris Wilson 2008-10-14 01:07:52 UTC
This patch has been folded into the tree and has since evolved...

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.