Changeset 3598 for trunk/src/opengl/mesa/blend.c
- Timestamp:
- May 23, 2000, 10:41:28 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/blend.c
r2962 r3598 1 /* $Id: blend.c,v 1. 2 2000-03-01 18:49:23jeroen Exp $ */1 /* $Id: blend.c,v 1.3 2000-05-23 20:40:24 jeroen Exp $ */ 2 2 3 3 /* 4 4 * Mesa 3-D graphics library 5 * Version: 3. 15 * Version: 3.3 6 6 * 7 7 * Copyright (C) 1999 Brian Paul All Rights Reserved. … … 30 30 #include "all.h" 31 31 #else 32 #ifndef XFree86Server 33 #include <stdio.h> 34 #include <assert.h> 35 #include <stdlib.h> 36 #else 37 #include "GL/xf86glx.h" 38 #endif 32 #include "glheader.h" 39 33 #include "alphabuf.h" 40 34 #include "blend.h" … … 48 42 49 43 #ifdef __WIN32OS2__ 50 #include <os2win.h>51 44 #include <cpuhlp.h> 52 45 #endif 53 46 54 void gl_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor ) 55 { 47 void 48 _mesa_BlendFunc( GLenum sfactor, GLenum dfactor ) 49 { 50 GET_CURRENT_CONTEXT(ctx); 56 51 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glBlendFunc"); 57 52 … … 111 106 112 107 113 /* GL_ INGR_blend_func_separate */108 /* GL_EXT_blend_func_separate */ 114 109 void 115 gl_BlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB, GLenum dfactorRGB, 116 GLenum sfactorA, GLenum dfactorA ) 117 { 110 _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, 111 GLenum sfactorA, GLenum dfactorA ) 112 { 113 GET_CURRENT_CONTEXT(ctx); 118 114 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glBlendFuncSeparate"); 119 115 … … 219 215 220 216 /* This is really an extension function! */ 221 void gl_BlendEquation( GLcontext *ctx, GLenum mode ) 222 { 217 void 218 _mesa_BlendEquation( GLenum mode ) 219 { 220 GET_CURRENT_CONTEXT(ctx); 223 221 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glBlendEquation"); 224 222 … … 261 259 262 260 263 void gl_BlendColor( GLcontext *ctx, GLclampf red, GLclampf green, 264 GLclampf blue, GLclampf alpha ) 265 { 261 void 262 _mesa_BlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) 263 { 264 GET_CURRENT_CONTEXT(ctx); 266 265 ctx->Color.BlendColor[0] = CLAMP( red, 0.0F, 1.0F ); 267 266 ctx->Color.BlendColor[1] = CLAMP( green, 0.0F, 1.0F ); … … 270 269 } 271 270 272 271 #ifdef USE_MMX_ASM 272 #define _BLENDAPI _ASMAPI 273 #else 274 #define _BLENDAPI 275 #endif 273 276 274 277 /* 275 278 * Common transparency blending mode. 276 279 */ 277 static void __cdecl blend_transparency( GLcontext *ctx, GLuint n, const GLubyte mask[], 278 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 280 static void _BLENDAPI 281 blend_transparency( GLcontext *ctx, GLuint n, const GLubyte mask[], 282 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 279 283 { 280 284 GLuint i; … … 286 290 for (i=0;i<n;i++) { 287 291 if (mask[i]) { 288 GLint t = rgba[i][ACOMP]; /* t in [0,255] */292 const GLint t = rgba[i][ACOMP]; /* t in [0,255] */ 289 293 if (t == 0) { 294 /* 0% alpha */ 290 295 rgba[i][RCOMP] = dest[i][RCOMP]; 291 296 rgba[i][GCOMP] = dest[i][GCOMP]; … … 293 298 rgba[i][ACOMP] = dest[i][ACOMP]; 294 299 } 295 else if (t == 255) {296 /* no-op */300 else if (t == CHAN_MAX) { 301 /* 100% alpha, no-op */ 297 302 } 298 303 else { 299 GLint s = 255- t;300 GLint r = (rgba[i][RCOMP] * t + dest[i][RCOMP] * s) >> 8;301 GLint g = (rgba[i][GCOMP] * t + dest[i][GCOMP] * s) >> 8;302 GLint b = (rgba[i][BCOMP] * t + dest[i][BCOMP] * s) >> 8;303 GLint a = (rgba[i][ACOMP] * t + dest[i][ACOMP] * s) >> 8;304 ASSERT(r <= 255);305 ASSERT(g <= 255);306 ASSERT(b <= 255);307 ASSERT(a <= 255);304 const GLint s = CHAN_MAX - t; 305 const GLint r = (rgba[i][RCOMP] * t + dest[i][RCOMP] * s) >> 8; 306 const GLint g = (rgba[i][GCOMP] * t + dest[i][GCOMP] * s) >> 8; 307 const GLint b = (rgba[i][BCOMP] * t + dest[i][BCOMP] * s) >> 8; 308 const GLint a = (rgba[i][ACOMP] * t + dest[i][ACOMP] * s) >> 8; 309 ASSERT(r <= CHAN_MAX); 310 ASSERT(g <= CHAN_MAX); 311 ASSERT(b <= CHAN_MAX); 312 ASSERT(a <= CHAN_MAX); 308 313 rgba[i][RCOMP] = (GLubyte) r; 309 314 rgba[i][GCOMP] = (GLubyte) g; … … 320 325 * Add src and dest. 321 326 */ 322 static void __cdecl blend_add( GLcontext *ctx, GLuint n, const GLubyte mask[], 323 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 327 static void _BLENDAPI 328 blend_add( GLcontext *ctx, GLuint n, const GLubyte mask[], 329 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 324 330 { 325 331 GLuint i; … … 335 341 GLint b = rgba[i][BCOMP] + dest[i][BCOMP]; 336 342 GLint a = rgba[i][ACOMP] + dest[i][ACOMP]; 337 rgba[i][RCOMP] = (GLubyte) MIN2( r, 255);338 rgba[i][GCOMP] = (GLubyte) MIN2( g, 255);339 rgba[i][BCOMP] = (GLubyte) MIN2( b, 255);340 rgba[i][ACOMP] = (GLubyte) MIN2( a, 255);343 rgba[i][RCOMP] = (GLubyte) MIN2( r, CHAN_MAX ); 344 rgba[i][GCOMP] = (GLubyte) MIN2( g, CHAN_MAX ); 345 rgba[i][BCOMP] = (GLubyte) MIN2( b, CHAN_MAX ); 346 rgba[i][ACOMP] = (GLubyte) MIN2( a, CHAN_MAX ); 341 347 } 342 348 } … … 348 354 * Blend min function (for GL_EXT_blend_minmax) 349 355 */ 350 static void __cdecl blend_min( GLcontext *ctx, GLuint n, const GLubyte mask[], 351 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 356 static void _BLENDAPI 357 blend_min( GLcontext *ctx, GLuint n, const GLubyte mask[], 358 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 352 359 { 353 360 GLuint i; … … 370 377 * Blend max function (for GL_EXT_blend_minmax) 371 378 */ 372 static void __cdecl blend_max( GLcontext *ctx, GLuint n, const GLubyte mask[], 373 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 379 static void _BLENDAPI 380 blend_max( GLcontext *ctx, GLuint n, const GLubyte mask[], 381 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 374 382 { 375 383 GLuint i; … … 392 400 * Modulate: result = src * dest 393 401 */ 394 static void __cdecl blend_modulate( GLcontext *ctx, GLuint n, const GLubyte mask[], 395 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 402 static void _BLENDAPI 403 blend_modulate( GLcontext *ctx, GLuint n, const GLubyte mask[], 404 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 396 405 { 397 406 GLuint i; … … 421 430 * Input: dest - the pixels from the dest color buffer 422 431 */ 423 static void __cdecl blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], 424 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 425 { 426 GLfloat rscale = 1.0F / 255.0F; 427 GLfloat gscale = 1.0F / 255.0F; 428 GLfloat bscale = 1.0F / 255.0F; 429 GLfloat ascale = 1.0F / 255.0F; 432 static void _BLENDAPI 433 blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], 434 GLubyte rgba[][4], CONST GLubyte dest[][4] ) 435 { 436 GLfloat rscale = 1.0F / CHAN_MAXF; 437 GLfloat gscale = 1.0F / CHAN_MAXF; 438 GLfloat bscale = 1.0F / CHAN_MAXF; 439 GLfloat ascale = 1.0F / CHAN_MAXF; 430 440 GLuint i; 431 441 … … 481 491 break; 482 492 case GL_SRC_ALPHA_SATURATE: 483 #ifdef __WIN32OS2__ 484 if(As < 255 - Ad) { 485 #else 486 if (As < 1.0F - (GLfloat) Ad * ascale) { 487 #endif 493 if (As < CHAN_MAX - Ad) { 488 494 sR = sG = sB = (GLfloat) As * ascale; 489 495 } … … 704 710 705 711 /* final clamping */ 706 rgba[i][RCOMP] = (GLubyte) (GLint) CLAMP( r, 0.0F, 255.0F );707 rgba[i][GCOMP] = (GLubyte) (GLint) CLAMP( g, 0.0F, 255.0F );708 rgba[i][BCOMP] = (GLubyte) (GLint) CLAMP( b, 0.0F, 255.0F );709 rgba[i][ACOMP] = (GLubyte) (GLint) CLAMP( a, 0.0F, 255.0F );712 rgba[i][RCOMP] = (GLubyte) (GLint) CLAMP( r, 0.0F, CHAN_MAXF ); 713 rgba[i][GCOMP] = (GLubyte) (GLint) CLAMP( g, 0.0F, CHAN_MAXF ); 714 rgba[i][BCOMP] = (GLubyte) (GLint) CLAMP( b, 0.0F, CHAN_MAXF ); 715 rgba[i][ACOMP] = (GLubyte) (GLint) CLAMP( a, 0.0F, CHAN_MAXF ); 710 716 } 711 717 } … … 783 789 * In/Out: rgba - pixel values 784 790 */ 785 void gl_blend_span( GLcontext *ctx, GLuint n, GLint x, GLint y, 786 GLubyte rgba[][4], const GLubyte mask[] ) 791 void 792 _mesa_blend_span( GLcontext *ctx, GLuint n, GLint x, GLint y, 793 GLubyte rgba[][4], const GLubyte mask[] ) 787 794 { 788 795 GLubyte dest[MAX_WIDTH][4]; … … 794 801 795 802 /* Read span of current frame buffer pixels */ 796 gl_read_rgba_span( ctx, n, x, y, dest );803 gl_read_rgba_span( ctx, ctx->DrawBuffer, n, x, y, dest ); 797 804 798 805 if (!ctx->Color.BlendFunc) … … 813 820 * In/Out: rgba - pixel values 814 821 */ 815 void gl_blend_pixels( GLcontext *ctx, 816 GLuint n, const GLint x[], const GLint y[], 817 GLubyte rgba[][4], const GLubyte mask[] ) 822 void 823 _mesa_blend_pixels( GLcontext *ctx, 824 GLuint n, const GLint x[], const GLint y[], 825 GLubyte rgba[][4], const GLubyte mask[] ) 818 826 { 819 827 GLubyte dest[PB_SIZE][4];
Note:
See TracChangeset
for help on using the changeset viewer.