aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-09-30 03:00:03 +0000
committerBrian Paul <[email protected]>2005-09-30 03:00:03 +0000
commitf493a04be0e004bb07f84b2e28124ed8cb6a9b38 (patch)
tree004499d78bfe8bd7222c23f93b2e7d73b8899767 /src/mesa
parent1ad6e0809069833f17578a9751ac8408362d410c (diff)
added _swrast_get_row()
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/swrast/s_span.c33
-rw-r--r--src/mesa/swrast/s_span.h5
2 files changed, 38 insertions, 0 deletions
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index a9745063d90..b6d4098f247 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1508,3 +1508,36 @@ _swrast_put_row(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutRow(ctx, rb, count, x, y,
(const GLubyte *) values + skip * valueSize, NULL);
}
+
+
+/**
+ * Wrapper for gl_renderbuffer::GetRow() which does clipping.
+ */
+void
+_swrast_get_row(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ 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->GetRow(ctx, rb, count, x, y, (GLubyte *) values + skip * valueSize);
+}
diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h
index 0c853746b82..40a57e1ae53 100644
--- a/src/mesa/swrast/s_span.h
+++ b/src/mesa/swrast/s_span.h
@@ -77,4 +77,9 @@ _swrast_put_row(GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint count, GLint x, GLint y,
const GLvoid *values, GLuint valueSize);
+extern void
+_swrast_get_row(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ GLvoid *values, GLuint valueSize);
+
#endif