17117f1b4Smrg/*
27117f1b4Smrg * Mesa 3-D graphics library
37117f1b4Smrg *
47117f1b4Smrg * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
57117f1b4Smrg *
67117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a
77117f1b4Smrg * copy of this software and associated documentation files (the "Software"),
87117f1b4Smrg * to deal in the Software without restriction, including without limitation
97117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
107117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the
117117f1b4Smrg * Software is furnished to do so, subject to the following conditions:
127117f1b4Smrg *
137117f1b4Smrg * The above copyright notice and this permission notice shall be included
147117f1b4Smrg * in all copies or substantial portions of the Software.
157117f1b4Smrg *
167117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
177117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
237117f1b4Smrg */
247117f1b4Smrg
257117f1b4Smrg
267117f1b4Smrg#ifndef FRAMEBUFFER_H
277117f1b4Smrg#define FRAMEBUFFER_H
287117f1b4Smrg
2901e04c3fSmrg#include "mtypes.h"
303464ebd5Sriastradh
313464ebd5Sriastradhstruct gl_config;
323464ebd5Sriastradhstruct gl_context;
33af69d88dSmrgstruct gl_renderbuffer;
347117f1b4Smrg
357117f1b4Smrgextern struct gl_framebuffer *
363464ebd5Sriastradh_mesa_new_framebuffer(struct gl_context *ctx, GLuint name);
377117f1b4Smrg
387117f1b4Smrgextern void
39cdc920a0Smrg_mesa_initialize_window_framebuffer(struct gl_framebuffer *fb,
403464ebd5Sriastradh				     const struct gl_config *visual);
41cdc920a0Smrg
42cdc920a0Smrgextern void
43cdc920a0Smrg_mesa_initialize_user_framebuffer(struct gl_framebuffer *fb, GLuint name);
447117f1b4Smrg
457117f1b4Smrgextern void
467117f1b4Smrg_mesa_destroy_framebuffer(struct gl_framebuffer *buffer);
477117f1b4Smrg
487117f1b4Smrgextern void
497117f1b4Smrg_mesa_free_framebuffer_data(struct gl_framebuffer *buffer);
507117f1b4Smrg
517117f1b4Smrgextern void
52af69d88dSmrg_mesa_reference_framebuffer_(struct gl_framebuffer **ptr,
53af69d88dSmrg                             struct gl_framebuffer *fb);
54af69d88dSmrg
55af69d88dSmrgstatic inline void
567117f1b4Smrg_mesa_reference_framebuffer(struct gl_framebuffer **ptr,
57af69d88dSmrg                            struct gl_framebuffer *fb)
58af69d88dSmrg{
59af69d88dSmrg   if (*ptr != fb)
60af69d88dSmrg      _mesa_reference_framebuffer_(ptr, fb);
61af69d88dSmrg}
627117f1b4Smrg
637117f1b4Smrgextern void
643464ebd5Sriastradh_mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
657117f1b4Smrg                         GLuint width, GLuint height);
667117f1b4Smrg
67c1f859d4Smrg
68c1f859d4Smrgextern void
693464ebd5Sriastradh_mesa_resizebuffers( struct gl_context *ctx );
70c1f859d4Smrg
71af69d88dSmrgextern void
7201e04c3fSmrg_mesa_intersect_scissor_bounding_box(const struct gl_context *ctx,
7301e04c3fSmrg                                     unsigned idx, int *bbox);
7401e04c3fSmrg
7501e04c3fSmrgstatic inline GLuint
7601e04c3fSmrg_mesa_geometric_width(const struct gl_framebuffer *buffer)
7701e04c3fSmrg{
7801e04c3fSmrg   return buffer->_HasAttachments ?
7901e04c3fSmrg      buffer->Width : buffer->DefaultGeometry.Width;
8001e04c3fSmrg}
8101e04c3fSmrg
8201e04c3fSmrgstatic inline GLuint
8301e04c3fSmrg_mesa_geometric_height(const struct gl_framebuffer *buffer)
8401e04c3fSmrg{
8501e04c3fSmrg   return buffer->_HasAttachments ?
8601e04c3fSmrg      buffer->Height : buffer->DefaultGeometry.Height;
8701e04c3fSmrg}
8801e04c3fSmrg
8901e04c3fSmrgstatic inline GLuint
9001e04c3fSmrg_mesa_geometric_samples(const struct gl_framebuffer *buffer)
9101e04c3fSmrg{
9201e04c3fSmrg   return buffer->_HasAttachments ?
9301e04c3fSmrg      buffer->Visual.samples :
9401e04c3fSmrg      buffer->DefaultGeometry._NumSamples;
9501e04c3fSmrg}
9601e04c3fSmrg
9701e04c3fSmrgstatic inline GLuint
9801e04c3fSmrg_mesa_geometric_layers(const struct gl_framebuffer *buffer)
9901e04c3fSmrg{
10001e04c3fSmrg   return buffer->_HasAttachments ?
10101e04c3fSmrg      buffer->MaxNumLayers : buffer->DefaultGeometry.Layers;
10201e04c3fSmrg}
103c1f859d4Smrg
1047117f1b4Smrgextern void
10501e04c3fSmrg_mesa_update_draw_buffer_bounds(struct gl_context *ctx,
10601e04c3fSmrg                                struct gl_framebuffer *drawFb);
1077117f1b4Smrg
1087117f1b4Smrgextern void
1093464ebd5Sriastradh_mesa_update_framebuffer_visual(struct gl_context *ctx,
1103464ebd5Sriastradh				struct gl_framebuffer *fb);
1117117f1b4Smrg
1127117f1b4Smrgextern void
11301e04c3fSmrg_mesa_update_framebuffer(struct gl_context *ctx,
11401e04c3fSmrg                         struct gl_framebuffer *readFb,
11501e04c3fSmrg                         struct gl_framebuffer *drawFb);
1167117f1b4Smrg
1177117f1b4Smrgextern GLboolean
1183464ebd5Sriastradh_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format);
1197117f1b4Smrg
1207117f1b4Smrgextern GLboolean
1213464ebd5Sriastradh_mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format);
1227117f1b4Smrg
1234a49301eSmrgextern GLenum
12401e04c3fSmrg_mesa_get_color_read_type(struct gl_context *ctx,
12501e04c3fSmrg                          struct gl_framebuffer *fb,
12601e04c3fSmrg                          const char *caller);
1274a49301eSmrg
1284a49301eSmrgextern GLenum
12901e04c3fSmrg_mesa_get_color_read_format(struct gl_context *ctx,
13001e04c3fSmrg                            struct gl_framebuffer *fb,
13101e04c3fSmrg                            const char *caller);
1323464ebd5Sriastradh
133af69d88dSmrgextern struct gl_renderbuffer *
134af69d88dSmrg_mesa_get_read_renderbuffer_for_format(const struct gl_context *ctx,
135af69d88dSmrg                                       GLenum format);
136af69d88dSmrg
1373464ebd5Sriastradhextern void
1383464ebd5Sriastradh_mesa_print_framebuffer(const struct gl_framebuffer *fb);
1397117f1b4Smrg
14001e04c3fSmrgextern bool
14101e04c3fSmrg_mesa_is_front_buffer_reading(const struct gl_framebuffer *fb);
14201e04c3fSmrg
14301e04c3fSmrgextern bool
14401e04c3fSmrg_mesa_is_front_buffer_drawing(const struct gl_framebuffer *fb);
14501e04c3fSmrg
14601e04c3fSmrgextern bool
14701e04c3fSmrg_mesa_is_multisample_enabled(const struct gl_context *ctx);
14801e04c3fSmrg
14901e04c3fSmrgextern bool
15001e04c3fSmrg_mesa_is_alpha_test_enabled(const struct gl_context *ctx);
15101e04c3fSmrg
15201e04c3fSmrgextern bool
15301e04c3fSmrg_mesa_is_alpha_to_coverage_enabled(const struct gl_context *ctx);
15401e04c3fSmrg
1557117f1b4Smrg#endif /* FRAMEBUFFER_H */
156