ff26856679c41840adfa149a7a500dfdd164afac
2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Templates for the span/pixel-array write/read functions called via
28 * the gl_renderbuffer's GetRow, GetValues, PutRow, and PutValues.
30 * Define the following macros before including this file:
31 * NAME(BASE) to generate the function name (i.e. add prefix or suffix)
32 * RB_TYPE the renderbuffer DataType
33 * SPAN_VARS to declare any local variables
34 * INIT_PIXEL_PTR(P, X, Y) to initialize a pointer to a pixel
35 * INC_PIXEL_PTR(P) to increment a pixel pointer by one pixel
36 * STORE_PIXEL(DST, X, Y, VALUE) to store pixel values in buffer
37 * FETCH_PIXEL(DST, SRC) to fetch pixel values from buffer
39 * Note that in the STORE_PIXEL macros, we also pass in the (X,Y) coordinates
40 * for the pixels to be stored. This is useful when dithering and probably
44 #include "main/macros.h"
47 #if !defined(RB_COMPONENTS)
48 #define RB_COMPONENTS 4
53 NAME(get_row
)( struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
54 GLuint count
, GLint x
, GLint y
, void *values
)
59 RB_TYPE (*dest
)[RB_COMPONENTS
] = (RB_TYPE (*)[RB_COMPONENTS
]) values
;
61 INIT_PIXEL_PTR(pixel
, x
, y
);
62 for (i
= 0; i
< count
; i
++) {
63 FETCH_PIXEL(dest
[i
], pixel
);
72 NAME(get_values
)( struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
73 GLuint count
, const GLint x
[], const GLint y
[], void *values
)
78 RB_TYPE (*dest
)[RB_COMPONENTS
] = (RB_TYPE (*)[RB_COMPONENTS
]) values
;
80 for (i
= 0; i
< count
; i
++) {
81 INIT_PIXEL_PTR(pixel
, x
[i
], y
[i
]);
82 FETCH_PIXEL(dest
[i
], pixel
);
90 NAME(put_row
)( struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
91 GLuint count
, GLint x
, GLint y
,
92 const void *values
, const GLubyte mask
[] )
97 const RB_TYPE (*src
)[RB_COMPONENTS
] = (const RB_TYPE (*)[RB_COMPONENTS
]) values
;
99 INIT_PIXEL_PTR(pixel
, x
, y
);
101 for (i
= 0; i
< count
; i
++) {
103 STORE_PIXEL(pixel
, x
+ i
, y
, src
[i
]);
105 INC_PIXEL_PTR(pixel
);
109 for (i
= 0; i
< count
; i
++) {
110 STORE_PIXEL(pixel
, x
+ i
, y
, src
[i
]);
111 INC_PIXEL_PTR(pixel
);
120 NAME(put_row_rgb
)( struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
121 GLuint count
, GLint x
, GLint y
,
122 const void *values
, const GLubyte mask
[] )
127 const RB_TYPE (*src
)[3] = (const RB_TYPE (*)[3]) values
;
129 INIT_PIXEL_PTR(pixel
, x
, y
);
130 for (i
= 0; i
< count
; i
++) {
131 if (!mask
|| mask
[i
]) {
132 #ifdef STORE_PIXEL_RGB
133 STORE_PIXEL_RGB(pixel
, x
+ i
, y
, src
[i
]);
135 STORE_PIXEL(pixel
, x
+ i
, y
, src
[i
]);
138 INC_PIXEL_PTR(pixel
);
146 NAME(put_values
)( struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
147 GLuint count
, const GLint x
[], const GLint y
[],
148 const void *values
, const GLubyte mask
[] )
153 const RB_TYPE (*src
)[RB_COMPONENTS
] = (const RB_TYPE (*)[RB_COMPONENTS
]) values
;
156 for (i
= 0; i
< count
; i
++) {
158 INIT_PIXEL_PTR(pixel
, x
[i
], y
[i
]);
159 STORE_PIXEL(pixel
, x
[i
], y
[i
], src
[i
]);
171 #undef INIT_PIXEL_PTR
174 #undef STORE_PIXEL_RGB