📄 renderbuffer.c
字号:
if (!mask || mask[i]) { GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i]; *dst = val; } }}/********************************************************************** * Functions for buffers of 3 X GLubyte (or GLbyte) values. * Typically color buffers. * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming * alpha values and return 255 for outgoing alpha values. */static void *get_pointer_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLint x, GLint y){ ASSERT(rb->_ActualFormat == GL_RGB8); /* No direct access since this buffer is RGB but caller will be * treating it as if it were RGBA. */ return NULL;}static voidget_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, void *values){ const GLubyte *src = (const GLubyte *) rb->Data + 3 * (y * rb->Width + x); GLubyte *dst = (GLubyte *) values; GLuint i; ASSERT(rb->_ActualFormat == GL_RGB8); ASSERT(rb->DataType == GL_UNSIGNED_BYTE); for (i = 0; i < count; i++) { dst[i * 4 + 0] = src[i * 3 + 0]; dst[i * 4 + 1] = src[i * 3 + 1]; dst[i * 4 + 2] = src[i * 3 + 2]; dst[i * 4 + 3] = 255; }}static voidget_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], void *values){ GLubyte *dst = (GLubyte *) values; GLuint i; ASSERT(rb->_ActualFormat == GL_RGB8); ASSERT(rb->DataType == GL_UNSIGNED_BYTE); for (i = 0; i < count; i++) { const GLubyte *src = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); dst[i * 4 + 0] = src[0]; dst[i * 4 + 1] = src[1]; dst[i * 4 + 2] = src[2]; dst[i * 4 + 3] = 255; }}static voidput_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, const void *values, const GLubyte *mask){ /* note: incoming values are RGB+A! */ const GLubyte *src = (const GLubyte *) values; GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); GLuint i; ASSERT(rb->_ActualFormat == GL_RGB8); ASSERT(rb->DataType == GL_UNSIGNED_BYTE); for (i = 0; i < count; i++) { if (!mask || mask[i]) { dst[i * 3 + 0] = src[i * 4 + 0]; dst[i * 3 + 1] = src[i * 4 + 1]; dst[i * 3 + 2] = src[i * 4 + 2]; } }}static voidput_row_rgb_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, const void *values, const GLubyte *mask){ /* note: incoming values are RGB+A! */ const GLubyte *src = (const GLubyte *) values; GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); GLuint i; ASSERT(rb->_ActualFormat == GL_RGB8); ASSERT(rb->DataType == GL_UNSIGNED_BYTE); for (i = 0; i < count; i++) { if (!mask || mask[i]) { dst[i * 3 + 0] = src[i * 3 + 0]; dst[i * 3 + 1] = src[i * 3 + 1]; dst[i * 3 + 2] = src[i * 3 + 2]; } }}static voidput_mono_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, const void *value, const GLubyte *mask){ /* note: incoming value is RGB+A! */ const GLubyte val0 = ((const GLubyte *) value)[0]; const GLubyte val1 = ((const GLubyte *) value)[1]; const GLubyte val2 = ((const GLubyte *) value)[2]; GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); ASSERT(rb->_ActualFormat == GL_RGB8); ASSERT(rb->DataType == GL_UNSIGNED_BYTE); if (!mask && val0 == val1 && val1 == val2) { /* optimized case */ _mesa_memset(dst, val0, 3 * count); } else { GLuint i; for (i = 0; i < count; i++) { if (!mask || mask[i]) { dst[i * 3 + 0] = val0; dst[i * 3 + 1] = val1; dst[i * 3 + 2] = val2; } } }}static voidput_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], const void *values, const GLubyte *mask){ /* note: incoming values are RGB+A! */ const GLubyte *src = (const GLubyte *) values; GLuint i; ASSERT(rb->_ActualFormat == GL_RGB8); ASSERT(rb->DataType == GL_UNSIGNED_BYTE); for (i = 0; i < count; i++) { if (!mask || mask[i]) { GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); dst[0] = src[i * 4 + 0]; dst[1] = src[i * 4 + 1]; dst[2] = src[i * 4 + 2]; } }}static voidput_mono_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], const void *value, const GLubyte *mask){ /* note: incoming value is RGB+A! */ const GLubyte val0 = ((const GLubyte *) value)[0]; const GLubyte val1 = ((const GLubyte *) value)[1]; const GLubyte val2 = ((const GLubyte *) value)[2]; GLuint i; ASSERT(rb->_ActualFormat == GL_RGB8); ASSERT(rb->DataType == GL_UNSIGNED_BYTE); for (i = 0; i < count; i++) { if (!mask || mask[i]) { GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); dst[0] = val0; dst[1] = val1; dst[2] = val2; } }}/********************************************************************** * Functions for buffers of 4 X GLubyte (or GLbyte) values. * Typically color buffers. */static void *get_pointer_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLint x, GLint y){ if (!rb->Data) return NULL; ASSERT(rb->DataType == GL_UNSIGNED_BYTE); ASSERT(rb->_ActualFormat == GL_RGBA8); return (GLubyte *) rb->Data + 4 * (y * rb->Width + x);}static voidget_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, void *values){ const GLubyte *src = (const GLubyte *) rb->Data + 4 * (y * rb->Width + x); ASSERT(rb->DataType == GL_UNSIGNED_BYTE); ASSERT(rb->_ActualFormat == GL_RGBA8); _mesa_memcpy(values, src, 4 * count * sizeof(GLubyte));}static voidget_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], void *values){ /* treat 4*GLubyte as 1*GLuint */ GLuint *dst = (GLuint *) values; GLuint i; ASSERT(rb->DataType == GL_UNSIGNED_BYTE); ASSERT(rb->_ActualFormat == GL_RGBA8); for (i = 0; i < count; i++) { const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); dst[i] = *src; }}static voidput_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, const void *values, const GLubyte *mask){ /* treat 4*GLubyte as 1*GLuint */ const GLuint *src = (const GLuint *) values; GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x); ASSERT(rb->DataType == GL_UNSIGNED_BYTE); ASSERT(rb->_ActualFormat == GL_RGBA8); if (mask) { GLuint i; for (i = 0; i < count; i++) { if (mask[i]) { dst[i] = src[i]; } } } else { _mesa_memcpy(dst, src, 4 * count * sizeof(GLubyte)); }}static voidput_row_rgb_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, const void *values, const GLubyte *mask){ /* Store RGB values in RGBA buffer */ const GLubyte *src = (const GLubyte *) values; GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->Width + x); GLuint i; ASSERT(rb->DataType == GL_UNSIGNED_BYTE); ASSERT(rb->_ActualFormat == GL_RGBA8); for (i = 0; i < count; i++) { if (!mask || mask[i]) { dst[i * 4 + 0] = src[i * 3 + 0]; dst[i * 4 + 1] = src[i * 3 + 1]; dst[i * 4 + 2] = src[i * 3 + 2]; dst[i * 4 + 3] = 0xff; } }}static voidput_mono_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, const void *value, const GLubyte *mask){ /* treat 4*GLubyte as 1*GLuint */ const GLuint val = *((const GLuint *) value); GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x); ASSERT(rb->DataType == GL_UNSIGNED_BYTE); ASSERT(rb->_ActualFormat == GL_RGBA8); if (!mask && val == 0) { /* common case */ _mesa_bzero(dst, count * 4 * sizeof(GLubyte)); } else { /* general case */ if (mask) { GLuint i; for (i = 0; i < count; i++) { if (mask[i]) { dst[i] = val; } } } else { GLuint i; for (i = 0; i < count; i++) { dst[i] = val; } } }}static voidput_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], const void *values, const GLubyte *mask){ /* treat 4*GLubyte as 1*GLuint */ const GLuint *src = (const GLuint *) values; GLuint i; ASSERT(rb->DataType == GL_UNSIGNED_BYTE); ASSERT(rb->_ActualFormat == GL_RGBA8); for (i = 0; i < count; i++) { if (!mask || mask[i]) { GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); *dst = src[i]; } }}static voidput_mono_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], const void *value, const GLubyte *mask){ /* treat 4*GLubyte as 1*GLuint */ const GLuint val = *((const GLuint *) value); GLuint i; ASSERT(rb->DataType == GL_UNSIGNED_BYTE); ASSERT(rb->_ActualFormat == GL_RGBA8); for (i = 0; i < count; i++) { if (!mask || mask[i]) { GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); *dst = val; } }}/********************************************************************** * Functions for buffers of 4 X GLushort (or GLshort) values. * Typically accum buffer. */static void *get_pointer_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLint x, GLint y){ if (!rb->Data) return NULL; ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); return (GLushort *) rb->Data + 4 * (y * rb->Width + x);}static voidget_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, void *values){ const GLshort *src = (const GLshort *) rb->Data + 4 * (y * rb->Width + x); ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); _mesa_memcpy(values, src, 4 * count * sizeof(GLshort));}static voidget_values_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], void *values){ GLushort *dst = (GLushort *) values; GLuint i; ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); for (i = 0; i < count; i++) { const GLushort *src = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]); dst[i] = *src; }}static voidput_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, const void *values, const GLubyte *mask){ const GLushort *src = (const GLushort *) values; GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x); ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); if (mask) { GLuint i; for (i = 0; i < count; i++) { if (mask[i]) { dst[i * 4 + 0] = src[i * 4 + 0]; dst[i * 4 + 1] = src[i * 4 + 1]; dst[i * 4 + 2] = src[i * 4 + 2]; dst[i * 4 + 3] = src[i * 4 + 3]; } } } else { _mesa_memcpy(dst, src, 4 * count * sizeof(GLushort)); }}static voidput_row_rgb_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, const void *values, const GLubyte *mask){ /* Put RGB values in RGBA buffer */ const GLushort *src = (const GLushort *) values; GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x); ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); if (mask) { GLuint i; for (i = 0; i < count; i++) { if (mask[i]) { dst[i * 4 + 0] = src[i * 3 + 0]; dst[i * 4 + 1] = src[i * 3 + 1]; dst[i * 4 + 2] = src[i * 3 + 2]; dst[i * 4 + 3] = 0xffff; } } } else { _mesa_memcpy(dst, src, 4 * count * sizeof(GLushort)); }}static voidput_mono_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, const void *value, const GLubyte *mask){ const GLushort val0 = ((const GLushort *) value)[0]; const GLushort val1 = ((const GLushort *) value)[1];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -