summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-09-29 04:27:47 +0000
committerBrian Paul <[email protected]>2005-09-29 04:27:47 +0000
commit3fd819aef8139761ce86cb8d763de83a11c81b33 (patch)
tree4fbf344dce2a63749c4cd5c6812c7e8f81edfc53 /src
parent8d0edf015d82a705796389890f6fe9b32e19414c (diff)
added _swrast_put_row()
Diffstat (limited to 'src')
-rw-r--r--src/mesa/swrast/s_span.c34
-rw-r--r--src/mesa/swrast/s_span.h5
2 files changed, 39 insertions, 0 deletions
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 38a7f95f273..a9745063d90 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1474,3 +1474,37 @@ _swrast_get_values(GLcontext *ctx, struct gl_renderbuffer *rb,
(GLubyte *) values + inStart * valueSize);
}
}
+
+
+/**
+ * Wrapper for gl_renderbuffer::PutRow() which does clipping.
+ */
+void
+_swrast_put_row(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ const GLvoid *values, GLuint valueSize)
+{
+ GLint skip = 0;
+
+ if (y < 0 || y >= rb->Height)
+ return; /* above or below */
+
+ if (x + (GLint) count <= 0 || x >= rb->Width)
+ return; /* entirely left or right */
+
+ if (x + count > rb->Width) {
+ /* right clip */
+ GLint clip = x + count - rb->Width;
+ count -= clip;
+ }
+
+ if (x < 0) {
+ /* left clip */
+ skip = -x;
+ x = 0;
+ count -= skip;
+ }
+
+ rb->PutRow(ctx, rb, count, x, y,
+ (const GLubyte *) values + skip * valueSize, NULL);
+}
diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h
index 1bba5aa53b3..0c853746b82 100644
--- a/src/mesa/swrast/s_span.h
+++ b/src/mesa/swrast/s_span.h
@@ -72,4 +72,9 @@ _swrast_get_values(GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint count, const GLint x[], const GLint y[],
void *values, GLuint valueSize);
+extern void
+_swrast_put_row(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ const GLvoid *values, GLuint valueSize);
+
#endif