st_cb_blit.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  * 
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  * 
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  * 
00026  **************************************************************************/
00027 
00028  /*
00029   * Authors:
00030   *   Brian Paul
00031   */
00032 
00033 #include "main/imports.h"
00034 #include "main/image.h"
00035 #include "main/macros.h"
00036 #include "main/texformat.h"
00037 #include "shader/program.h"
00038 #include "shader/prog_parameter.h"
00039 #include "shader/prog_print.h"
00040 
00041 #include "st_context.h"
00042 #include "st_program.h"
00043 #include "st_cb_blit.h"
00044 #include "st_cb_fbo.h"
00045 
00046 #include "util/u_blit.h"
00047 
00048 #include "cso_cache/cso_context.h"
00049 
00050 
00051 void
00052 st_init_blit(struct st_context *st)
00053 {
00054    st->blit = util_create_blit(st->pipe, st->cso_context);
00055 }
00056 
00057 
00058 void
00059 st_destroy_blit(struct st_context *st)
00060 {
00061    util_destroy_blit(st->blit);
00062    st->blit = NULL;
00063 }
00064 
00065 
00066 static void
00067 st_BlitFramebuffer(GLcontext *ctx,
00068                    GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
00069                    GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
00070                    GLbitfield mask, GLenum filter)
00071 {
00072    struct st_context *st = ctx->st;
00073 
00074    const uint pFilter = ((filter == GL_NEAREST)
00075                          ? PIPE_TEX_MIPFILTER_NEAREST
00076                          : PIPE_TEX_MIPFILTER_LINEAR);
00077 
00078    if (mask & GL_COLOR_BUFFER_BIT) {
00079       struct st_renderbuffer *srcRb = 
00080          st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
00081       struct st_renderbuffer *dstRb = 
00082          st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]);
00083       struct pipe_surface *srcSurf = srcRb->surface;
00084       struct pipe_surface *dstSurf = dstRb->surface;
00085 
00086       if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
00087          /* invert Y */
00088          srcY0 = srcRb->Base.Height - srcY0;
00089          srcY1 = srcRb->Base.Height - srcY1;
00090 
00091          dstY0 = dstRb->Base.Height - dstY0;
00092          dstY1 = dstRb->Base.Height - dstY1;
00093       }
00094 
00095       util_blit_pixels(st->blit,
00096                        srcSurf, srcX0, srcY0, srcX1, srcY1,
00097                        dstSurf, dstX0, dstY0, dstX1, dstY1,
00098                        0.0, pFilter);
00099 
00100    }
00101 }
00102 
00103 
00104 
00105 void
00106 st_init_blit_functions(struct dd_function_table *functions)
00107 {
00108 #if FEATURE_EXT_framebuffer_blit
00109    functions->BlitFramebuffer = st_BlitFramebuffer;
00110 #endif
00111 }

Generated on Tue Sep 29 06:25:18 2009 for Gallium3D by  doxygen 1.5.4