|
|
Definition at line 273 of file s_accum.c.
Referenced by _swrast_Accum().
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
struct gl_renderbuffer *rb
= ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
const GLboolean directAccess = (rb->GetPointer(ctx, rb, 0, 0) != NULL);
assert(rb);
if (!ctx->ReadBuffer->_ColorReadBuffer) {
return;
}
if (swrast->_IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0)
swrast->_IntegerAccumScaler = value;
if (swrast->_IntegerAccumMode && value != swrast->_IntegerAccumScaler)
rescale_accum(ctx);
if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
const GLfloat scale = value * ACCUM_SCALE16 / CHAN_MAXF;
GLshort accumRow[4 * MAX_WIDTH];
GLchan rgba[MAX_WIDTH][4];
GLint i;
for (i = 0; i < height; i++) {
GLshort *acc;
if (directAccess) {
acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
}
else {
rb->GetRow(ctx, rb, width, xpos, ypos + i, accumRow);
acc = accumRow;
}
_swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer, width,
xpos, ypos + i, CHAN_TYPE, rgba);
if (swrast->_IntegerAccumMode) {
GLint j;
for (j = 0; j < width; j++) {
acc[j * 4 + 0] += rgba[j][RCOMP];
acc[j * 4 + 1] += rgba[j][GCOMP];
acc[j * 4 + 2] += rgba[j][BCOMP];
acc[j * 4 + 3] += rgba[j][ACOMP];
}
}
else {
GLint j;
for (j = 0; j < width; j++) {
acc[j * 4 + 0] += (GLshort) ((GLfloat) rgba[j][RCOMP] * scale);
acc[j * 4 + 1] += (GLshort) ((GLfloat) rgba[j][GCOMP] * scale);
acc[j * 4 + 2] += (GLshort) ((GLfloat) rgba[j][BCOMP] * scale);
acc[j * 4 + 3] += (GLshort) ((GLfloat) rgba[j][ACOMP] * scale);
}
}
if (!directAccess) {
rb->PutRow(ctx, rb, width, xpos, ypos + i, accumRow, NULL);
}
}
}
else {
}
}
|