On Thu Jul 6 14:18:42 2023 +0000, Alexandros Frantzis wrote:
I investigated a bit more, but I wasn't able to find a good (and/or efficient) way to implement all the required operations with GDI (ideas are welcome if someone has more experience with GDI). For example, one operation we will need is: `dst_rgba = src_rgba * alpha`. `NtGdiBitBlt` raster ops don't seem to allow for such color manipulation. `NtGdiAlphaBlend` won't work directly because it blends with the destination using `SRC_OVER`, but in this case we want to disregard the destination and there is no way to adjust the blending function (a workaround would be to first paint the destination region black and then blend with a constant alpha, but that would be inefficient). The closest functionality I could find that would help with this operation is the Color Matrix from GDI+, but GDI+ is not available to the driver. Another variation we will need is `dst_rgb = src_rgb * alpha; dst_a = alpha;`, which presents us with similar difficulties. One approach would be to use `NtGdi` for what we can, and fall back to manual pixel manipulation for other cases. However, given that what we can implement with `NtGdi` boils down to simple memcpy operations, this wouldn't help us avoid the extra LoC and complexity, and would, in fact, increase it more since we would now need to maintain both mechanisms. So, for now, my preference would be to keep the manual implementation, which we know we can enhance with the required operations. If we find a reasonable way to support all we need with `NtGdi` or some other built-in mechanism, I would be happy to switch.
Alright, thanks.