00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
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
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 }