114
111
dst_y /= blockheight;
115
112
width = (width + blockwidth - 1)/blockwidth;
116
113
height = (height + blockheight - 1)/blockheight;
118
115
dst += dst_x * blocksize;
119
116
dst += dst_y * dst_stride;
120
117
width_size = width * blocksize;
122
119
switch (blocksize) {
124
121
if(dst_stride == width_size)
125
memset(dst, (ubyte) value, height * width_size);
122
memset(dst, uc->ub, height * width_size);
127
for (i = 0; i < height; i++) {
128
memset(dst, (ubyte) value, width_size);
124
for (i = 0; i < height; i++) {
125
memset(dst, uc->ub, width_size);
134
131
for (i = 0; i < height; i++) {
135
uint16_t *row = (uint16_t *)dst;
136
for (j = 0; j < width; j++)
137
*row++ = (uint16_t) value;
132
uint16_t *row = (uint16_t *)dst;
133
for (j = 0; j < width; j++)
142
139
for (i = 0; i < height; i++) {
143
uint32_t *row = (uint32_t *)dst;
144
for (j = 0; j < width; j++)
140
uint32_t *row = (uint32_t *)dst;
141
for (j = 0; j < width; j++)
151
for (i = 0; i < height; i++) {
153
for (j = 0; j < width; j++) {
154
memcpy(row, uc, blocksize);
158
* Fallback function for pipe->surface_copy().
159
* Note: (X,Y)=(0,0) is always the upper-left corner.
160
* if do_flip, flip the image vertically on its way from src rect to dst rect.
161
* XXX should probably put this in new u_surface.c file...
164
util_surface_copy(struct pipe_context *pipe,
166
struct pipe_surface *dst,
167
unsigned dst_x, unsigned dst_y,
168
struct pipe_surface *src,
169
unsigned src_x, unsigned src_y,
170
unsigned w, unsigned h)
172
struct pipe_screen *screen = pipe->screen;
173
struct pipe_transfer *src_trans, *dst_trans;
176
enum pipe_format src_format, dst_format;
178
assert(src->texture && dst->texture);
179
if (!src->texture || !dst->texture)
182
src_format = src->texture->format;
183
dst_format = dst->texture->format;
185
src_trans = screen->get_tex_transfer(screen,
193
dst_trans = screen->get_tex_transfer(screen,
201
assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format));
202
assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format));
203
assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format));
205
src_map = pipe->screen->transfer_map(screen, src_trans);
206
dst_map = pipe->screen->transfer_map(screen, dst_trans);
211
if (src_map && dst_map) {
212
/* If do_flip, invert src_y position and pass negative src stride */
213
util_copy_rect(dst_map,
219
do_flip ? -(int) src_trans->stride : src_trans->stride,
221
do_flip ? h - 1 : 0);
224
pipe->screen->transfer_unmap(pipe->screen, src_trans);
225
pipe->screen->transfer_unmap(pipe->screen, dst_trans);
227
screen->tex_transfer_destroy(src_trans);
228
screen->tex_transfer_destroy(dst_trans);
233
#define UBYTE_TO_USHORT(B) ((B) | ((B) << 8))
237
* Fallback for pipe->surface_fill() function.
238
* XXX should probably put this in new u_surface.c file...
241
util_surface_fill(struct pipe_context *pipe,
242
struct pipe_surface *dst,
243
unsigned dstx, unsigned dsty,
244
unsigned width, unsigned height, unsigned value)
246
struct pipe_screen *screen = pipe->screen;
247
struct pipe_transfer *dst_trans;
250
assert(dst->texture);
253
dst_trans = screen->get_tex_transfer(screen,
259
dstx, dsty, width, height);
261
dst_map = pipe->screen->transfer_map(screen, dst_trans);
266
assert(dst_trans->stride > 0);
268
switch (util_format_get_blocksize(dst_trans->texture->format)) {
272
util_fill_rect(dst_map, dst_trans->texture->format, dst_trans->stride,
273
0, 0, width, height, value);
277
/* expand the 4-byte clear value to an 8-byte value */
278
ushort *row = (ushort *) dst_map;
279
ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
280
ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
281
ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
282
ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
284
val0 = (val0 << 8) | val0;
285
val1 = (val1 << 8) | val1;
286
val2 = (val2 << 8) | val2;
287
val3 = (val3 << 8) | val3;
288
for (i = 0; i < height; i++) {
289
for (j = 0; j < width; j++) {
295
row += dst_trans->stride/2;
305
pipe->screen->transfer_unmap(pipe->screen, dst_trans);
306
screen->tex_transfer_destroy(dst_trans);