1 /* $Id: histogram.c,v 1.2 2000/11/10 18:31:04 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 #include "histogram.h"
42 pack_histogram( GLcontext
*ctx
,
43 GLuint n
, CONST GLuint rgba
[][4],
44 GLenum format
, GLenum type
, GLvoid
*destination
,
45 const struct gl_pixelstore_attrib
*packing
)
47 const GLint comps
= _mesa_components_in_format(format
);
48 GLuint luminance
[MAX_WIDTH
];
50 if (format
== GL_LUMINANCE
|| format
== GL_LUMINANCE_ALPHA
) {
52 for (i
= 0; i
< n
; i
++) {
53 luminance
[i
] = rgba
[i
][RCOMP
] + rgba
[i
][GCOMP
] + rgba
[i
][BCOMP
];
57 #define PACK_MACRO(TYPE) \
63 dst[i] = (TYPE) rgba[i][RCOMP]; \
67 dst[i] = (TYPE) rgba[i][GCOMP]; \
71 dst[i] = (TYPE) rgba[i][BCOMP]; \
75 dst[i] = (TYPE) rgba[i][ACOMP]; \
79 dst[i] = (TYPE) luminance[i]; \
81 case GL_LUMINANCE_ALPHA: \
83 dst[i*2+0] = (TYPE) luminance[i]; \
84 dst[i*2+1] = (TYPE) rgba[i][ACOMP]; \
89 dst[i*3+0] = (TYPE) rgba[i][RCOMP]; \
90 dst[i*3+1] = (TYPE) rgba[i][GCOMP]; \
91 dst[i*3+2] = (TYPE) rgba[i][BCOMP]; \
96 dst[i*4+0] = (TYPE) rgba[i][RCOMP]; \
97 dst[i*4+1] = (TYPE) rgba[i][GCOMP]; \
98 dst[i*4+2] = (TYPE) rgba[i][BCOMP]; \
99 dst[i*4+3] = (TYPE) rgba[i][ACOMP]; \
103 for (i=0;i<n;i++) { \
104 dst[i*3+0] = (TYPE) rgba[i][BCOMP]; \
105 dst[i*3+1] = (TYPE) rgba[i][GCOMP]; \
106 dst[i*3+2] = (TYPE) rgba[i][RCOMP]; \
110 for (i=0;i<n;i++) { \
111 dst[i*4+0] = (TYPE) rgba[i][BCOMP]; \
112 dst[i*4+1] = (TYPE) rgba[i][GCOMP]; \
113 dst[i*4+2] = (TYPE) rgba[i][RCOMP]; \
114 dst[i*4+3] = (TYPE) rgba[i][ACOMP]; \
118 for (i=0;i<n;i++) { \
119 dst[i*4+0] = (TYPE) rgba[i][ACOMP]; \
120 dst[i*4+1] = (TYPE) rgba[i][BCOMP]; \
121 dst[i*4+2] = (TYPE) rgba[i][GCOMP]; \
122 dst[i*4+3] = (TYPE) rgba[i][RCOMP]; \
126 gl_problem(ctx, "bad format in pack_histogram"); \
131 case GL_UNSIGNED_BYTE
:
133 GLubyte
*dst
= (GLubyte
*) destination
;
139 GLbyte
*dst
= (GLbyte
*) destination
;
143 case GL_UNSIGNED_SHORT
:
145 GLushort
*dst
= (GLushort
*) destination
;
146 PACK_MACRO(GLushort
);
147 if (packing
->SwapBytes
) {
148 _mesa_swap2(dst
, n
* comps
);
154 GLshort
*dst
= (GLshort
*) destination
;
156 if (packing
->SwapBytes
) {
157 _mesa_swap2((GLushort
*) dst
, n
* comps
);
161 case GL_UNSIGNED_INT
:
163 GLuint
*dst
= (GLuint
*) destination
;
165 if (packing
->SwapBytes
) {
166 _mesa_swap4(dst
, n
* comps
);
172 GLint
*dst
= (GLint
*) destination
;
174 if (packing
->SwapBytes
) {
175 _mesa_swap4((GLuint
*) dst
, n
* comps
);
181 GLfloat
*dst
= (GLfloat
*) destination
;
183 if (packing
->SwapBytes
) {
184 _mesa_swap4((GLuint
*) dst
, n
* comps
);
189 gl_problem(ctx
, "Bad type in pack_histogram");
198 pack_minmax( GLcontext
*ctx
, CONST GLfloat minmax
[2][4],
199 GLenum format
, GLenum type
, GLvoid
*destination
,
200 const struct gl_pixelstore_attrib
*packing
)
202 const GLint comps
= _mesa_components_in_format(format
);
205 if (format
== GL_LUMINANCE
|| format
== GL_LUMINANCE_ALPHA
) {
206 luminance
[0] = minmax
[0][RCOMP
] + minmax
[0][GCOMP
] + minmax
[0][BCOMP
];
207 luminance
[1] = minmax
[1][RCOMP
] + minmax
[1][GCOMP
] + minmax
[1][BCOMP
];
210 #define PACK_MACRO(TYPE, CONVERSION) \
216 dst[i] = CONVERSION (minmax[i][RCOMP]); \
220 dst[i] = CONVERSION (minmax[i][GCOMP]); \
224 dst[i] = CONVERSION (minmax[i][BCOMP]); \
228 dst[i] = CONVERSION (minmax[i][ACOMP]); \
232 dst[i] = CONVERSION (luminance[i]); \
234 case GL_LUMINANCE_ALPHA: \
235 for (i=0;i<2;i++) { \
236 dst[i*2+0] = CONVERSION (luminance[i]); \
237 dst[i*2+1] = CONVERSION (minmax[i][ACOMP]); \
241 for (i=0;i<2;i++) { \
242 dst[i*3+0] = CONVERSION (minmax[i][RCOMP]); \
243 dst[i*3+1] = CONVERSION (minmax[i][GCOMP]); \
244 dst[i*3+2] = CONVERSION (minmax[i][BCOMP]); \
248 for (i=0;i<2;i++) { \
249 dst[i*4+0] = CONVERSION (minmax[i][RCOMP]); \
250 dst[i*4+1] = CONVERSION (minmax[i][GCOMP]); \
251 dst[i*4+2] = CONVERSION (minmax[i][BCOMP]); \
252 dst[i*4+3] = CONVERSION (minmax[i][ACOMP]); \
256 for (i=0;i<2;i++) { \
257 dst[i*3+0] = CONVERSION (minmax[i][BCOMP]); \
258 dst[i*3+1] = CONVERSION (minmax[i][GCOMP]); \
259 dst[i*3+2] = CONVERSION (minmax[i][RCOMP]); \
263 for (i=0;i<2;i++) { \
264 dst[i*4+0] = CONVERSION (minmax[i][BCOMP]); \
265 dst[i*4+1] = CONVERSION (minmax[i][GCOMP]); \
266 dst[i*4+2] = CONVERSION (minmax[i][RCOMP]); \
267 dst[i*4+3] = CONVERSION (minmax[i][ACOMP]); \
271 for (i=0;i<2;i++) { \
272 dst[i*4+0] = CONVERSION (minmax[i][ACOMP]); \
273 dst[i*4+1] = CONVERSION (minmax[i][BCOMP]); \
274 dst[i*4+2] = CONVERSION (minmax[i][GCOMP]); \
275 dst[i*4+3] = CONVERSION (minmax[i][RCOMP]); \
279 gl_problem(ctx, "bad format in pack_minmax"); \
284 case GL_UNSIGNED_BYTE
:
286 GLubyte
*dst
= (GLubyte
*) destination
;
287 PACK_MACRO(GLubyte
, FLOAT_TO_UBYTE
);
292 GLbyte
*dst
= (GLbyte
*) destination
;
293 PACK_MACRO(GLbyte
, FLOAT_TO_BYTE
);
296 case GL_UNSIGNED_SHORT
:
298 GLushort
*dst
= (GLushort
*) destination
;
299 PACK_MACRO(GLushort
, FLOAT_TO_USHORT
);
300 if (packing
->SwapBytes
) {
301 _mesa_swap2(dst
, 2 * comps
);
307 GLshort
*dst
= (GLshort
*) destination
;
308 PACK_MACRO(GLshort
, FLOAT_TO_SHORT
);
309 if (packing
->SwapBytes
) {
310 _mesa_swap2((GLushort
*) dst
, 2 * comps
);
314 case GL_UNSIGNED_INT
:
316 GLuint
*dst
= (GLuint
*) destination
;
317 PACK_MACRO(GLuint
, FLOAT_TO_UINT
);
318 if (packing
->SwapBytes
) {
319 _mesa_swap4(dst
, 2 * comps
);
325 GLint
*dst
= (GLint
*) destination
;
326 PACK_MACRO(GLint
, FLOAT_TO_INT
);
327 if (packing
->SwapBytes
) {
328 _mesa_swap4((GLuint
*) dst
, 2 * comps
);
334 GLfloat
*dst
= (GLfloat
*) destination
;
335 PACK_MACRO(GLfloat
, (GLfloat
));
336 if (packing
->SwapBytes
) {
337 _mesa_swap4((GLuint
*) dst
, 2 * comps
);
342 gl_problem(ctx
, "Bad type in pack_minmax");
350 * Given an internalFormat token passed to glHistogram or glMinMax,
351 * return the corresponding base format.
352 * Return -1 if invalid token.
355 base_histogram_format( GLenum format
)
370 case GL_LUMINANCE_ALPHA
:
371 case GL_LUMINANCE4_ALPHA4
:
372 case GL_LUMINANCE6_ALPHA2
:
373 case GL_LUMINANCE8_ALPHA8
:
374 case GL_LUMINANCE12_ALPHA4
:
375 case GL_LUMINANCE12_ALPHA12
:
376 case GL_LUMINANCE16_ALPHA16
:
377 return GL_LUMINANCE_ALPHA
;
397 return -1; /* error */
403 _mesa_GetMinmax(GLenum target
, GLboolean reset
, GLenum format
, GLenum type
, GLvoid
*values
)
405 GET_CURRENT_CONTEXT(ctx
);
406 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetMinmax");
408 if (!ctx
->Extensions
.EXT_histogram
) {
409 gl_error(ctx
, GL_INVALID_OPERATION
, "glGetMinmax");
413 if (target
!= GL_MINMAX
) {
414 gl_error(ctx
, GL_INVALID_ENUM
, "glGetMinmax(target)");
418 if (format
!= GL_RED
&&
419 format
!= GL_GREEN
&&
421 format
!= GL_ALPHA
&&
424 format
!= GL_ABGR_EXT
&&
425 format
!= GL_LUMINANCE
&&
426 format
!= GL_LUMINANCE_ALPHA
) {
427 gl_error(ctx
, GL_INVALID_ENUM
, "glGetMinmax(format)");
431 if (type
!= GL_UNSIGNED_BYTE
&&
433 type
!= GL_UNSIGNED_SHORT
&&
435 type
!= GL_UNSIGNED_INT
&&
438 gl_error(ctx
, GL_INVALID_ENUM
, "glGetMinmax(type)");
446 GLfloat minmax
[2][4];
447 minmax
[0][RCOMP
] = CLAMP(ctx
->MinMax
.Min
[RCOMP
], 0.0F
, 1.0F
);
448 minmax
[0][GCOMP
] = CLAMP(ctx
->MinMax
.Min
[GCOMP
], 0.0F
, 1.0F
);
449 minmax
[0][BCOMP
] = CLAMP(ctx
->MinMax
.Min
[BCOMP
], 0.0F
, 1.0F
);
450 minmax
[0][ACOMP
] = CLAMP(ctx
->MinMax
.Min
[ACOMP
], 0.0F
, 1.0F
);
451 minmax
[1][RCOMP
] = CLAMP(ctx
->MinMax
.Max
[RCOMP
], 0.0F
, 1.0F
);
452 minmax
[1][GCOMP
] = CLAMP(ctx
->MinMax
.Max
[GCOMP
], 0.0F
, 1.0F
);
453 minmax
[1][BCOMP
] = CLAMP(ctx
->MinMax
.Max
[BCOMP
], 0.0F
, 1.0F
);
454 minmax
[1][ACOMP
] = CLAMP(ctx
->MinMax
.Max
[ACOMP
], 0.0F
, 1.0F
);
455 pack_minmax(ctx
, (CONST
GLfloat (*)[4]) minmax
,
456 format
, type
, values
, &ctx
->Pack
);
460 _mesa_ResetMinmax(GL_MINMAX
);
466 _mesa_GetHistogram(GLenum target
, GLboolean reset
, GLenum format
, GLenum type
, GLvoid
*values
)
468 GET_CURRENT_CONTEXT(ctx
);
469 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetHistogram");
471 if (!ctx
->Extensions
.EXT_histogram
) {
472 gl_error(ctx
, GL_INVALID_OPERATION
, "glGetHistogram");
476 if (target
!= GL_HISTOGRAM
) {
477 gl_error(ctx
, GL_INVALID_ENUM
, "glGetHistogram(target)");
481 if (format
!= GL_RED
&&
482 format
!= GL_GREEN
&&
484 format
!= GL_ALPHA
&&
487 format
!= GL_ABGR_EXT
&&
488 format
!= GL_LUMINANCE
&&
489 format
!= GL_LUMINANCE_ALPHA
) {
490 gl_error(ctx
, GL_INVALID_ENUM
, "glGetHistogram(format)");
494 if (type
!= GL_UNSIGNED_BYTE
&&
496 type
!= GL_UNSIGNED_SHORT
&&
498 type
!= GL_UNSIGNED_INT
&&
501 gl_error(ctx
, GL_INVALID_ENUM
, "glGetHistogram(type)");
508 pack_histogram(ctx
, ctx
->Histogram
.Width
,
509 (CONST
GLuint (*)[4]) ctx
->Histogram
.Count
,
510 format
, type
, values
, &ctx
->Pack
);
514 for (i
= 0; i
< HISTOGRAM_TABLE_SIZE
; i
++) {
515 ctx
->Histogram
.Count
[i
][0] = 0;
516 ctx
->Histogram
.Count
[i
][1] = 0;
517 ctx
->Histogram
.Count
[i
][2] = 0;
518 ctx
->Histogram
.Count
[i
][3] = 0;
525 _mesa_GetHistogramParameterfv(GLenum target
, GLenum pname
, GLfloat
*params
)
527 GET_CURRENT_CONTEXT(ctx
);
528 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetHistogramParameterfv");
530 if (!ctx
->Extensions
.EXT_histogram
) {
531 gl_error(ctx
, GL_INVALID_OPERATION
, "glGetHistogramParameterfv");
535 if (target
!= GL_HISTOGRAM
&& target
!= GL_PROXY_HISTOGRAM
) {
536 gl_error(ctx
, GL_INVALID_ENUM
, "glGetHistogramParameterfv(target)");
541 case GL_HISTOGRAM_WIDTH
:
542 *params
= (GLfloat
) ctx
->Histogram
.Width
;
544 case GL_HISTOGRAM_FORMAT
:
545 *params
= (GLfloat
) ctx
->Histogram
.Format
;
547 case GL_HISTOGRAM_RED_SIZE
:
548 *params
= (GLfloat
) ctx
->Histogram
.RedSize
;
550 case GL_HISTOGRAM_GREEN_SIZE
:
551 *params
= (GLfloat
) ctx
->Histogram
.GreenSize
;
553 case GL_HISTOGRAM_BLUE_SIZE
:
554 *params
= (GLfloat
) ctx
->Histogram
.BlueSize
;
556 case GL_HISTOGRAM_ALPHA_SIZE
:
557 *params
= (GLfloat
) ctx
->Histogram
.AlphaSize
;
559 case GL_HISTOGRAM_LUMINANCE_SIZE
:
560 *params
= (GLfloat
) ctx
->Histogram
.LuminanceSize
;
562 case GL_HISTOGRAM_SINK
:
563 *params
= (GLfloat
) ctx
->Histogram
.Sink
;
566 gl_error(ctx
, GL_INVALID_ENUM
, "glGetHistogramParameterfv(pname)");
572 _mesa_GetHistogramParameteriv(GLenum target
, GLenum pname
, GLint
*params
)
574 GET_CURRENT_CONTEXT(ctx
);
575 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetHistogramParameteriv");
577 if (!ctx
->Extensions
.EXT_histogram
) {
578 gl_error(ctx
, GL_INVALID_OPERATION
, "glGetHistogramParameteriv");
582 if (target
!= GL_HISTOGRAM
&& target
!= GL_PROXY_HISTOGRAM
) {
583 gl_error(ctx
, GL_INVALID_ENUM
, "glGetHistogramParameteriv(target)");
588 case GL_HISTOGRAM_WIDTH
:
589 *params
= (GLint
) ctx
->Histogram
.Width
;
591 case GL_HISTOGRAM_FORMAT
:
592 *params
= (GLint
) ctx
->Histogram
.Format
;
594 case GL_HISTOGRAM_RED_SIZE
:
595 *params
= (GLint
) ctx
->Histogram
.RedSize
;
597 case GL_HISTOGRAM_GREEN_SIZE
:
598 *params
= (GLint
) ctx
->Histogram
.GreenSize
;
600 case GL_HISTOGRAM_BLUE_SIZE
:
601 *params
= (GLint
) ctx
->Histogram
.BlueSize
;
603 case GL_HISTOGRAM_ALPHA_SIZE
:
604 *params
= (GLint
) ctx
->Histogram
.AlphaSize
;
606 case GL_HISTOGRAM_LUMINANCE_SIZE
:
607 *params
= (GLint
) ctx
->Histogram
.LuminanceSize
;
609 case GL_HISTOGRAM_SINK
:
610 *params
= (GLint
) ctx
->Histogram
.Sink
;
613 gl_error(ctx
, GL_INVALID_ENUM
, "glGetHistogramParameteriv(pname)");
619 _mesa_GetMinmaxParameterfv(GLenum target
, GLenum pname
, GLfloat
*params
)
621 GET_CURRENT_CONTEXT(ctx
);
622 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetMinmaxParameterfv");
624 if (!ctx
->Extensions
.EXT_histogram
) {
625 gl_error(ctx
, GL_INVALID_OPERATION
, "glGetMinmaxParameterfv");
628 if (target
!= GL_MINMAX
) {
629 gl_error(ctx
, GL_INVALID_ENUM
, "glGetMinmaxParameterfv(target)");
632 if (pname
== GL_MINMAX_FORMAT
) {
633 *params
= (GLfloat
) ctx
->MinMax
.Format
;
635 else if (pname
== GL_MINMAX_SINK
) {
636 *params
= (GLfloat
) ctx
->MinMax
.Sink
;
639 gl_error(ctx
, GL_INVALID_ENUM
, "glGetMinMaxParameterfv(pname)");
645 _mesa_GetMinmaxParameteriv(GLenum target
, GLenum pname
, GLint
*params
)
647 GET_CURRENT_CONTEXT(ctx
);
648 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetMinmaxParameteriv");
650 if (!ctx
->Extensions
.EXT_histogram
) {
651 gl_error(ctx
, GL_INVALID_OPERATION
, "glGetMinmaxParameteriv");
654 if (target
!= GL_MINMAX
) {
655 gl_error(ctx
, GL_INVALID_ENUM
, "glGetMinmaxParameteriv(target)");
658 if (pname
== GL_MINMAX_FORMAT
) {
659 *params
= (GLint
) ctx
->MinMax
.Format
;
661 else if (pname
== GL_MINMAX_SINK
) {
662 *params
= (GLint
) ctx
->MinMax
.Sink
;
665 gl_error(ctx
, GL_INVALID_ENUM
, "glGetMinMaxParameteriv(pname)");
671 _mesa_Histogram(GLenum target
, GLsizei width
, GLenum internalFormat
, GLboolean sink
)
674 GLboolean error
= GL_FALSE
;
675 GET_CURRENT_CONTEXT(ctx
);
676 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glHistogram");
678 if (!ctx
->Extensions
.EXT_histogram
) {
679 gl_error(ctx
, GL_INVALID_OPERATION
, "glHistogram");
683 if (target
!= GL_HISTOGRAM
&& target
!= GL_PROXY_HISTOGRAM
) {
684 gl_error(ctx
, GL_INVALID_ENUM
, "glHistogram(target)");
688 if (width
< 0 || width
> HISTOGRAM_TABLE_SIZE
) {
689 if (target
== GL_PROXY_HISTOGRAM
) {
694 gl_error(ctx
, GL_INVALID_VALUE
, "glHistogram(width)");
696 gl_error(ctx
, GL_TABLE_TOO_LARGE
, "glHistogram(width)");
701 if (width
!= 0 && _mesa_bitcount(width
) != 1) {
702 if (target
== GL_PROXY_HISTOGRAM
) {
706 gl_error(ctx
, GL_INVALID_VALUE
, "glHistogram(width)");
711 if (base_histogram_format(internalFormat
) < 0) {
712 if (target
== GL_PROXY_HISTOGRAM
) {
716 gl_error(ctx
, GL_INVALID_ENUM
, "glHistogram(internalFormat)");
721 /* reset histograms */
722 for (i
= 0; i
< HISTOGRAM_TABLE_SIZE
; i
++) {
723 ctx
->Histogram
.Count
[i
][0] = 0;
724 ctx
->Histogram
.Count
[i
][1] = 0;
725 ctx
->Histogram
.Count
[i
][2] = 0;
726 ctx
->Histogram
.Count
[i
][3] = 0;
730 ctx
->Histogram
.Width
= 0;
731 ctx
->Histogram
.Format
= 0;
732 ctx
->Histogram
.RedSize
= 0;
733 ctx
->Histogram
.GreenSize
= 0;
734 ctx
->Histogram
.BlueSize
= 0;
735 ctx
->Histogram
.AlphaSize
= 0;
736 ctx
->Histogram
.LuminanceSize
= 0;
739 ctx
->Histogram
.Width
= width
;
740 ctx
->Histogram
.Format
= internalFormat
;
741 ctx
->Histogram
.Sink
= sink
;
742 ctx
->Histogram
.RedSize
= 0xffffffff;
743 ctx
->Histogram
.GreenSize
= 0xffffffff;
744 ctx
->Histogram
.BlueSize
= 0xffffffff;
745 ctx
->Histogram
.AlphaSize
= 0xffffffff;
746 ctx
->Histogram
.LuminanceSize
= 0xffffffff;
749 ctx
->NewState
|= _NEW_PIXEL
;
754 _mesa_Minmax(GLenum target
, GLenum internalFormat
, GLboolean sink
)
756 GET_CURRENT_CONTEXT(ctx
);
757 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glMinmax");
759 if (!ctx
->Extensions
.EXT_histogram
) {
760 gl_error(ctx
, GL_INVALID_OPERATION
, "glMinmax");
764 if (target
!= GL_MINMAX
) {
765 gl_error(ctx
, GL_INVALID_ENUM
, "glMinMax(target)");
769 if (base_histogram_format(internalFormat
) < 0) {
770 gl_error(ctx
, GL_INVALID_ENUM
, "glMinMax(internalFormat)");
774 ctx
->MinMax
.Sink
= sink
;
775 ctx
->NewState
|= _NEW_PIXEL
;
780 _mesa_ResetHistogram(GLenum target
)
783 GET_CURRENT_CONTEXT(ctx
);
784 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glResetHistogram");
786 if (!ctx
->Extensions
.EXT_histogram
) {
787 gl_error(ctx
, GL_INVALID_OPERATION
, "glResetHistogram");
791 if (target
!= GL_HISTOGRAM
) {
792 gl_error(ctx
, GL_INVALID_ENUM
, "glResetHistogram(target)");
796 for (i
= 0; i
< HISTOGRAM_TABLE_SIZE
; i
++) {
797 ctx
->Histogram
.Count
[i
][0] = 0;
798 ctx
->Histogram
.Count
[i
][1] = 0;
799 ctx
->Histogram
.Count
[i
][2] = 0;
800 ctx
->Histogram
.Count
[i
][3] = 0;
803 ctx
->NewState
|= _NEW_PIXEL
;
808 _mesa_ResetMinmax(GLenum target
)
810 GET_CURRENT_CONTEXT(ctx
);
811 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glResetMinmax");
813 if (!ctx
->Extensions
.EXT_histogram
) {
814 gl_error(ctx
, GL_INVALID_OPERATION
, "glResetMinmax");
818 if (target
!= GL_MINMAX
) {
819 gl_error(ctx
, GL_INVALID_ENUM
, "glResetMinMax(target)");
823 ctx
->MinMax
.Min
[RCOMP
] = 1000; ctx
->MinMax
.Max
[RCOMP
] = -1000;
824 ctx
->MinMax
.Min
[GCOMP
] = 1000; ctx
->MinMax
.Max
[GCOMP
] = -1000;
825 ctx
->MinMax
.Min
[BCOMP
] = 1000; ctx
->MinMax
.Max
[BCOMP
] = -1000;
826 ctx
->MinMax
.Min
[ACOMP
] = 1000; ctx
->MinMax
.Max
[ACOMP
] = -1000;
827 ctx
->NewState
|= _NEW_PIXEL
;