histogram.c revision 7117f1b4
17117f1b4Smrg/* 27117f1b4Smrg * Mesa 3-D graphics library 37117f1b4Smrg * Version: 6.3 47117f1b4Smrg * 57117f1b4Smrg * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. 67117f1b4Smrg * 77117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 87117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 97117f1b4Smrg * to deal in the Software without restriction, including without limitation 107117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 117117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 127117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 137117f1b4Smrg * 147117f1b4Smrg * The above copyright notice and this permission notice shall be included 157117f1b4Smrg * in all copies or substantial portions of the Software. 167117f1b4Smrg * 177117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 187117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 197117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 207117f1b4Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 217117f1b4Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 227117f1b4Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 237117f1b4Smrg */ 247117f1b4Smrg 257117f1b4Smrg 267117f1b4Smrg#include "glheader.h" 277117f1b4Smrg#include "bufferobj.h" 287117f1b4Smrg#include "colormac.h" 297117f1b4Smrg#include "context.h" 307117f1b4Smrg#include "image.h" 317117f1b4Smrg#include "histogram.h" 327117f1b4Smrg 337117f1b4Smrg 347117f1b4Smrg/********************************************************************** 357117f1b4Smrg * Internal functions 367117f1b4Smrg */ 377117f1b4Smrg 387117f1b4Smrg 397117f1b4Smrg/* 407117f1b4Smrg * Update the min/max values from an array of fragment colors. 417117f1b4Smrg */ 427117f1b4Smrgvoid 437117f1b4Smrg_mesa_update_minmax(GLcontext *ctx, GLuint n, const GLfloat rgba[][4]) 447117f1b4Smrg{ 457117f1b4Smrg GLuint i; 467117f1b4Smrg for (i = 0; i < n; i++) { 477117f1b4Smrg /* update mins */ 487117f1b4Smrg if (rgba[i][RCOMP] < ctx->MinMax.Min[RCOMP]) 497117f1b4Smrg ctx->MinMax.Min[RCOMP] = rgba[i][RCOMP]; 507117f1b4Smrg if (rgba[i][GCOMP] < ctx->MinMax.Min[GCOMP]) 517117f1b4Smrg ctx->MinMax.Min[GCOMP] = rgba[i][GCOMP]; 527117f1b4Smrg if (rgba[i][BCOMP] < ctx->MinMax.Min[BCOMP]) 537117f1b4Smrg ctx->MinMax.Min[BCOMP] = rgba[i][BCOMP]; 547117f1b4Smrg if (rgba[i][ACOMP] < ctx->MinMax.Min[ACOMP]) 557117f1b4Smrg ctx->MinMax.Min[ACOMP] = rgba[i][ACOMP]; 567117f1b4Smrg 577117f1b4Smrg /* update maxs */ 587117f1b4Smrg if (rgba[i][RCOMP] > ctx->MinMax.Max[RCOMP]) 597117f1b4Smrg ctx->MinMax.Max[RCOMP] = rgba[i][RCOMP]; 607117f1b4Smrg if (rgba[i][GCOMP] > ctx->MinMax.Max[GCOMP]) 617117f1b4Smrg ctx->MinMax.Max[GCOMP] = rgba[i][GCOMP]; 627117f1b4Smrg if (rgba[i][BCOMP] > ctx->MinMax.Max[BCOMP]) 637117f1b4Smrg ctx->MinMax.Max[BCOMP] = rgba[i][BCOMP]; 647117f1b4Smrg if (rgba[i][ACOMP] > ctx->MinMax.Max[ACOMP]) 657117f1b4Smrg ctx->MinMax.Max[ACOMP] = rgba[i][ACOMP]; 667117f1b4Smrg } 677117f1b4Smrg} 687117f1b4Smrg 697117f1b4Smrg 707117f1b4Smrg/* 717117f1b4Smrg * Update the histogram values from an array of fragment colors. 727117f1b4Smrg */ 737117f1b4Smrgvoid 747117f1b4Smrg_mesa_update_histogram(GLcontext *ctx, GLuint n, const GLfloat rgba[][4]) 757117f1b4Smrg{ 767117f1b4Smrg const GLint max = ctx->Histogram.Width - 1; 777117f1b4Smrg GLfloat w = (GLfloat) max; 787117f1b4Smrg GLuint i; 797117f1b4Smrg 807117f1b4Smrg if (ctx->Histogram.Width == 0) 817117f1b4Smrg return; 827117f1b4Smrg 837117f1b4Smrg for (i = 0; i < n; i++) { 847117f1b4Smrg GLint ri = IROUND(rgba[i][RCOMP] * w); 857117f1b4Smrg GLint gi = IROUND(rgba[i][GCOMP] * w); 867117f1b4Smrg GLint bi = IROUND(rgba[i][BCOMP] * w); 877117f1b4Smrg GLint ai = IROUND(rgba[i][ACOMP] * w); 887117f1b4Smrg ri = CLAMP(ri, 0, max); 897117f1b4Smrg gi = CLAMP(gi, 0, max); 907117f1b4Smrg bi = CLAMP(bi, 0, max); 917117f1b4Smrg ai = CLAMP(ai, 0, max); 927117f1b4Smrg ctx->Histogram.Count[ri][RCOMP]++; 937117f1b4Smrg ctx->Histogram.Count[gi][GCOMP]++; 947117f1b4Smrg ctx->Histogram.Count[bi][BCOMP]++; 957117f1b4Smrg ctx->Histogram.Count[ai][ACOMP]++; 967117f1b4Smrg } 977117f1b4Smrg} 987117f1b4Smrg 997117f1b4Smrg 1007117f1b4Smrg/* 1017117f1b4Smrg * XXX the packed pixel formats haven't been tested. 1027117f1b4Smrg */ 1037117f1b4Smrgstatic void 1047117f1b4Smrgpack_histogram( GLcontext *ctx, 1057117f1b4Smrg GLuint n, CONST GLuint rgba[][4], 1067117f1b4Smrg GLenum format, GLenum type, GLvoid *destination, 1077117f1b4Smrg const struct gl_pixelstore_attrib *packing ) 1087117f1b4Smrg{ 1097117f1b4Smrg const GLint comps = _mesa_components_in_format(format); 1107117f1b4Smrg GLuint luminance[MAX_WIDTH]; 1117117f1b4Smrg 1127117f1b4Smrg if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA) { 1137117f1b4Smrg GLuint i; 1147117f1b4Smrg for (i = 0; i < n; i++) { 1157117f1b4Smrg luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; 1167117f1b4Smrg } 1177117f1b4Smrg } 1187117f1b4Smrg 1197117f1b4Smrg#define PACK_MACRO(TYPE) \ 1207117f1b4Smrg { \ 1217117f1b4Smrg GLuint i; \ 1227117f1b4Smrg switch (format) { \ 1237117f1b4Smrg case GL_RED: \ 1247117f1b4Smrg for (i=0;i<n;i++) \ 1257117f1b4Smrg dst[i] = (TYPE) rgba[i][RCOMP]; \ 1267117f1b4Smrg break; \ 1277117f1b4Smrg case GL_GREEN: \ 1287117f1b4Smrg for (i=0;i<n;i++) \ 1297117f1b4Smrg dst[i] = (TYPE) rgba[i][GCOMP]; \ 1307117f1b4Smrg break; \ 1317117f1b4Smrg case GL_BLUE: \ 1327117f1b4Smrg for (i=0;i<n;i++) \ 1337117f1b4Smrg dst[i] = (TYPE) rgba[i][BCOMP]; \ 1347117f1b4Smrg break; \ 1357117f1b4Smrg case GL_ALPHA: \ 1367117f1b4Smrg for (i=0;i<n;i++) \ 1377117f1b4Smrg dst[i] = (TYPE) rgba[i][ACOMP]; \ 1387117f1b4Smrg break; \ 1397117f1b4Smrg case GL_LUMINANCE: \ 1407117f1b4Smrg for (i=0;i<n;i++) \ 1417117f1b4Smrg dst[i] = (TYPE) luminance[i]; \ 1427117f1b4Smrg break; \ 1437117f1b4Smrg case GL_LUMINANCE_ALPHA: \ 1447117f1b4Smrg for (i=0;i<n;i++) { \ 1457117f1b4Smrg dst[i*2+0] = (TYPE) luminance[i]; \ 1467117f1b4Smrg dst[i*2+1] = (TYPE) rgba[i][ACOMP]; \ 1477117f1b4Smrg } \ 1487117f1b4Smrg break; \ 1497117f1b4Smrg case GL_RGB: \ 1507117f1b4Smrg for (i=0;i<n;i++) { \ 1517117f1b4Smrg dst[i*3+0] = (TYPE) rgba[i][RCOMP]; \ 1527117f1b4Smrg dst[i*3+1] = (TYPE) rgba[i][GCOMP]; \ 1537117f1b4Smrg dst[i*3+2] = (TYPE) rgba[i][BCOMP]; \ 1547117f1b4Smrg } \ 1557117f1b4Smrg break; \ 1567117f1b4Smrg case GL_RGBA: \ 1577117f1b4Smrg for (i=0;i<n;i++) { \ 1587117f1b4Smrg dst[i*4+0] = (TYPE) rgba[i][RCOMP]; \ 1597117f1b4Smrg dst[i*4+1] = (TYPE) rgba[i][GCOMP]; \ 1607117f1b4Smrg dst[i*4+2] = (TYPE) rgba[i][BCOMP]; \ 1617117f1b4Smrg dst[i*4+3] = (TYPE) rgba[i][ACOMP]; \ 1627117f1b4Smrg } \ 1637117f1b4Smrg break; \ 1647117f1b4Smrg case GL_BGR: \ 1657117f1b4Smrg for (i=0;i<n;i++) { \ 1667117f1b4Smrg dst[i*3+0] = (TYPE) rgba[i][BCOMP]; \ 1677117f1b4Smrg dst[i*3+1] = (TYPE) rgba[i][GCOMP]; \ 1687117f1b4Smrg dst[i*3+2] = (TYPE) rgba[i][RCOMP]; \ 1697117f1b4Smrg } \ 1707117f1b4Smrg break; \ 1717117f1b4Smrg case GL_BGRA: \ 1727117f1b4Smrg for (i=0;i<n;i++) { \ 1737117f1b4Smrg dst[i*4+0] = (TYPE) rgba[i][BCOMP]; \ 1747117f1b4Smrg dst[i*4+1] = (TYPE) rgba[i][GCOMP]; \ 1757117f1b4Smrg dst[i*4+2] = (TYPE) rgba[i][RCOMP]; \ 1767117f1b4Smrg dst[i*4+3] = (TYPE) rgba[i][ACOMP]; \ 1777117f1b4Smrg } \ 1787117f1b4Smrg break; \ 1797117f1b4Smrg case GL_ABGR_EXT: \ 1807117f1b4Smrg for (i=0;i<n;i++) { \ 1817117f1b4Smrg dst[i*4+0] = (TYPE) rgba[i][ACOMP]; \ 1827117f1b4Smrg dst[i*4+1] = (TYPE) rgba[i][BCOMP]; \ 1837117f1b4Smrg dst[i*4+2] = (TYPE) rgba[i][GCOMP]; \ 1847117f1b4Smrg dst[i*4+3] = (TYPE) rgba[i][RCOMP]; \ 1857117f1b4Smrg } \ 1867117f1b4Smrg break; \ 1877117f1b4Smrg default: \ 1887117f1b4Smrg _mesa_problem(ctx, "bad format in pack_histogram"); \ 1897117f1b4Smrg } \ 1907117f1b4Smrg } 1917117f1b4Smrg 1927117f1b4Smrg switch (type) { 1937117f1b4Smrg case GL_UNSIGNED_BYTE: 1947117f1b4Smrg { 1957117f1b4Smrg GLubyte *dst = (GLubyte *) destination; 1967117f1b4Smrg PACK_MACRO(GLubyte); 1977117f1b4Smrg } 1987117f1b4Smrg break; 1997117f1b4Smrg case GL_BYTE: 2007117f1b4Smrg { 2017117f1b4Smrg GLbyte *dst = (GLbyte *) destination; 2027117f1b4Smrg PACK_MACRO(GLbyte); 2037117f1b4Smrg } 2047117f1b4Smrg break; 2057117f1b4Smrg case GL_UNSIGNED_SHORT: 2067117f1b4Smrg { 2077117f1b4Smrg GLushort *dst = (GLushort *) destination; 2087117f1b4Smrg PACK_MACRO(GLushort); 2097117f1b4Smrg if (packing->SwapBytes) { 2107117f1b4Smrg _mesa_swap2(dst, n * comps); 2117117f1b4Smrg } 2127117f1b4Smrg } 2137117f1b4Smrg break; 2147117f1b4Smrg case GL_SHORT: 2157117f1b4Smrg { 2167117f1b4Smrg GLshort *dst = (GLshort *) destination; 2177117f1b4Smrg PACK_MACRO(GLshort); 2187117f1b4Smrg if (packing->SwapBytes) { 2197117f1b4Smrg _mesa_swap2((GLushort *) dst, n * comps); 2207117f1b4Smrg } 2217117f1b4Smrg } 2227117f1b4Smrg break; 2237117f1b4Smrg case GL_UNSIGNED_INT: 2247117f1b4Smrg { 2257117f1b4Smrg GLuint *dst = (GLuint *) destination; 2267117f1b4Smrg PACK_MACRO(GLuint); 2277117f1b4Smrg if (packing->SwapBytes) { 2287117f1b4Smrg _mesa_swap4(dst, n * comps); 2297117f1b4Smrg } 2307117f1b4Smrg } 2317117f1b4Smrg break; 2327117f1b4Smrg case GL_INT: 2337117f1b4Smrg { 2347117f1b4Smrg GLint *dst = (GLint *) destination; 2357117f1b4Smrg PACK_MACRO(GLint); 2367117f1b4Smrg if (packing->SwapBytes) { 2377117f1b4Smrg _mesa_swap4((GLuint *) dst, n * comps); 2387117f1b4Smrg } 2397117f1b4Smrg } 2407117f1b4Smrg break; 2417117f1b4Smrg case GL_FLOAT: 2427117f1b4Smrg { 2437117f1b4Smrg GLfloat *dst = (GLfloat *) destination; 2447117f1b4Smrg PACK_MACRO(GLfloat); 2457117f1b4Smrg if (packing->SwapBytes) { 2467117f1b4Smrg _mesa_swap4((GLuint *) dst, n * comps); 2477117f1b4Smrg } 2487117f1b4Smrg } 2497117f1b4Smrg break; 2507117f1b4Smrg case GL_HALF_FLOAT_ARB: 2517117f1b4Smrg { 2527117f1b4Smrg /* temporarily store as GLuints */ 2537117f1b4Smrg GLuint temp[4*HISTOGRAM_TABLE_SIZE]; 2547117f1b4Smrg GLhalfARB *dst = (GLhalfARB *) destination; 2557117f1b4Smrg GLuint i; 2567117f1b4Smrg /* get GLuint values */ 2577117f1b4Smrg PACK_MACRO(GLuint); 2587117f1b4Smrg /* convert to GLhalf */ 2597117f1b4Smrg for (i = 0; i < n * comps; i++) { 2607117f1b4Smrg dst[i] = _mesa_float_to_half((GLfloat) temp[i]); 2617117f1b4Smrg } 2627117f1b4Smrg if (packing->SwapBytes) { 2637117f1b4Smrg _mesa_swap2((GLushort *) dst, n * comps); 2647117f1b4Smrg } 2657117f1b4Smrg } 2667117f1b4Smrg break; 2677117f1b4Smrg case GL_UNSIGNED_BYTE_3_3_2: 2687117f1b4Smrg if (format == GL_RGB) { 2697117f1b4Smrg GLubyte *dst = (GLubyte *) destination; 2707117f1b4Smrg GLuint i; 2717117f1b4Smrg for (i = 0; i < n; i++) { 2727117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0x7) << 5) 2737117f1b4Smrg | ((rgba[i][GCOMP] & 0x7) << 2) 2747117f1b4Smrg | ((rgba[i][BCOMP] & 0x3) ); 2757117f1b4Smrg } 2767117f1b4Smrg } 2777117f1b4Smrg else { 2787117f1b4Smrg GLubyte *dst = (GLubyte *) destination; 2797117f1b4Smrg GLuint i; 2807117f1b4Smrg ASSERT(format == GL_BGR); 2817117f1b4Smrg for (i = 0; i < n; i++) { 2827117f1b4Smrg dst[i] = ((rgba[i][BCOMP] & 0x7) << 5) 2837117f1b4Smrg | ((rgba[i][GCOMP] & 0x7) << 2) 2847117f1b4Smrg | ((rgba[i][RCOMP] & 0x3) ); 2857117f1b4Smrg } 2867117f1b4Smrg } 2877117f1b4Smrg break; 2887117f1b4Smrg case GL_UNSIGNED_BYTE_2_3_3_REV: 2897117f1b4Smrg if (format == GL_RGB) { 2907117f1b4Smrg GLubyte *dst = (GLubyte *) destination; 2917117f1b4Smrg GLuint i; 2927117f1b4Smrg for (i = 0; i < n; i++) { 2937117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0x3) << 6) 2947117f1b4Smrg | ((rgba[i][GCOMP] & 0x7) << 3) 2957117f1b4Smrg | ((rgba[i][BCOMP] & 0x7) ); 2967117f1b4Smrg } 2977117f1b4Smrg } 2987117f1b4Smrg else { 2997117f1b4Smrg GLubyte *dst = (GLubyte *) destination; 3007117f1b4Smrg GLuint i; 3017117f1b4Smrg ASSERT(format == GL_BGR); 3027117f1b4Smrg for (i = 0; i < n; i++) { 3037117f1b4Smrg dst[i] = ((rgba[i][BCOMP] & 0x3) << 6) 3047117f1b4Smrg | ((rgba[i][GCOMP] & 0x7) << 3) 3057117f1b4Smrg | ((rgba[i][RCOMP] & 0x7) ); 3067117f1b4Smrg } 3077117f1b4Smrg } 3087117f1b4Smrg break; 3097117f1b4Smrg case GL_UNSIGNED_SHORT_5_6_5: 3107117f1b4Smrg if (format == GL_RGB) { 3117117f1b4Smrg GLushort *dst = (GLushort *) destination; 3127117f1b4Smrg GLuint i; 3137117f1b4Smrg for (i = 0; i < n; i++) { 3147117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11) 3157117f1b4Smrg | ((rgba[i][GCOMP] & 0x3f) << 5) 3167117f1b4Smrg | ((rgba[i][BCOMP] & 0x1f) ); 3177117f1b4Smrg } 3187117f1b4Smrg } 3197117f1b4Smrg else { 3207117f1b4Smrg GLushort *dst = (GLushort *) destination; 3217117f1b4Smrg GLuint i; 3227117f1b4Smrg ASSERT(format == GL_BGR); 3237117f1b4Smrg for (i = 0; i < n; i++) { 3247117f1b4Smrg dst[i] = ((rgba[i][BCOMP] & 0x1f) << 11) 3257117f1b4Smrg | ((rgba[i][GCOMP] & 0x3f) << 5) 3267117f1b4Smrg | ((rgba[i][RCOMP] & 0x1f) ); 3277117f1b4Smrg } 3287117f1b4Smrg } 3297117f1b4Smrg break; 3307117f1b4Smrg case GL_UNSIGNED_SHORT_5_6_5_REV: 3317117f1b4Smrg if (format == GL_RGB) { 3327117f1b4Smrg GLushort *dst = (GLushort *) destination; 3337117f1b4Smrg GLuint i; 3347117f1b4Smrg for (i = 0; i < n; i++) { 3357117f1b4Smrg dst[i] = ((rgba[i][BCOMP] & 0x1f) << 11) 3367117f1b4Smrg | ((rgba[i][GCOMP] & 0x3f) << 5) 3377117f1b4Smrg | ((rgba[i][RCOMP] & 0x1f) ); 3387117f1b4Smrg } 3397117f1b4Smrg } 3407117f1b4Smrg else { 3417117f1b4Smrg GLushort *dst = (GLushort *) destination; 3427117f1b4Smrg GLuint i; 3437117f1b4Smrg ASSERT(format == GL_BGR); 3447117f1b4Smrg for (i = 0; i < n; i++) { 3457117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11) 3467117f1b4Smrg | ((rgba[i][GCOMP] & 0x3f) << 5) 3477117f1b4Smrg | ((rgba[i][BCOMP] & 0x1f) ); 3487117f1b4Smrg } 3497117f1b4Smrg } 3507117f1b4Smrg break; 3517117f1b4Smrg case GL_UNSIGNED_SHORT_4_4_4_4: 3527117f1b4Smrg if (format == GL_RGBA) { 3537117f1b4Smrg GLushort *dst = (GLushort *) destination; 3547117f1b4Smrg GLuint i; 3557117f1b4Smrg for (i = 0; i < n; i++) { 3567117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0xf) << 12) 3577117f1b4Smrg | ((rgba[i][GCOMP] & 0xf) << 8) 3587117f1b4Smrg | ((rgba[i][BCOMP] & 0xf) << 4) 3597117f1b4Smrg | ((rgba[i][ACOMP] & 0xf) ); 3607117f1b4Smrg } 3617117f1b4Smrg } 3627117f1b4Smrg else if (format == GL_BGRA) { 3637117f1b4Smrg GLushort *dst = (GLushort *) destination; 3647117f1b4Smrg GLuint i; 3657117f1b4Smrg for (i = 0; i < n; i++) { 3667117f1b4Smrg dst[i] = ((rgba[i][BCOMP] & 0xf) << 12) 3677117f1b4Smrg | ((rgba[i][GCOMP] & 0xf) << 8) 3687117f1b4Smrg | ((rgba[i][RCOMP] & 0xf) << 4) 3697117f1b4Smrg | ((rgba[i][ACOMP] & 0xf) ); 3707117f1b4Smrg } 3717117f1b4Smrg } 3727117f1b4Smrg else { 3737117f1b4Smrg GLushort *dst = (GLushort *) destination; 3747117f1b4Smrg GLuint i; 3757117f1b4Smrg ASSERT(format == GL_ABGR_EXT); 3767117f1b4Smrg for (i = 0; i < n; i++) { 3777117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0xf) << 12) 3787117f1b4Smrg | ((rgba[i][BCOMP] & 0xf) << 8) 3797117f1b4Smrg | ((rgba[i][GCOMP] & 0xf) << 4) 3807117f1b4Smrg | ((rgba[i][RCOMP] & 0xf) ); 3817117f1b4Smrg } 3827117f1b4Smrg } 3837117f1b4Smrg break; 3847117f1b4Smrg case GL_UNSIGNED_SHORT_4_4_4_4_REV: 3857117f1b4Smrg if (format == GL_RGBA) { 3867117f1b4Smrg GLushort *dst = (GLushort *) destination; 3877117f1b4Smrg GLuint i; 3887117f1b4Smrg for (i = 0; i < n; i++) { 3897117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0xf) << 12) 3907117f1b4Smrg | ((rgba[i][BCOMP] & 0xf) << 8) 3917117f1b4Smrg | ((rgba[i][GCOMP] & 0xf) << 4) 3927117f1b4Smrg | ((rgba[i][RCOMP] & 0xf) ); 3937117f1b4Smrg } 3947117f1b4Smrg } 3957117f1b4Smrg else if (format == GL_BGRA) { 3967117f1b4Smrg GLushort *dst = (GLushort *) destination; 3977117f1b4Smrg GLuint i; 3987117f1b4Smrg for (i = 0; i < n; i++) { 3997117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0xf) << 12) 4007117f1b4Smrg | ((rgba[i][RCOMP] & 0xf) << 8) 4017117f1b4Smrg | ((rgba[i][GCOMP] & 0xf) << 4) 4027117f1b4Smrg | ((rgba[i][BCOMP] & 0xf) ); 4037117f1b4Smrg } 4047117f1b4Smrg } 4057117f1b4Smrg else { 4067117f1b4Smrg GLushort *dst = (GLushort *) destination; 4077117f1b4Smrg GLuint i; 4087117f1b4Smrg ASSERT(format == GL_ABGR_EXT); 4097117f1b4Smrg for (i = 0; i < n; i++) { 4107117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0xf) << 12) 4117117f1b4Smrg | ((rgba[i][GCOMP] & 0xf) << 8) 4127117f1b4Smrg | ((rgba[i][BCOMP] & 0xf) << 4) 4137117f1b4Smrg | ((rgba[i][ACOMP] & 0xf) ); 4147117f1b4Smrg } 4157117f1b4Smrg } 4167117f1b4Smrg break; 4177117f1b4Smrg case GL_UNSIGNED_SHORT_5_5_5_1: 4187117f1b4Smrg if (format == GL_RGBA) { 4197117f1b4Smrg GLushort *dst = (GLushort *) destination; 4207117f1b4Smrg GLuint i; 4217117f1b4Smrg for (i = 0; i < n; i++) { 4227117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11) 4237117f1b4Smrg | ((rgba[i][GCOMP] & 0x1f) << 6) 4247117f1b4Smrg | ((rgba[i][BCOMP] & 0x1f) << 1) 4257117f1b4Smrg | ((rgba[i][ACOMP] & 0x1) ); 4267117f1b4Smrg } 4277117f1b4Smrg } 4287117f1b4Smrg else if (format == GL_BGRA) { 4297117f1b4Smrg GLushort *dst = (GLushort *) destination; 4307117f1b4Smrg GLuint i; 4317117f1b4Smrg for (i = 0; i < n; i++) { 4327117f1b4Smrg dst[i] = ((rgba[i][BCOMP] & 0x1f) << 11) 4337117f1b4Smrg | ((rgba[i][GCOMP] & 0x1f) << 6) 4347117f1b4Smrg | ((rgba[i][RCOMP] & 0x1f) << 1) 4357117f1b4Smrg | ((rgba[i][ACOMP] & 0x1) ); 4367117f1b4Smrg } 4377117f1b4Smrg } 4387117f1b4Smrg else { 4397117f1b4Smrg GLushort *dst = (GLushort *) destination; 4407117f1b4Smrg GLuint i; 4417117f1b4Smrg ASSERT(format == GL_ABGR_EXT); 4427117f1b4Smrg for (i = 0; i < n; i++) { 4437117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0x1f) << 11) 4447117f1b4Smrg | ((rgba[i][BCOMP] & 0x1f) << 6) 4457117f1b4Smrg | ((rgba[i][GCOMP] & 0x1f) << 1) 4467117f1b4Smrg | ((rgba[i][RCOMP] & 0x1) ); 4477117f1b4Smrg } 4487117f1b4Smrg } 4497117f1b4Smrg break; 4507117f1b4Smrg case GL_UNSIGNED_SHORT_1_5_5_5_REV: 4517117f1b4Smrg if (format == GL_RGBA) { 4527117f1b4Smrg GLushort *dst = (GLushort *) destination; 4537117f1b4Smrg GLuint i; 4547117f1b4Smrg for (i = 0; i < n; i++) { 4557117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0x1f) << 11) 4567117f1b4Smrg | ((rgba[i][BCOMP] & 0x1f) << 6) 4577117f1b4Smrg | ((rgba[i][GCOMP] & 0x1f) << 1) 4587117f1b4Smrg | ((rgba[i][RCOMP] & 0x1) ); 4597117f1b4Smrg } 4607117f1b4Smrg } 4617117f1b4Smrg else if (format == GL_BGRA) { 4627117f1b4Smrg GLushort *dst = (GLushort *) destination; 4637117f1b4Smrg GLuint i; 4647117f1b4Smrg for (i = 0; i < n; i++) { 4657117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0x1f) << 11) 4667117f1b4Smrg | ((rgba[i][RCOMP] & 0x1f) << 6) 4677117f1b4Smrg | ((rgba[i][GCOMP] & 0x1f) << 1) 4687117f1b4Smrg | ((rgba[i][BCOMP] & 0x1) ); 4697117f1b4Smrg } 4707117f1b4Smrg } 4717117f1b4Smrg else { 4727117f1b4Smrg GLushort *dst = (GLushort *) destination; 4737117f1b4Smrg GLuint i; 4747117f1b4Smrg ASSERT(format == GL_ABGR_EXT); 4757117f1b4Smrg for (i = 0; i < n; i++) { 4767117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11) 4777117f1b4Smrg | ((rgba[i][GCOMP] & 0x1f) << 6) 4787117f1b4Smrg | ((rgba[i][BCOMP] & 0x1f) << 1) 4797117f1b4Smrg | ((rgba[i][ACOMP] & 0x1) ); 4807117f1b4Smrg } 4817117f1b4Smrg } 4827117f1b4Smrg break; 4837117f1b4Smrg case GL_UNSIGNED_INT_8_8_8_8: 4847117f1b4Smrg if (format == GL_RGBA) { 4857117f1b4Smrg GLuint *dst = (GLuint *) destination; 4867117f1b4Smrg GLuint i; 4877117f1b4Smrg for (i = 0; i < n; i++) { 4887117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0xff) << 24) 4897117f1b4Smrg | ((rgba[i][GCOMP] & 0xff) << 16) 4907117f1b4Smrg | ((rgba[i][BCOMP] & 0xff) << 8) 4917117f1b4Smrg | ((rgba[i][ACOMP] & 0xff) ); 4927117f1b4Smrg } 4937117f1b4Smrg } 4947117f1b4Smrg else if (format == GL_BGRA) { 4957117f1b4Smrg GLuint *dst = (GLuint *) destination; 4967117f1b4Smrg GLuint i; 4977117f1b4Smrg for (i = 0; i < n; i++) { 4987117f1b4Smrg dst[i] = ((rgba[i][BCOMP] & 0xff) << 24) 4997117f1b4Smrg | ((rgba[i][GCOMP] & 0xff) << 16) 5007117f1b4Smrg | ((rgba[i][RCOMP] & 0xff) << 8) 5017117f1b4Smrg | ((rgba[i][ACOMP] & 0xff) ); 5027117f1b4Smrg } 5037117f1b4Smrg } 5047117f1b4Smrg else { 5057117f1b4Smrg GLuint *dst = (GLuint *) destination; 5067117f1b4Smrg GLuint i; 5077117f1b4Smrg ASSERT(format == GL_ABGR_EXT); 5087117f1b4Smrg for (i = 0; i < n; i++) { 5097117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0xff) << 24) 5107117f1b4Smrg | ((rgba[i][BCOMP] & 0xff) << 16) 5117117f1b4Smrg | ((rgba[i][GCOMP] & 0xff) << 8) 5127117f1b4Smrg | ((rgba[i][RCOMP] & 0xff) ); 5137117f1b4Smrg } 5147117f1b4Smrg } 5157117f1b4Smrg break; 5167117f1b4Smrg case GL_UNSIGNED_INT_8_8_8_8_REV: 5177117f1b4Smrg if (format == GL_RGBA) { 5187117f1b4Smrg GLuint *dst = (GLuint *) destination; 5197117f1b4Smrg GLuint i; 5207117f1b4Smrg for (i = 0; i < n; i++) { 5217117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0xff) << 24) 5227117f1b4Smrg | ((rgba[i][BCOMP] & 0xff) << 16) 5237117f1b4Smrg | ((rgba[i][GCOMP] & 0xff) << 8) 5247117f1b4Smrg | ((rgba[i][RCOMP] & 0xff) ); 5257117f1b4Smrg } 5267117f1b4Smrg } 5277117f1b4Smrg else if (format == GL_BGRA) { 5287117f1b4Smrg GLuint *dst = (GLuint *) destination; 5297117f1b4Smrg GLuint i; 5307117f1b4Smrg for (i = 0; i < n; i++) { 5317117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0xff) << 24) 5327117f1b4Smrg | ((rgba[i][RCOMP] & 0xff) << 16) 5337117f1b4Smrg | ((rgba[i][GCOMP] & 0xff) << 8) 5347117f1b4Smrg | ((rgba[i][BCOMP] & 0xff) ); 5357117f1b4Smrg } 5367117f1b4Smrg } 5377117f1b4Smrg else { 5387117f1b4Smrg GLuint *dst = (GLuint *) destination; 5397117f1b4Smrg GLuint i; 5407117f1b4Smrg ASSERT(format == GL_ABGR_EXT); 5417117f1b4Smrg for (i = 0; i < n; i++) { 5427117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0xff) << 24) 5437117f1b4Smrg | ((rgba[i][GCOMP] & 0xff) << 16) 5447117f1b4Smrg | ((rgba[i][BCOMP] & 0xff) << 8) 5457117f1b4Smrg | ((rgba[i][ACOMP] & 0xff) ); 5467117f1b4Smrg } 5477117f1b4Smrg } 5487117f1b4Smrg break; 5497117f1b4Smrg case GL_UNSIGNED_INT_10_10_10_2: 5507117f1b4Smrg if (format == GL_RGBA) { 5517117f1b4Smrg GLuint *dst = (GLuint *) destination; 5527117f1b4Smrg GLuint i; 5537117f1b4Smrg for (i = 0; i < n; i++) { 5547117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0x3ff) << 22) 5557117f1b4Smrg | ((rgba[i][GCOMP] & 0x3ff) << 12) 5567117f1b4Smrg | ((rgba[i][BCOMP] & 0x3ff) << 2) 5577117f1b4Smrg | ((rgba[i][ACOMP] & 0x3) ); 5587117f1b4Smrg } 5597117f1b4Smrg } 5607117f1b4Smrg else if (format == GL_BGRA) { 5617117f1b4Smrg GLuint *dst = (GLuint *) destination; 5627117f1b4Smrg GLuint i; 5637117f1b4Smrg for (i = 0; i < n; i++) { 5647117f1b4Smrg dst[i] = ((rgba[i][BCOMP] & 0x3ff) << 22) 5657117f1b4Smrg | ((rgba[i][GCOMP] & 0x3ff) << 12) 5667117f1b4Smrg | ((rgba[i][RCOMP] & 0x3ff) << 2) 5677117f1b4Smrg | ((rgba[i][ACOMP] & 0x3) ); 5687117f1b4Smrg } 5697117f1b4Smrg } 5707117f1b4Smrg else { 5717117f1b4Smrg GLuint *dst = (GLuint *) destination; 5727117f1b4Smrg GLuint i; 5737117f1b4Smrg ASSERT(format == GL_ABGR_EXT); 5747117f1b4Smrg for (i = 0; i < n; i++) { 5757117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0x3ff) << 22) 5767117f1b4Smrg | ((rgba[i][BCOMP] & 0x3ff) << 12) 5777117f1b4Smrg | ((rgba[i][GCOMP] & 0x3ff) << 2) 5787117f1b4Smrg | ((rgba[i][RCOMP] & 0x3) ); 5797117f1b4Smrg } 5807117f1b4Smrg } 5817117f1b4Smrg break; 5827117f1b4Smrg case GL_UNSIGNED_INT_2_10_10_10_REV: 5837117f1b4Smrg if (format == GL_RGBA) { 5847117f1b4Smrg GLuint *dst = (GLuint *) destination; 5857117f1b4Smrg GLuint i; 5867117f1b4Smrg for (i = 0; i < n; i++) { 5877117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0x3ff) << 22) 5887117f1b4Smrg | ((rgba[i][BCOMP] & 0x3ff) << 12) 5897117f1b4Smrg | ((rgba[i][GCOMP] & 0x3ff) << 2) 5907117f1b4Smrg | ((rgba[i][RCOMP] & 0x3) ); 5917117f1b4Smrg } 5927117f1b4Smrg } 5937117f1b4Smrg else if (format == GL_BGRA) { 5947117f1b4Smrg GLuint *dst = (GLuint *) destination; 5957117f1b4Smrg GLuint i; 5967117f1b4Smrg for (i = 0; i < n; i++) { 5977117f1b4Smrg dst[i] = ((rgba[i][ACOMP] & 0x3ff) << 22) 5987117f1b4Smrg | ((rgba[i][RCOMP] & 0x3ff) << 12) 5997117f1b4Smrg | ((rgba[i][GCOMP] & 0x3ff) << 2) 6007117f1b4Smrg | ((rgba[i][BCOMP] & 0x3) ); 6017117f1b4Smrg } 6027117f1b4Smrg } 6037117f1b4Smrg else { 6047117f1b4Smrg GLuint *dst = (GLuint *) destination; 6057117f1b4Smrg GLuint i; 6067117f1b4Smrg ASSERT(format == GL_ABGR_EXT); 6077117f1b4Smrg for (i = 0; i < n; i++) { 6087117f1b4Smrg dst[i] = ((rgba[i][RCOMP] & 0x3ff) << 22) 6097117f1b4Smrg | ((rgba[i][GCOMP] & 0x3ff) << 12) 6107117f1b4Smrg | ((rgba[i][BCOMP] & 0x3ff) << 2) 6117117f1b4Smrg | ((rgba[i][ACOMP] & 0x3) ); 6127117f1b4Smrg } 6137117f1b4Smrg } 6147117f1b4Smrg break; 6157117f1b4Smrg default: 6167117f1b4Smrg _mesa_problem(ctx, "Bad type in pack_histogram"); 6177117f1b4Smrg } 6187117f1b4Smrg 6197117f1b4Smrg#undef PACK_MACRO 6207117f1b4Smrg} 6217117f1b4Smrg 6227117f1b4Smrg 6237117f1b4Smrg/* 6247117f1b4Smrg * Given an internalFormat token passed to glHistogram or glMinMax, 6257117f1b4Smrg * return the corresponding base format. 6267117f1b4Smrg * Return -1 if invalid token. 6277117f1b4Smrg */ 6287117f1b4Smrgstatic GLint 6297117f1b4Smrgbase_histogram_format( GLenum format ) 6307117f1b4Smrg{ 6317117f1b4Smrg switch (format) { 6327117f1b4Smrg case GL_ALPHA: 6337117f1b4Smrg case GL_ALPHA4: 6347117f1b4Smrg case GL_ALPHA8: 6357117f1b4Smrg case GL_ALPHA12: 6367117f1b4Smrg case GL_ALPHA16: 6377117f1b4Smrg return GL_ALPHA; 6387117f1b4Smrg case GL_LUMINANCE: 6397117f1b4Smrg case GL_LUMINANCE4: 6407117f1b4Smrg case GL_LUMINANCE8: 6417117f1b4Smrg case GL_LUMINANCE12: 6427117f1b4Smrg case GL_LUMINANCE16: 6437117f1b4Smrg return GL_LUMINANCE; 6447117f1b4Smrg case GL_LUMINANCE_ALPHA: 6457117f1b4Smrg case GL_LUMINANCE4_ALPHA4: 6467117f1b4Smrg case GL_LUMINANCE6_ALPHA2: 6477117f1b4Smrg case GL_LUMINANCE8_ALPHA8: 6487117f1b4Smrg case GL_LUMINANCE12_ALPHA4: 6497117f1b4Smrg case GL_LUMINANCE12_ALPHA12: 6507117f1b4Smrg case GL_LUMINANCE16_ALPHA16: 6517117f1b4Smrg return GL_LUMINANCE_ALPHA; 6527117f1b4Smrg case GL_RGB: 6537117f1b4Smrg case GL_R3_G3_B2: 6547117f1b4Smrg case GL_RGB4: 6557117f1b4Smrg case GL_RGB5: 6567117f1b4Smrg case GL_RGB8: 6577117f1b4Smrg case GL_RGB10: 6587117f1b4Smrg case GL_RGB12: 6597117f1b4Smrg case GL_RGB16: 6607117f1b4Smrg return GL_RGB; 6617117f1b4Smrg case GL_RGBA: 6627117f1b4Smrg case GL_RGBA2: 6637117f1b4Smrg case GL_RGBA4: 6647117f1b4Smrg case GL_RGB5_A1: 6657117f1b4Smrg case GL_RGBA8: 6667117f1b4Smrg case GL_RGB10_A2: 6677117f1b4Smrg case GL_RGBA12: 6687117f1b4Smrg case GL_RGBA16: 6697117f1b4Smrg return GL_RGBA; 6707117f1b4Smrg default: 6717117f1b4Smrg return -1; /* error */ 6727117f1b4Smrg } 6737117f1b4Smrg} 6747117f1b4Smrg 6757117f1b4Smrg 6767117f1b4Smrg 6777117f1b4Smrg/********************************************************************** 6787117f1b4Smrg * API functions 6797117f1b4Smrg */ 6807117f1b4Smrg 6817117f1b4Smrg 6827117f1b4Smrgvoid GLAPIENTRY 6837117f1b4Smrg_mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) 6847117f1b4Smrg{ 6857117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 6867117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 6877117f1b4Smrg 6887117f1b4Smrg if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { 6897117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmax"); 6907117f1b4Smrg return; 6917117f1b4Smrg } 6927117f1b4Smrg 6937117f1b4Smrg if (target != GL_MINMAX) { 6947117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinmax(target)"); 6957117f1b4Smrg return; 6967117f1b4Smrg } 6977117f1b4Smrg 6987117f1b4Smrg if (format != GL_RED && 6997117f1b4Smrg format != GL_GREEN && 7007117f1b4Smrg format != GL_BLUE && 7017117f1b4Smrg format != GL_ALPHA && 7027117f1b4Smrg format != GL_RGB && 7037117f1b4Smrg format != GL_BGR && 7047117f1b4Smrg format != GL_RGBA && 7057117f1b4Smrg format != GL_BGRA && 7067117f1b4Smrg format != GL_ABGR_EXT && 7077117f1b4Smrg format != GL_LUMINANCE && 7087117f1b4Smrg format != GL_LUMINANCE_ALPHA) { 7097117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinMax(format)"); 7107117f1b4Smrg } 7117117f1b4Smrg 7127117f1b4Smrg if (!_mesa_is_legal_format_and_type(ctx, format, type)) { 7137117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmax(format or type)"); 7147117f1b4Smrg return; 7157117f1b4Smrg } 7167117f1b4Smrg 7177117f1b4Smrg if (ctx->Pack.BufferObj->Name) { 7187117f1b4Smrg /* pack min/max values into a PBO */ 7197117f1b4Smrg GLubyte *buf; 7207117f1b4Smrg if (!_mesa_validate_pbo_access(1, &ctx->Pack, 2, 1, 1, 7217117f1b4Smrg format, type, values)) { 7227117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, 7237117f1b4Smrg "glGetMinMax(invalid PBO access)"); 7247117f1b4Smrg return; 7257117f1b4Smrg } 7267117f1b4Smrg buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, 7277117f1b4Smrg GL_WRITE_ONLY_ARB, 7287117f1b4Smrg ctx->Pack.BufferObj); 7297117f1b4Smrg if (!buf) { 7307117f1b4Smrg /* buffer is already mapped - that's an error */ 7317117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION,"glGetMinMax(PBO is mapped)"); 7327117f1b4Smrg return; 7337117f1b4Smrg } 7347117f1b4Smrg values = ADD_POINTERS(buf, values); 7357117f1b4Smrg } 7367117f1b4Smrg else if (!values) { 7377117f1b4Smrg /* not an error */ 7387117f1b4Smrg return; 7397117f1b4Smrg } 7407117f1b4Smrg 7417117f1b4Smrg { 7427117f1b4Smrg GLfloat minmax[2][4]; 7437117f1b4Smrg minmax[0][RCOMP] = CLAMP(ctx->MinMax.Min[RCOMP], 0.0F, 1.0F); 7447117f1b4Smrg minmax[0][GCOMP] = CLAMP(ctx->MinMax.Min[GCOMP], 0.0F, 1.0F); 7457117f1b4Smrg minmax[0][BCOMP] = CLAMP(ctx->MinMax.Min[BCOMP], 0.0F, 1.0F); 7467117f1b4Smrg minmax[0][ACOMP] = CLAMP(ctx->MinMax.Min[ACOMP], 0.0F, 1.0F); 7477117f1b4Smrg minmax[1][RCOMP] = CLAMP(ctx->MinMax.Max[RCOMP], 0.0F, 1.0F); 7487117f1b4Smrg minmax[1][GCOMP] = CLAMP(ctx->MinMax.Max[GCOMP], 0.0F, 1.0F); 7497117f1b4Smrg minmax[1][BCOMP] = CLAMP(ctx->MinMax.Max[BCOMP], 0.0F, 1.0F); 7507117f1b4Smrg minmax[1][ACOMP] = CLAMP(ctx->MinMax.Max[ACOMP], 0.0F, 1.0F); 7517117f1b4Smrg _mesa_pack_rgba_span_float(ctx, 2, minmax, 7527117f1b4Smrg format, type, values, &ctx->Pack, 0x0); 7537117f1b4Smrg } 7547117f1b4Smrg 7557117f1b4Smrg if (ctx->Pack.BufferObj->Name) { 7567117f1b4Smrg ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, 7577117f1b4Smrg ctx->Pack.BufferObj); 7587117f1b4Smrg } 7597117f1b4Smrg 7607117f1b4Smrg if (reset) { 7617117f1b4Smrg _mesa_ResetMinmax(GL_MINMAX); 7627117f1b4Smrg } 7637117f1b4Smrg} 7647117f1b4Smrg 7657117f1b4Smrg 7667117f1b4Smrgvoid GLAPIENTRY 7677117f1b4Smrg_mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) 7687117f1b4Smrg{ 7697117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 7707117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 7717117f1b4Smrg 7727117f1b4Smrg if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { 7737117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogram"); 7747117f1b4Smrg return; 7757117f1b4Smrg } 7767117f1b4Smrg 7777117f1b4Smrg if (target != GL_HISTOGRAM) { 7787117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogram(target)"); 7797117f1b4Smrg return; 7807117f1b4Smrg } 7817117f1b4Smrg 7827117f1b4Smrg if (format != GL_RED && 7837117f1b4Smrg format != GL_GREEN && 7847117f1b4Smrg format != GL_BLUE && 7857117f1b4Smrg format != GL_ALPHA && 7867117f1b4Smrg format != GL_RGB && 7877117f1b4Smrg format != GL_BGR && 7887117f1b4Smrg format != GL_RGBA && 7897117f1b4Smrg format != GL_BGRA && 7907117f1b4Smrg format != GL_ABGR_EXT && 7917117f1b4Smrg format != GL_LUMINANCE && 7927117f1b4Smrg format != GL_LUMINANCE_ALPHA) { 7937117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogram(format)"); 7947117f1b4Smrg } 7957117f1b4Smrg 7967117f1b4Smrg if (!_mesa_is_legal_format_and_type(ctx, format, type)) { 7977117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogram(format or type)"); 7987117f1b4Smrg return; 7997117f1b4Smrg } 8007117f1b4Smrg 8017117f1b4Smrg if (ctx->Pack.BufferObj->Name) { 8027117f1b4Smrg /* pack min/max values into a PBO */ 8037117f1b4Smrg GLubyte *buf; 8047117f1b4Smrg if (!_mesa_validate_pbo_access(1, &ctx->Pack, ctx->Histogram.Width, 1, 1, 8057117f1b4Smrg format, type, values)) { 8067117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, 8077117f1b4Smrg "glGetHistogram(invalid PBO access)"); 8087117f1b4Smrg return; 8097117f1b4Smrg } 8107117f1b4Smrg buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, 8117117f1b4Smrg GL_WRITE_ONLY_ARB, 8127117f1b4Smrg ctx->Pack.BufferObj); 8137117f1b4Smrg if (!buf) { 8147117f1b4Smrg /* buffer is already mapped - that's an error */ 8157117f1b4Smrg _mesa_error(ctx,GL_INVALID_OPERATION,"glGetHistogram(PBO is mapped)"); 8167117f1b4Smrg return; 8177117f1b4Smrg } 8187117f1b4Smrg values = ADD_POINTERS(buf, values); 8197117f1b4Smrg } 8207117f1b4Smrg else if (!values) { 8217117f1b4Smrg /* not an error */ 8227117f1b4Smrg return; 8237117f1b4Smrg } 8247117f1b4Smrg 8257117f1b4Smrg pack_histogram(ctx, ctx->Histogram.Width, 8267117f1b4Smrg (CONST GLuint (*)[4]) ctx->Histogram.Count, 8277117f1b4Smrg format, type, values, &ctx->Pack); 8287117f1b4Smrg 8297117f1b4Smrg if (ctx->Pack.BufferObj->Name) { 8307117f1b4Smrg ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, 8317117f1b4Smrg ctx->Pack.BufferObj); 8327117f1b4Smrg } 8337117f1b4Smrg 8347117f1b4Smrg if (reset) { 8357117f1b4Smrg GLuint i; 8367117f1b4Smrg for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { 8377117f1b4Smrg ctx->Histogram.Count[i][0] = 0; 8387117f1b4Smrg ctx->Histogram.Count[i][1] = 0; 8397117f1b4Smrg ctx->Histogram.Count[i][2] = 0; 8407117f1b4Smrg ctx->Histogram.Count[i][3] = 0; 8417117f1b4Smrg } 8427117f1b4Smrg } 8437117f1b4Smrg} 8447117f1b4Smrg 8457117f1b4Smrg 8467117f1b4Smrgvoid GLAPIENTRY 8477117f1b4Smrg_mesa_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) 8487117f1b4Smrg{ 8497117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 8507117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END(ctx); 8517117f1b4Smrg 8527117f1b4Smrg if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { 8537117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameterfv"); 8547117f1b4Smrg return; 8557117f1b4Smrg } 8567117f1b4Smrg 8577117f1b4Smrg if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { 8587117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameterfv(target)"); 8597117f1b4Smrg return; 8607117f1b4Smrg } 8617117f1b4Smrg 8627117f1b4Smrg switch (pname) { 8637117f1b4Smrg case GL_HISTOGRAM_WIDTH: 8647117f1b4Smrg *params = (GLfloat) ctx->Histogram.Width; 8657117f1b4Smrg break; 8667117f1b4Smrg case GL_HISTOGRAM_FORMAT: 8677117f1b4Smrg *params = (GLfloat) ctx->Histogram.Format; 8687117f1b4Smrg break; 8697117f1b4Smrg case GL_HISTOGRAM_RED_SIZE: 8707117f1b4Smrg *params = (GLfloat) ctx->Histogram.RedSize; 8717117f1b4Smrg break; 8727117f1b4Smrg case GL_HISTOGRAM_GREEN_SIZE: 8737117f1b4Smrg *params = (GLfloat) ctx->Histogram.GreenSize; 8747117f1b4Smrg break; 8757117f1b4Smrg case GL_HISTOGRAM_BLUE_SIZE: 8767117f1b4Smrg *params = (GLfloat) ctx->Histogram.BlueSize; 8777117f1b4Smrg break; 8787117f1b4Smrg case GL_HISTOGRAM_ALPHA_SIZE: 8797117f1b4Smrg *params = (GLfloat) ctx->Histogram.AlphaSize; 8807117f1b4Smrg break; 8817117f1b4Smrg case GL_HISTOGRAM_LUMINANCE_SIZE: 8827117f1b4Smrg *params = (GLfloat) ctx->Histogram.LuminanceSize; 8837117f1b4Smrg break; 8847117f1b4Smrg case GL_HISTOGRAM_SINK: 8857117f1b4Smrg *params = (GLfloat) ctx->Histogram.Sink; 8867117f1b4Smrg break; 8877117f1b4Smrg default: 8887117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameterfv(pname)"); 8897117f1b4Smrg } 8907117f1b4Smrg} 8917117f1b4Smrg 8927117f1b4Smrg 8937117f1b4Smrgvoid GLAPIENTRY 8947117f1b4Smrg_mesa_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) 8957117f1b4Smrg{ 8967117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 8977117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END(ctx); 8987117f1b4Smrg 8997117f1b4Smrg if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { 9007117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameteriv"); 9017117f1b4Smrg return; 9027117f1b4Smrg } 9037117f1b4Smrg 9047117f1b4Smrg if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { 9057117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameteriv(target)"); 9067117f1b4Smrg return; 9077117f1b4Smrg } 9087117f1b4Smrg 9097117f1b4Smrg switch (pname) { 9107117f1b4Smrg case GL_HISTOGRAM_WIDTH: 9117117f1b4Smrg *params = (GLint) ctx->Histogram.Width; 9127117f1b4Smrg break; 9137117f1b4Smrg case GL_HISTOGRAM_FORMAT: 9147117f1b4Smrg *params = (GLint) ctx->Histogram.Format; 9157117f1b4Smrg break; 9167117f1b4Smrg case GL_HISTOGRAM_RED_SIZE: 9177117f1b4Smrg *params = (GLint) ctx->Histogram.RedSize; 9187117f1b4Smrg break; 9197117f1b4Smrg case GL_HISTOGRAM_GREEN_SIZE: 9207117f1b4Smrg *params = (GLint) ctx->Histogram.GreenSize; 9217117f1b4Smrg break; 9227117f1b4Smrg case GL_HISTOGRAM_BLUE_SIZE: 9237117f1b4Smrg *params = (GLint) ctx->Histogram.BlueSize; 9247117f1b4Smrg break; 9257117f1b4Smrg case GL_HISTOGRAM_ALPHA_SIZE: 9267117f1b4Smrg *params = (GLint) ctx->Histogram.AlphaSize; 9277117f1b4Smrg break; 9287117f1b4Smrg case GL_HISTOGRAM_LUMINANCE_SIZE: 9297117f1b4Smrg *params = (GLint) ctx->Histogram.LuminanceSize; 9307117f1b4Smrg break; 9317117f1b4Smrg case GL_HISTOGRAM_SINK: 9327117f1b4Smrg *params = (GLint) ctx->Histogram.Sink; 9337117f1b4Smrg break; 9347117f1b4Smrg default: 9357117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameteriv(pname)"); 9367117f1b4Smrg } 9377117f1b4Smrg} 9387117f1b4Smrg 9397117f1b4Smrg 9407117f1b4Smrgvoid GLAPIENTRY 9417117f1b4Smrg_mesa_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) 9427117f1b4Smrg{ 9437117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 9447117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END(ctx); 9457117f1b4Smrg 9467117f1b4Smrg if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { 9477117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameterfv"); 9487117f1b4Smrg return; 9497117f1b4Smrg } 9507117f1b4Smrg if (target != GL_MINMAX) { 9517117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinmaxParameterfv(target)"); 9527117f1b4Smrg return; 9537117f1b4Smrg } 9547117f1b4Smrg if (pname == GL_MINMAX_FORMAT) { 9557117f1b4Smrg *params = (GLfloat) ctx->MinMax.Format; 9567117f1b4Smrg } 9577117f1b4Smrg else if (pname == GL_MINMAX_SINK) { 9587117f1b4Smrg *params = (GLfloat) ctx->MinMax.Sink; 9597117f1b4Smrg } 9607117f1b4Smrg else { 9617117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinMaxParameterfv(pname)"); 9627117f1b4Smrg } 9637117f1b4Smrg} 9647117f1b4Smrg 9657117f1b4Smrg 9667117f1b4Smrgvoid GLAPIENTRY 9677117f1b4Smrg_mesa_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) 9687117f1b4Smrg{ 9697117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 9707117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END(ctx); 9717117f1b4Smrg 9727117f1b4Smrg if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { 9737117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameteriv"); 9747117f1b4Smrg return; 9757117f1b4Smrg } 9767117f1b4Smrg if (target != GL_MINMAX) { 9777117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinmaxParameteriv(target)"); 9787117f1b4Smrg return; 9797117f1b4Smrg } 9807117f1b4Smrg if (pname == GL_MINMAX_FORMAT) { 9817117f1b4Smrg *params = (GLint) ctx->MinMax.Format; 9827117f1b4Smrg } 9837117f1b4Smrg else if (pname == GL_MINMAX_SINK) { 9847117f1b4Smrg *params = (GLint) ctx->MinMax.Sink; 9857117f1b4Smrg } 9867117f1b4Smrg else { 9877117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinMaxParameteriv(pname)"); 9887117f1b4Smrg } 9897117f1b4Smrg} 9907117f1b4Smrg 9917117f1b4Smrg 9927117f1b4Smrgvoid GLAPIENTRY 9937117f1b4Smrg_mesa_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink) 9947117f1b4Smrg{ 9957117f1b4Smrg GLuint i; 9967117f1b4Smrg GLboolean error = GL_FALSE; 9977117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 9987117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* sideeffects */ 9997117f1b4Smrg 10007117f1b4Smrg if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { 10017117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glHistogram"); 10027117f1b4Smrg return; 10037117f1b4Smrg } 10047117f1b4Smrg 10057117f1b4Smrg if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { 10067117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glHistogram(target)"); 10077117f1b4Smrg return; 10087117f1b4Smrg } 10097117f1b4Smrg 10107117f1b4Smrg if (width < 0 || width > HISTOGRAM_TABLE_SIZE) { 10117117f1b4Smrg if (target == GL_PROXY_HISTOGRAM) { 10127117f1b4Smrg error = GL_TRUE; 10137117f1b4Smrg } 10147117f1b4Smrg else { 10157117f1b4Smrg if (width < 0) 10167117f1b4Smrg _mesa_error(ctx, GL_INVALID_VALUE, "glHistogram(width)"); 10177117f1b4Smrg else 10187117f1b4Smrg _mesa_error(ctx, GL_TABLE_TOO_LARGE, "glHistogram(width)"); 10197117f1b4Smrg return; 10207117f1b4Smrg } 10217117f1b4Smrg } 10227117f1b4Smrg 10237117f1b4Smrg if (width != 0 && _mesa_bitcount(width) != 1) { 10247117f1b4Smrg if (target == GL_PROXY_HISTOGRAM) { 10257117f1b4Smrg error = GL_TRUE; 10267117f1b4Smrg } 10277117f1b4Smrg else { 10287117f1b4Smrg _mesa_error(ctx, GL_INVALID_VALUE, "glHistogram(width)"); 10297117f1b4Smrg return; 10307117f1b4Smrg } 10317117f1b4Smrg } 10327117f1b4Smrg 10337117f1b4Smrg if (base_histogram_format(internalFormat) < 0) { 10347117f1b4Smrg if (target == GL_PROXY_HISTOGRAM) { 10357117f1b4Smrg error = GL_TRUE; 10367117f1b4Smrg } 10377117f1b4Smrg else { 10387117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glHistogram(internalFormat)"); 10397117f1b4Smrg return; 10407117f1b4Smrg } 10417117f1b4Smrg } 10427117f1b4Smrg 10437117f1b4Smrg /* reset histograms */ 10447117f1b4Smrg for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { 10457117f1b4Smrg ctx->Histogram.Count[i][0] = 0; 10467117f1b4Smrg ctx->Histogram.Count[i][1] = 0; 10477117f1b4Smrg ctx->Histogram.Count[i][2] = 0; 10487117f1b4Smrg ctx->Histogram.Count[i][3] = 0; 10497117f1b4Smrg } 10507117f1b4Smrg 10517117f1b4Smrg if (error) { 10527117f1b4Smrg ctx->Histogram.Width = 0; 10537117f1b4Smrg ctx->Histogram.Format = 0; 10547117f1b4Smrg ctx->Histogram.RedSize = 0; 10557117f1b4Smrg ctx->Histogram.GreenSize = 0; 10567117f1b4Smrg ctx->Histogram.BlueSize = 0; 10577117f1b4Smrg ctx->Histogram.AlphaSize = 0; 10587117f1b4Smrg ctx->Histogram.LuminanceSize = 0; 10597117f1b4Smrg } 10607117f1b4Smrg else { 10617117f1b4Smrg ctx->Histogram.Width = width; 10627117f1b4Smrg ctx->Histogram.Format = internalFormat; 10637117f1b4Smrg ctx->Histogram.Sink = sink; 10647117f1b4Smrg ctx->Histogram.RedSize = 8 * sizeof(GLuint); 10657117f1b4Smrg ctx->Histogram.GreenSize = 8 * sizeof(GLuint); 10667117f1b4Smrg ctx->Histogram.BlueSize = 8 * sizeof(GLuint); 10677117f1b4Smrg ctx->Histogram.AlphaSize = 8 * sizeof(GLuint); 10687117f1b4Smrg ctx->Histogram.LuminanceSize = 8 * sizeof(GLuint); 10697117f1b4Smrg } 10707117f1b4Smrg 10717117f1b4Smrg ctx->NewState |= _NEW_PIXEL; 10727117f1b4Smrg} 10737117f1b4Smrg 10747117f1b4Smrg 10757117f1b4Smrgvoid GLAPIENTRY 10767117f1b4Smrg_mesa_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) 10777117f1b4Smrg{ 10787117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 10797117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END(ctx); 10807117f1b4Smrg 10817117f1b4Smrg if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { 10827117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glMinmax"); 10837117f1b4Smrg return; 10847117f1b4Smrg } 10857117f1b4Smrg 10867117f1b4Smrg if (target != GL_MINMAX) { 10877117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glMinMax(target)"); 10887117f1b4Smrg return; 10897117f1b4Smrg } 10907117f1b4Smrg 10917117f1b4Smrg if (base_histogram_format(internalFormat) < 0) { 10927117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glMinMax(internalFormat)"); 10937117f1b4Smrg return; 10947117f1b4Smrg } 10957117f1b4Smrg 10967117f1b4Smrg if (ctx->MinMax.Sink == sink) 10977117f1b4Smrg return; 10987117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PIXEL); 10997117f1b4Smrg ctx->MinMax.Sink = sink; 11007117f1b4Smrg} 11017117f1b4Smrg 11027117f1b4Smrg 11037117f1b4Smrgvoid GLAPIENTRY 11047117f1b4Smrg_mesa_ResetHistogram(GLenum target) 11057117f1b4Smrg{ 11067117f1b4Smrg GLuint i; 11077117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 11087117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* sideeffects */ 11097117f1b4Smrg 11107117f1b4Smrg if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { 11117117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glResetHistogram"); 11127117f1b4Smrg return; 11137117f1b4Smrg } 11147117f1b4Smrg 11157117f1b4Smrg if (target != GL_HISTOGRAM) { 11167117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glResetHistogram(target)"); 11177117f1b4Smrg return; 11187117f1b4Smrg } 11197117f1b4Smrg 11207117f1b4Smrg for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { 11217117f1b4Smrg ctx->Histogram.Count[i][0] = 0; 11227117f1b4Smrg ctx->Histogram.Count[i][1] = 0; 11237117f1b4Smrg ctx->Histogram.Count[i][2] = 0; 11247117f1b4Smrg ctx->Histogram.Count[i][3] = 0; 11257117f1b4Smrg } 11267117f1b4Smrg 11277117f1b4Smrg ctx->NewState |= _NEW_PIXEL; 11287117f1b4Smrg} 11297117f1b4Smrg 11307117f1b4Smrg 11317117f1b4Smrgvoid GLAPIENTRY 11327117f1b4Smrg_mesa_ResetMinmax(GLenum target) 11337117f1b4Smrg{ 11347117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 11357117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 11367117f1b4Smrg 11377117f1b4Smrg if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { 11387117f1b4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glResetMinmax"); 11397117f1b4Smrg return; 11407117f1b4Smrg } 11417117f1b4Smrg 11427117f1b4Smrg if (target != GL_MINMAX) { 11437117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glResetMinMax(target)"); 11447117f1b4Smrg return; 11457117f1b4Smrg } 11467117f1b4Smrg 11477117f1b4Smrg ctx->MinMax.Min[RCOMP] = 1000; ctx->MinMax.Max[RCOMP] = -1000; 11487117f1b4Smrg ctx->MinMax.Min[GCOMP] = 1000; ctx->MinMax.Max[GCOMP] = -1000; 11497117f1b4Smrg ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000; 11507117f1b4Smrg ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000; 11517117f1b4Smrg ctx->NewState |= _NEW_PIXEL; 11527117f1b4Smrg} 11537117f1b4Smrg 11547117f1b4Smrg 11557117f1b4Smrg 11567117f1b4Smrg/**********************************************************************/ 11577117f1b4Smrg/***** Initialization *****/ 11587117f1b4Smrg/**********************************************************************/ 11597117f1b4Smrg 11607117f1b4Smrgvoid _mesa_init_histogram( GLcontext * ctx ) 11617117f1b4Smrg{ 11627117f1b4Smrg int i; 11637117f1b4Smrg 11647117f1b4Smrg /* Histogram group */ 11657117f1b4Smrg ctx->Histogram.Width = 0; 11667117f1b4Smrg ctx->Histogram.Format = GL_RGBA; 11677117f1b4Smrg ctx->Histogram.Sink = GL_FALSE; 11687117f1b4Smrg ctx->Histogram.RedSize = 0; 11697117f1b4Smrg ctx->Histogram.GreenSize = 0; 11707117f1b4Smrg ctx->Histogram.BlueSize = 0; 11717117f1b4Smrg ctx->Histogram.AlphaSize = 0; 11727117f1b4Smrg ctx->Histogram.LuminanceSize = 0; 11737117f1b4Smrg for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { 11747117f1b4Smrg ctx->Histogram.Count[i][0] = 0; 11757117f1b4Smrg ctx->Histogram.Count[i][1] = 0; 11767117f1b4Smrg ctx->Histogram.Count[i][2] = 0; 11777117f1b4Smrg ctx->Histogram.Count[i][3] = 0; 11787117f1b4Smrg } 11797117f1b4Smrg 11807117f1b4Smrg /* Min/Max group */ 11817117f1b4Smrg ctx->MinMax.Format = GL_RGBA; 11827117f1b4Smrg ctx->MinMax.Sink = GL_FALSE; 11837117f1b4Smrg ctx->MinMax.Min[RCOMP] = 1000; ctx->MinMax.Max[RCOMP] = -1000; 11847117f1b4Smrg ctx->MinMax.Min[GCOMP] = 1000; ctx->MinMax.Max[GCOMP] = -1000; 11857117f1b4Smrg ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000; 11867117f1b4Smrg ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000; 11877117f1b4Smrg} 1188