https://git.reactos.org/?p=reactos.git;a=commitdiff;h=08f228577aed4a7601de2d...
commit 08f228577aed4a7601de2de29a18bc054d9f6cf7 Author: Jérôme Gardou jerome.gardou@reactos.org AuthorDate: Wed Feb 5 13:08:04 2020 +0100 Commit: Jérôme Gardou zefklop@users.noreply.github.com CommitDate: Fri Feb 14 08:55:45 2020 +0100
[OPENGL32] Fix RGB <-> BGR mismatch
Fix CORE-16221 --- dll/opengl/opengl32/swimpl.c | 75 +++++++++++--------------------------------- 1 file changed, 18 insertions(+), 57 deletions(-)
diff --git a/dll/opengl/opengl32/swimpl.c b/dll/opengl/opengl32/swimpl.c index 70b4ca7abb0..7f2808d1b0e 100644 --- a/dll/opengl/opengl32/swimpl.c +++ b/dll/opengl/opengl32/swimpl.c @@ -616,63 +616,6 @@ static inline ULONG GET_PIXEL_32(ULONG* Buffer) return *Buffer; }
-static inline COLORREF MAKE_COLORREF_8(const struct pixel_format *format, BYTE Color) -{ - BYTE R,G,B; - - if (format->iPixelType == PFD_TYPE_COLORINDEX) - return PALETTEINDEX(Color); - - R = (Color & 0x7) << 5; - G = (Color & 0x38) << 2; - B = Color & 0xC; - - return RGB(R, G, B); -} - -static inline COLORREF MAKE_COLORREF_16(const struct pixel_format *format, USHORT Color) -{ - BYTE R,G,B; - - if (format->iPixelType == PFD_TYPE_COLORINDEX) - return PALETTEINDEX(Color); - - R = (Color & 0x7) << 5; - G = (Color & 0x38) << 2; - B = Color & 0xC; - - return RGB(R, G, B); -} - -static inline COLORREF MAKE_COLORREF_24(const struct pixel_format *format, ULONG Color) -{ - BYTE R,G,B; - - if (format->iPixelType == PFD_TYPE_COLORINDEX) - return PALETTEINDEX(Color); - - R = (Color & 0xFF0000) >> 16; - G = (Color & 0x00FF00) >> 8; - B = Color & 0xFF; - - return RGB(R, G, B); -} - -static inline COLORREF MAKE_COLORREF_32(const struct pixel_format *format, ULONG Color) -{ - BYTE R,G,B; - - if (format->iPixelType == PFD_TYPE_COLORINDEX) - return PALETTEINDEX(Color); - - R = (Color & 0xFF0000) >> 16; - G = (Color & 0x00FF00) >> 8; - B = Color & 0xFF; - - return RGB(R, G, B); -} - - static inline BYTE PACK_COLOR_8(GLubyte r, GLubyte g, GLubyte b) { return (r & 0x7) | ((g & 0x7) << 3) | ((b & 0x3) << 6); @@ -769,6 +712,24 @@ static inline void UNPACK_COLORREF_32(COLORREF Color, GLubyte* r, GLubyte* g, GL *b = GetBValue(Color); }
+#define MAKE_COLORREF(__bpp, __type) \ +static inline COLORREF MAKE_COLORREF_##__bpp(const struct pixel_format *format, __type Color) \ +{ \ + GLubyte r,g,b; \ + \ + if (format->iPixelType == PFD_TYPE_COLORINDEX) \ + return PALETTEINDEX(Color); \ + \ + UNPACK_COLOR_##__bpp(Color, &r, &g, &b); \ + \ + return PACK_COLORREF_##__bpp(r, g, b); \ +} +MAKE_COLORREF(8, BYTE) +MAKE_COLORREF(16, USHORT) +MAKE_COLORREF(24, ULONG) +MAKE_COLORREF(32, ULONG) +#undef MAKE_COLORREF + /* * Set the color index used to clear the color buffer. */