Clean up warnings in r300 code by making some symbols static, adding prototypes
[mesa.git] / src / mesa / drivers / x11 / xm_buffer.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.3
4 *
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 */
24
25
26 #include "glxheader.h"
27 #include "GL/xmesa.h"
28 #include "xmesaP.h"
29 #include "imports.h"
30 #include "renderbuffer.h"
31
32
33 static void
34 xmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
35 {
36 /* XXX this routine should really delete the attached ximage, etc. */
37 }
38
39
40 /**
41 * Reallocate renderbuffer storage.
42 * This is called when the window's resized. It'll get called once for
43 * the front color renderbuffer and again for the back color renderbuffer.
44 */
45 static GLboolean
46 xmesa_alloc_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
47 GLenum internalFormat, GLuint width, GLuint height)
48 {
49 struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
50
51 if (xrb->ximage) {
52 /* Needed by PIXELADDR1 macro */
53 xrb->width1 = xrb->ximage->bytes_per_line;
54 xrb->origin1 = (GLubyte *) xrb->ximage->data + xrb->width1 * (height - 1);
55
56 /* Needed by PIXELADDR2 macro */
57 xrb->width2 = xrb->ximage->bytes_per_line / 2;
58 xrb->origin2 = (GLushort *) xrb->ximage->data + xrb->width2 * (height - 1);
59
60 /* Needed by PIXELADDR3 macro */
61 xrb->width3 = xrb->ximage->bytes_per_line;
62 xrb->origin3 = (GLubyte *) xrb->ximage->data + xrb->width3 * (height - 1);
63
64 /* Needed by PIXELADDR4 macro */
65 xrb->width4 = xrb->ximage->width;
66 xrb->origin4 = (GLuint *) xrb->ximage->data + xrb->width4 * (height - 1);
67 }
68 else {
69 assert(xrb->pixmap);
70 }
71
72 /* for the FLIP macro: */
73 xrb->bottom = height - 1;
74
75 rb->Width = width;
76 rb->Height = height;
77 rb->InternalFormat = internalFormat;
78
79 return GL_TRUE;
80 }
81
82
83 struct xmesa_renderbuffer *
84 xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode)
85 {
86 struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer);
87 if (xrb) {
88 GLuint name = 0;
89 _mesa_init_renderbuffer(&xrb->Base, name);
90
91 xrb->Base.Delete = xmesa_delete_renderbuffer;
92 xrb->Base.AllocStorage = xmesa_alloc_storage;
93
94 if (rgbMode) {
95 xrb->Base.InternalFormat = GL_RGBA;
96 xrb->Base._BaseFormat = GL_RGBA;
97 xrb->Base.DataType = GL_UNSIGNED_BYTE;
98 }
99 else {
100 xrb->Base.InternalFormat = GL_COLOR_INDEX;
101 xrb->Base._BaseFormat = GL_COLOR_INDEX;
102 xrb->Base.DataType = GL_UNSIGNED_INT;
103 }
104 xrb->Base.ComponentSizes[0] = 0; /* XXX fix? */
105 }
106 return xrb;
107 }
108
109
110
111