3 * Mesa 3-D graphics library
6 * Copyright (C) 1999 Brian Paul All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 gl_mmx_blend_transparency( GLcontext
*ctx
, GLuint n
, const GLubyte mask
[],
36 GLubyte rgba
[][4], const GLubyte dest
[][4] );
39 void gl_mmx_set_blend_function( GLcontext
*ctx
)
41 const GLenum eq
= ctx
->Color
.BlendEquation
;
42 const GLenum srcRGB
= ctx
->Color
.BlendSrcRGB
;
43 const GLenum dstRGB
= ctx
->Color
.BlendDstRGB
;
44 const GLenum srcA
= ctx
->Color
.BlendSrcA
;
45 const GLenum dstA
= ctx
->Color
.BlendDstA
;
48 if (srcRGB
!= srcA
|| dstRGB
!= dstA
) {
49 ctx
->Color
.BlendFunc
= blend_general
;
51 else if (eq
==GL_FUNC_ADD_EXT
&& srcRGB
==GL_SRC_ALPHA
52 && dstRGB
==GL_ONE_MINUS_SRC_ALPHA
) {
53 ctx
->Color
.BlendFunc
= gl_mmx_blend_transparency
;
55 else if (eq
==GL_FUNC_ADD_EXT
&& srcRGB
==GL_ONE
&& dstRGB
==GL_ONE
) {
56 ctx
->Color
.BlendFunc
= blend_add
;
58 else if (((eq
==GL_FUNC_ADD_EXT
|| eq
==GL_FUNC_REVERSE_SUBTRACT_EXT
)
59 && (srcRGB
==GL_ZERO
&& dstRGB
==GL_SRC_COLOR
))
61 ((eq
==GL_FUNC_ADD_EXT
|| eq
==GL_FUNC_SUBTRACT_EXT
)
62 && (srcRGB
==GL_DST_COLOR
&& dstRGB
==GL_ZERO
))) {
63 ctx
->Color
.BlendFunc
= blend_modulate
;
65 else if (eq
==GL_MIN_EXT
) {
66 ctx
->Color
.BlendFunc
= blend_min
;
68 else if (eq
==GL_MAX_EXT
) {
69 ctx
->Color
.BlendFunc
= blend_max
;
72 ctx
->Color
.BlendFunc
= blend_general
;