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
00033 #include "pipe/p_defines.h"
00034 #include "util/u_math.h"
00035 #include "util/u_memory.h"
00036 #include "sp_context.h"
00037 #include "sp_headers.h"
00038 #include "sp_surface.h"
00039 #include "sp_quad.h"
00040 #include "sp_tile_cache.h"
00041
00042
00043
00047 static void
00048 colormask_quad(struct quad_stage *qs, struct quad_header *quad)
00049 {
00050 struct softpipe_context *softpipe = qs->softpipe;
00051 uint cbuf;
00052
00053
00054 for (cbuf = 0; cbuf < softpipe->framebuffer.num_cbufs; cbuf++) {
00055 float dest[4][QUAD_SIZE];
00056 struct softpipe_cached_tile *tile
00057 = sp_get_cached_tile(softpipe,
00058 softpipe->cbuf_cache[cbuf],
00059 quad->input.x0, quad->input.y0);
00060 float (*quadColor)[4] = quad->output.color[cbuf];
00061 uint i, j;
00062
00063
00064 for (j = 0; j < QUAD_SIZE; j++) {
00065 int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
00066 int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
00067 for (i = 0; i < 4; i++) {
00068 dest[i][j] = tile->data.color[y][x][i];
00069 }
00070 }
00071
00072
00073 if (!(softpipe->blend->colormask & PIPE_MASK_R))
00074 COPY_4V(quadColor[0], dest[0]);
00075
00076
00077 if (!(softpipe->blend->colormask & PIPE_MASK_G))
00078 COPY_4V(quadColor[1], dest[1]);
00079
00080
00081 if (!(softpipe->blend->colormask & PIPE_MASK_B))
00082 COPY_4V(quadColor[2], dest[2]);
00083
00084
00085 if (!(softpipe->blend->colormask & PIPE_MASK_A))
00086 COPY_4V(quadColor[3], dest[3]);
00087 }
00088
00089
00090 qs->next->run(qs->next, quad);
00091 }
00092
00093
00094 static void colormask_begin(struct quad_stage *qs)
00095 {
00096 qs->next->begin(qs->next);
00097 }
00098
00099
00100 static void colormask_destroy(struct quad_stage *qs)
00101 {
00102 FREE( qs );
00103 }
00104
00105
00106 struct quad_stage *sp_quad_colormask_stage( struct softpipe_context *softpipe )
00107 {
00108 struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00109
00110 stage->softpipe = softpipe;
00111 stage->begin = colormask_begin;
00112 stage->run = colormask_quad;
00113 stage->destroy = colormask_destroy;
00114
00115 return stage;
00116 }