瀏覽代碼

added _mesa_clip_pixelrect()

tags/mesa_3_3
Brian Paul 25 年之前
父節點
當前提交
4e176ff358
共有 2 個檔案被更改,包括 53 行新增2 行删除
  1. 45
    1
      src/mesa/main/drawpix.c
  2. 8
    1
      src/mesa/main/drawpix.h

+ 45
- 1
src/mesa/main/drawpix.c 查看文件

@@ -1,4 +1,4 @@
/* $Id: drawpix.c,v 1.7 1999/11/18 15:44:37 brianp Exp $ */
/* $Id: drawpix.c,v 1.8 1999/11/22 22:21:38 brianp Exp $ */

/*
* Mesa 3-D graphics library
@@ -44,6 +44,50 @@



/*
* Given the dest position, size and skipPixels and skipRows values
* for a glDrawPixels command, perform clipping of the image bounds
* so the result lies withing the context's buffer bounds.
* Return: GL_TRUE if image is ready for drawing
* GL_FALSE if image was completely clipped away (draw nothing)
*/
GLboolean
_mesa_clip_pixelrect(const GLcontext *ctx,
GLint *destX, GLint *destY,
GLsizei *width, GLsizei *height,
GLint *skipPixels, GLint *skipRows)
{
/* left clipping */
if (*destX < ctx->Buffer->Xmin) {
*skipPixels += (ctx->Buffer->Xmin - *destX);
*width -= (ctx->Buffer->Xmin - *destX);
*destX = ctx->Buffer->Xmin;
}
/* right clipping */
if (*destX + *width > ctx->Buffer->Xmax)
*width -= (*destX + *width - ctx->Buffer->Xmax - 1);

if (*width <= 0)
return GL_FALSE;

/* bottom clipping */
if (*destY < ctx->Buffer->Ymin) {
*skipRows += (ctx->Buffer->Ymin - *destY);
*height -= (ctx->Buffer->Ymin - *destY);
*destY = ctx->Buffer->Ymin;
}
/* top clipping */
if (*destY + *height > ctx->Buffer->Ymax)
*height -= (*destY + *height - ctx->Buffer->Ymax - 1);

if (*height <= 0)
return GL_TRUE;

return GL_TRUE;
}



/*
* Try to do a fast and simple RGB(a) glDrawPixels.
* Return: GL_TRUE if success, GL_FALSE if slow path must be used instead

+ 8
- 1
src/mesa/main/drawpix.h 查看文件

@@ -1,4 +1,4 @@
/* $Id: drawpix.h,v 1.2 1999/11/11 01:22:26 brianp Exp $ */
/* $Id: drawpix.h,v 1.3 1999/11/22 22:21:38 brianp Exp $ */

/*
* Mesa 3-D graphics library
@@ -32,6 +32,13 @@
#include "types.h"


extern GLboolean
_mesa_clip_pixelrect(const GLcontext *ctx,
GLint *destX, GLint *destY,
GLsizei *width, GLsizei *height,
GLint *skipPixels, GLint *skipRows);


extern void
_mesa_DrawPixels( GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid *pixels );

Loading…
取消
儲存