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_bitmap.c
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  7.1
00004  *
00005  * Copyright (C) 1999-2008  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 
00031 #include "main/glheader.h"
00032 #include "main/bufferobj.h"
00033 #include "main/image.h"
00034 #include "main/macros.h"
00035 #include "main/pixel.h"
00036 
00037 #include "s_context.h"
00038 #include "s_span.h"
00039 
00040 
00041 
00047 void
00048 _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
00049         GLsizei width, GLsizei height,
00050         const struct gl_pixelstore_attrib *unpack,
00051         const GLubyte *bitmap )
00052 {
00053    SWcontext *swrast = SWRAST_CONTEXT(ctx);
00054    GLint row, col;
00055    GLuint count = 0;
00056    SWspan span;
00057 
00058    ASSERT(ctx->RenderMode == GL_RENDER);
00059 
00060    bitmap = _mesa_map_bitmap_pbo(ctx, unpack, bitmap);
00061    if (!bitmap)
00062       return;
00063 
00064    RENDER_START(swrast,ctx);
00065 
00066    if (SWRAST_CONTEXT(ctx)->NewState)
00067       _swrast_validate_derived( ctx );
00068 
00069    INIT_SPAN(span, GL_BITMAP);
00070    span.end = width;
00071    span.arrayMask = SPAN_XY;
00072    _swrast_span_default_attribs(ctx, &span);
00073 
00074    for (row = 0; row < height; row++) {
00075       const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
00076                  bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
00077 
00078       if (unpack->LsbFirst) {
00079          /* Lsb first */
00080          GLubyte mask = 1U << (unpack->SkipPixels & 0x7);
00081          for (col = 0; col < width; col++) {
00082             if (*src & mask) {
00083                span.array->x[count] = px + col;
00084                span.array->y[count] = py + row;
00085                count++;
00086             }
00087             if (mask == 128U) {
00088                src++;
00089                mask = 1U;
00090             }
00091             else {
00092                mask = mask << 1;
00093             }
00094          }
00095 
00096          /* get ready for next row */
00097          if (mask != 1)
00098             src++;
00099       }
00100       else {
00101          /* Msb first */
00102          GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
00103          for (col = 0; col < width; col++) {
00104             if (*src & mask) {
00105                span.array->x[count] = px + col;
00106                span.array->y[count] = py + row;
00107                count++;
00108             }
00109             if (mask == 1U) {
00110                src++;
00111                mask = 128U;
00112             }
00113             else {
00114                mask = mask >> 1;
00115             }
00116          }
00117 
00118          /* get ready for next row */
00119          if (mask != 128)
00120             src++;
00121       }
00122 
00123       if (count + width >= MAX_WIDTH || row + 1 == height) {
00124          /* flush the span */
00125          span.end = count;
00126          if (ctx->Visual.rgbMode)
00127             _swrast_write_rgba_span(ctx, &span);
00128          else
00129             _swrast_write_index_span(ctx, &span);
00130          span.end = 0;
00131          count = 0;
00132       }
00133    }
00134 
00135    RENDER_FINISH(swrast,ctx);
00136 
00137    _mesa_unmap_bitmap_pbo(ctx, unpack);
00138 }
00139 
00140 
00141 #if 0
00142 /*
00143  * XXX this is another way to implement Bitmap.  Use horizontal runs of
00144  * fragments, initializing the mask array to indicate which fragments to
00145  * draw or skip.
00146  */
00147 void
00148 _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
00149         GLsizei width, GLsizei height,
00150         const struct gl_pixelstore_attrib *unpack,
00151         const GLubyte *bitmap )
00152 {
00153    SWcontext *swrast = SWRAST_CONTEXT(ctx);
00154    GLint row, col;
00155    SWspan span;
00156 
00157    ASSERT(ctx->RenderMode == GL_RENDER);
00158    ASSERT(bitmap);
00159 
00160    RENDER_START(swrast,ctx);
00161 
00162    if (SWRAST_CONTEXT(ctx)->NewState)
00163       _swrast_validate_derived( ctx );
00164 
00165    INIT_SPAN(span, GL_BITMAP);
00166    span.end = width;
00167    span.arrayMask = SPAN_MASK;
00168    _swrast_span_default_attribs(ctx, &span);
00169 
00170    /*span.arrayMask |= SPAN_MASK;*/  /* we'll init span.mask[] */
00171    span.x = px;
00172    span.y = py;
00173    /*span.end = width;*/
00174 
00175    for (row=0; row<height; row++, span.y++) {
00176       const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
00177                  bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
00178 
00179       if (unpack->LsbFirst) {
00180          /* Lsb first */
00181          GLubyte mask = 1U << (unpack->SkipPixels & 0x7);
00182          for (col=0; col<width; col++) {
00183             span.array->mask[col] = (*src & mask) ? GL_TRUE : GL_FALSE;
00184             if (mask == 128U) {
00185                src++;
00186                mask = 1U;
00187             }
00188             else {
00189                mask = mask << 1;
00190             }
00191          }
00192 
00193          if (ctx->Visual.rgbMode)
00194             _swrast_write_rgba_span(ctx, &span);
00195          else
00196         _swrast_write_index_span(ctx, &span);
00197 
00198          /* get ready for next row */
00199          if (mask != 1)
00200             src++;
00201       }
00202       else {
00203          /* Msb first */
00204          GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
00205          for (col=0; col<width; col++) {
00206             span.array->mask[col] = (*src & mask) ? GL_TRUE : GL_FALSE;
00207             if (mask == 1U) {
00208                src++;
00209                mask = 128U;
00210             }
00211             else {
00212                mask = mask >> 1;
00213             }
00214          }
00215 
00216          if (ctx->Visual.rgbMode)
00217             _swrast_write_rgba_span(ctx, &span);
00218          else
00219             _swrast_write_index_span(ctx, &span);
00220 
00221          /* get ready for next row */
00222          if (mask != 128)
00223             src++;
00224       }
00225    }
00226 
00227    RENDER_FINISH(swrast,ctx);
00228 }
00229 #endif

Generated on Sun May 27 2012 04:20:42 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.