1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "i915_context.h"
29 #include "i915_blit.h"
30 #include "i915_state.h"
31 #include "pipe/p_defines.h"
32 #include "pipe/p_inlines.h"
33 #include "pipe/p_util.h"
34 #include "pipe/p_inlines.h"
35 #include "pipe/p_winsys.h"
36 #include "util/p_tile.h"
39 /* Assumes all values are within bounds -- no checking at this level -
40 * do it higher up if required.
43 i915_surface_copy(struct pipe_context
*pipe
,
45 struct pipe_surface
*dst
,
46 unsigned dstx
, unsigned dsty
,
47 struct pipe_surface
*src
,
48 unsigned srcx
, unsigned srcy
, unsigned width
, unsigned height
)
51 assert( dst
->cpp
== src
->cpp
);
54 void *dst_map
= pipe
->screen
->surface_map( pipe
->screen
,
56 PIPE_BUFFER_USAGE_CPU_WRITE
);
58 const void *src_map
= pipe
->screen
->surface_map( pipe
->screen
,
60 PIPE_BUFFER_USAGE_CPU_READ
);
62 pipe_copy_rect(dst_map
,
68 do_flip
? -(int) src
->pitch
: src
->pitch
,
69 srcx
, do_flip
? 1 - srcy
- height
: srcy
);
71 pipe
->screen
->surface_unmap(pipe
->screen
, src
);
72 pipe
->screen
->surface_unmap(pipe
->screen
, dst
);
75 i915_copy_blit( i915_context(pipe
),
78 (short) src
->pitch
, src
->buffer
, src
->offset
,
79 (short) dst
->pitch
, dst
->buffer
, dst
->offset
,
80 (short) srcx
, (short) srcy
, (short) dstx
, (short) dsty
, (short) width
, (short) height
);
85 /* Fill a rectangular sub-region. Need better logic about when to
86 * push buffers into AGP - will currently do so whenever possible.
89 get_pointer(struct pipe_surface
*dst
, void *dst_map
, unsigned x
, unsigned y
)
91 return (char *)dst_map
+ (y
* dst
->pitch
+ x
) * dst
->cpp
;
96 i915_surface_fill(struct pipe_context
*pipe
,
97 struct pipe_surface
*dst
,
98 unsigned dstx
, unsigned dsty
,
99 unsigned width
, unsigned height
, unsigned value
)
103 void *dst_map
= pipe
->screen
->surface_map( pipe
->screen
,
105 PIPE_BUFFER_USAGE_CPU_WRITE
);
110 ubyte
*row
= get_pointer(dst
, dst_map
, dstx
, dsty
);
111 for (i
= 0; i
< height
; i
++) {
112 memset(row
, value
, width
);
118 ushort
*row
= get_pointer(dst
, dst_map
, dstx
, dsty
);
119 for (i
= 0; i
< height
; i
++) {
120 for (j
= 0; j
< width
; j
++)
121 row
[j
] = (ushort
) value
;
127 unsigned *row
= get_pointer(dst
, dst_map
, dstx
, dsty
);
128 for (i
= 0; i
< height
; i
++) {
129 for (j
= 0; j
< width
; j
++)
140 pipe
->screen
->surface_unmap(pipe
->screen
, dst
);
143 i915_fill_blit( i915_context(pipe
),
146 dst
->buffer
, dst
->offset
,
147 (short) dstx
, (short) dsty
,
148 (short) width
, (short) height
,
155 i915_init_surface_functions(struct i915_context
*i915
)
157 i915
->pipe
.surface_copy
= i915_surface_copy
;
158 i915
->pipe
.surface_fill
= i915_surface_fill
;