00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
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 
00040 
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 }