ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

s_imaging.c
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  6.5
00004  *
00005  * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a
00008  * copy of this software and associated documentation files (the "Software"),
00009  * to deal in the Software without restriction, including without limitation
00010  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011  * and/or sell copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following conditions:
00013  *
00014  * The above copyright notice and this permission notice shall be included
00015  * in all copies or substantial portions of the Software.
00016  *
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00018  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00020  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  */
00024 
00025 /* KW:  Moved these here to remove knowledge of swrast from core mesa.
00026  * Should probably pull the entire software implementation of these
00027  * extensions into either swrast or a sister module.  
00028  */
00029 
00030 #include "main/glheader.h"
00031 #include "main/colortab.h"
00032 #include "main/convolve.h"
00033 #include "s_context.h"
00034 #include "s_span.h"
00035 
00036 
00037 void
00038 _swrast_CopyColorTable( GLcontext *ctx, 
00039             GLenum target, GLenum internalformat,
00040             GLint x, GLint y, GLsizei width)
00041 {
00042    SWcontext *swrast = SWRAST_CONTEXT(ctx);
00043    GLchan data[MAX_WIDTH][4];
00044    struct gl_buffer_object *bufferSave;
00045 
00046    if (!ctx->ReadBuffer->_ColorReadBuffer) {
00047       /* no readbuffer - OK */
00048       return;
00049    }
00050 
00051    if (width > MAX_WIDTH)
00052       width = MAX_WIDTH;
00053 
00054    RENDER_START( swrast, ctx );
00055 
00056    /* read the data from framebuffer */
00057    _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
00058                            width, x, y, CHAN_TYPE, data );
00059 
00060    RENDER_FINISH(swrast,ctx);
00061 
00062    /* save PBO binding */
00063    bufferSave = ctx->Unpack.BufferObj;
00064    ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
00065 
00066    _mesa_ColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data);
00067 
00068    /* restore PBO binding */
00069    ctx->Unpack.BufferObj = bufferSave;
00070 }
00071 
00072 
00073 void
00074 _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
00075                GLint x, GLint y, GLsizei width)
00076 {
00077    SWcontext *swrast = SWRAST_CONTEXT(ctx);
00078    GLchan data[MAX_WIDTH][4];
00079    struct gl_buffer_object *bufferSave;
00080 
00081    if (!ctx->ReadBuffer->_ColorReadBuffer) {
00082       /* no readbuffer - OK */
00083       return;
00084    }
00085 
00086    if (width > MAX_WIDTH)
00087       width = MAX_WIDTH;
00088 
00089    RENDER_START( swrast, ctx );
00090 
00091    /* read the data from framebuffer */
00092    _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
00093                            width, x, y, CHAN_TYPE, data );
00094 
00095    RENDER_FINISH(swrast,ctx);
00096 
00097    /* save PBO binding */
00098    bufferSave = ctx->Unpack.BufferObj;
00099    ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
00100 
00101    _mesa_ColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data);
00102 
00103    /* restore PBO binding */
00104    ctx->Unpack.BufferObj = bufferSave;
00105 }
00106 
00107 
00108 void
00109 _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, 
00110                 GLenum internalFormat, 
00111                 GLint x, GLint y, GLsizei width)
00112 {
00113    SWcontext *swrast = SWRAST_CONTEXT(ctx);
00114    GLchan rgba[MAX_CONVOLUTION_WIDTH][4];
00115    struct gl_buffer_object *bufferSave;
00116 
00117    if (!ctx->ReadBuffer->_ColorReadBuffer) {
00118       /* no readbuffer - OK */
00119       return;
00120    }
00121 
00122    RENDER_START( swrast, ctx );
00123 
00124    /* read the data from framebuffer */
00125    _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
00126                            width, x, y, CHAN_TYPE, rgba );
00127    
00128    RENDER_FINISH( swrast, ctx );
00129 
00130    /* save PBO binding */
00131    bufferSave = ctx->Unpack.BufferObj;
00132    ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
00133 
00134    /* store as convolution filter */
00135    _mesa_ConvolutionFilter1D(target, internalFormat, width,
00136                              GL_RGBA, CHAN_TYPE, rgba);
00137 
00138    /* restore PBO binding */
00139    ctx->Unpack.BufferObj = bufferSave;
00140 }
00141 
00142 
00143 void
00144 _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, 
00145                 GLenum internalFormat, 
00146                 GLint x, GLint y, GLsizei width, GLsizei height)
00147 {
00148    SWcontext *swrast = SWRAST_CONTEXT(ctx);
00149    struct gl_pixelstore_attrib packSave;
00150    GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4];
00151    GLint i;
00152    struct gl_buffer_object *bufferSave;
00153 
00154    if (!ctx->ReadBuffer->_ColorReadBuffer) {
00155       /* no readbuffer - OK */
00156       return;
00157    }
00158 
00159    RENDER_START(swrast,ctx);
00160    
00161    /* read pixels from framebuffer */
00162    for (i = 0; i < height; i++) {
00163       _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
00164                               width, x, y + i, CHAN_TYPE, rgba[i] );
00165    }
00166 
00167    RENDER_FINISH(swrast,ctx);
00168 
00169    /*
00170     * HACK: save & restore context state so we can store this as a
00171     * convolution filter via the GL api.  Doesn't call any callbacks
00172     * hanging off ctx->Unpack statechanges.
00173     */
00174 
00175    packSave = ctx->Unpack;  /* save pixel packing params */
00176 
00177    ctx->Unpack.Alignment = 1;
00178    ctx->Unpack.RowLength = MAX_CONVOLUTION_WIDTH;
00179    ctx->Unpack.SkipPixels = 0;
00180    ctx->Unpack.SkipRows = 0;
00181    ctx->Unpack.ImageHeight = 0;
00182    ctx->Unpack.SkipImages = 0;
00183    ctx->Unpack.SwapBytes = GL_FALSE;
00184    ctx->Unpack.LsbFirst = GL_FALSE;
00185    ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
00186    ctx->NewState |= _NEW_PACKUNPACK;
00187 
00188    /* save PBO binding */
00189    bufferSave = ctx->Unpack.BufferObj;
00190    ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
00191 
00192    _mesa_ConvolutionFilter2D(target, internalFormat, width, height,
00193                              GL_RGBA, CHAN_TYPE, rgba);
00194 
00195    /* restore PBO binding */
00196    ctx->Unpack.BufferObj = bufferSave;
00197 
00198    ctx->Unpack = packSave;  /* restore pixel packing params */
00199    ctx->NewState |= _NEW_PACKUNPACK; 
00200 }

Generated on Sat May 26 2012 04:19:32 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.