Vincent Povirk madewokherd@gmail.com wrote:
I'm still primarily concerned with getting all of the features in place and behaving correctly first. Performance isn't a concern for me, but if someone points out a real app where it is an issue then I may be more interested.
I have an application which generates the final image using 1 bpp TIFF as a background, placing some additional pieces here and there from different sources with different color formats and scaling transforms. Under Wine generating the final image takes tens of seconds while with native gdiplus it's almost instant.
I agree that image drawing is far enough along that we can start to optimize it, and I'm not surprised that the performance is bad. I imagine that convert_pixels is very slow in most cases, and optimized codepaths for the common cases could lead to some general improvement (even those cases that are treated specially have not been profiled, so they may not be ideal). The fact that alpha_blend_pixels works using GdipBitmapGetPixel/GdipBitmapSetPixel is very bad, and will hurt performance of any drawing operation on a bitmap.
When drawing to an HDC (or a Bitmap with premultiplied alpha), the fact that we convert from the bitmap format to non-premultiplied alpha, then convert back to premultiplied alpha in alpha_blend_pixels, is probably not good. In cases where we have no ImageAttributes object, we may be able to use premultiplied alpha for the whole process.
I suspect that generating an intermediate RGBA image in the process of drawing should be avoided when source or destination bitmaps have no alpha. Also the way how gdiplus currently scales source is pretty not optimal, using GDI instead is way faster and produces similar results.