2 * DIB driver primitives.
4 * Copyright 2011 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "gdi_private.h"
24 static inline DWORD *get_pixel_ptr_32(const dib_info *dib, int x, int y)
26 return (DWORD *)((BYTE*)dib->bits + y * dib->stride + x * 4);
29 static inline void do_rop_32(DWORD *ptr, DWORD and, DWORD xor)
31 *ptr = (*ptr & and) ^ xor;
34 static void solid_rects_32(const dib_info *dib, int num, RECT *rc, DWORD and, DWORD xor)
39 for(i = 0; i < num; i++, rc++)
41 start = ptr = get_pixel_ptr_32(dib, rc->left, rc->top);
42 for(y = rc->top; y < rc->bottom; y++, start += dib->stride / 4)
43 for(x = rc->left, ptr = start; x < rc->right; x++)
44 do_rop_32(ptr++, and, xor);
48 static void solid_rects_null(const dib_info *dib, int num, RECT *rc, DWORD and, DWORD xor)
53 static DWORD colorref_to_pixel_888(const dib_info *dib, COLORREF color)
55 return ( ((color >> 16) & 0xff) | (color & 0xff00) | ((color << 16) & 0xff0000) );
58 static inline DWORD put_field(DWORD field, int shift, int len)
60 shift = shift - (8 - len);
62 field &= (((1 << len) - 1) << (8 - len));
70 static DWORD colorref_to_pixel_masks(const dib_info *dib, COLORREF colour)
74 r = GetRValue(colour);
75 g = GetGValue(colour);
76 b = GetBValue(colour);
78 return put_field(r, dib->red_shift, dib->red_len) |
79 put_field(g, dib->green_shift, dib->green_len) |
80 put_field(b, dib->blue_shift, dib->blue_len);
83 static DWORD colorref_to_pixel_null(const dib_info *dib, COLORREF color)
88 const primitive_funcs funcs_8888 =
94 const primitive_funcs funcs_32 =
97 colorref_to_pixel_masks
100 const primitive_funcs funcs_null =
103 colorref_to_pixel_null