i915_surface.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  * 
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  * 
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  * 
00026  **************************************************************************/
00027 
00028 #include "i915_context.h"
00029 #include "i915_blit.h"
00030 #include "i915_state.h"
00031 #include "pipe/p_defines.h"
00032 #include "pipe/p_inlines.h"
00033 #include "pipe/p_inlines.h"
00034 #include "pipe/p_winsys.h"
00035 #include "util/u_tile.h"
00036 #include "util/u_rect.h"
00037 
00038 
00039 /* Assumes all values are within bounds -- no checking at this level -
00040  * do it higher up if required.
00041  */
00042 static void
00043 i915_surface_copy(struct pipe_context *pipe,
00044                   boolean do_flip,
00045                   struct pipe_surface *dst,
00046                   unsigned dstx, unsigned dsty,
00047                   struct pipe_surface *src,
00048                   unsigned srcx, unsigned srcy, unsigned width, unsigned height)
00049 {
00050    assert( dst != src );
00051    assert( dst->block.size == src->block.size );
00052    assert( dst->block.width == src->block.height );
00053    assert( dst->block.height == src->block.height );
00054 
00055    if (0) {
00056       void *dst_map = pipe->screen->surface_map( pipe->screen,
00057                                                  dst,
00058                                                  PIPE_BUFFER_USAGE_CPU_WRITE );
00059       
00060       const void *src_map = pipe->screen->surface_map( pipe->screen,
00061                                                        src,
00062                                                        PIPE_BUFFER_USAGE_CPU_READ );
00063       
00064       pipe_copy_rect(dst_map,
00065                      &dst->block,
00066                      dst->stride,
00067                      dstx, dsty,
00068                      width, height,
00069                      src_map,
00070                      do_flip ? -(int) src->stride : src->stride,
00071                      srcx, do_flip ? height - 1 - srcy : srcy);
00072 
00073       pipe->screen->surface_unmap(pipe->screen, src);
00074       pipe->screen->surface_unmap(pipe->screen, dst);
00075    }
00076    else {
00077       assert(dst->block.width == 1);
00078       assert(dst->block.height == 1);
00079       i915_copy_blit( i915_context(pipe),
00080                       do_flip,
00081                       dst->block.size,
00082                       (short) src->stride, src->buffer, src->offset,
00083                       (short) dst->stride, dst->buffer, dst->offset,
00084                       (short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
00085    }
00086 }
00087 
00088 
00089 static void
00090 i915_surface_fill(struct pipe_context *pipe,
00091                   struct pipe_surface *dst,
00092                   unsigned dstx, unsigned dsty,
00093                   unsigned width, unsigned height, unsigned value)
00094 {
00095    if (0) {
00096       void *dst_map = pipe->screen->surface_map( pipe->screen,
00097                                                  dst,
00098                                                  PIPE_BUFFER_USAGE_CPU_WRITE );
00099 
00100       pipe_fill_rect(dst_map, &dst->block, dst->stride, dstx, dsty, width, height, value);
00101 
00102       pipe->screen->surface_unmap(pipe->screen, dst);
00103    }
00104    else {
00105       assert(dst->block.width == 1);
00106       assert(dst->block.height == 1);
00107       i915_fill_blit( i915_context(pipe),
00108                       dst->block.size,
00109                       (short) dst->stride,
00110                       dst->buffer, dst->offset,
00111                       (short) dstx, (short) dsty,
00112                       (short) width, (short) height,
00113                       value );
00114    }
00115 }
00116 
00117 
00118 void
00119 i915_init_surface_functions(struct i915_context *i915)
00120 {
00121    i915->pipe.surface_copy = i915_surface_copy;
00122    i915->pipe.surface_fill = i915_surface_fill;
00123 }

Generated on Tue Sep 29 06:25:16 2009 for Gallium3D by  doxygen 1.5.4