~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to src/gallium/auxiliary/util/u_rect.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 */
31
31
 
32
32
 
33
 
#include "pipe/p_defines.h"
34
 
#include "pipe/p_format.h"
35
 
#include "pipe/p_context.h"
36
 
#include "pipe/p_screen.h"
37
33
#include "util/u_format.h"
38
34
#include "util/u_rect.h"
 
35
#include "util/u_pack_color.h"
39
36
 
40
37
 
41
38
/**
98
95
               unsigned dst_y,
99
96
               unsigned width,
100
97
               unsigned height,
101
 
               uint32_t value)
 
98
               union util_color *uc)
102
99
{
103
100
   unsigned i, j;
104
101
   unsigned width_size;
114
111
   dst_y /= blockheight;
115
112
   width = (width + blockwidth - 1)/blockwidth;
116
113
   height = (height + blockheight - 1)/blockheight;
117
 
   
 
114
 
118
115
   dst += dst_x * blocksize;
119
116
   dst += dst_y * dst_stride;
120
117
   width_size = width * blocksize;
121
 
   
 
118
 
122
119
   switch (blocksize) {
123
120
   case 1:
124
121
      if(dst_stride == width_size)
125
 
         memset(dst, (ubyte) value, height * width_size);
 
122
         memset(dst, uc->ub, height * width_size);
126
123
      else {
127
 
         for (i = 0; i < height; i++) {
128
 
            memset(dst, (ubyte) value, width_size);
129
 
            dst += dst_stride;
130
 
         }
 
124
         for (i = 0; i < height; i++) {
 
125
            memset(dst, uc->ub, width_size);
 
126
            dst += dst_stride;
 
127
         }
131
128
      }
132
129
      break;
133
130
   case 2:
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;
138
 
         dst += dst_stride;
 
132
         uint16_t *row = (uint16_t *)dst;
 
133
         for (j = 0; j < width; j++)
 
134
            *row++ = uc->us;
 
135
         dst += dst_stride;
139
136
      }
140
137
      break;
141
138
   case 4:
142
139
      for (i = 0; i < height; i++) {
143
 
         uint32_t *row = (uint32_t *)dst;
144
 
         for (j = 0; j < width; j++)
145
 
            *row++ = value;
146
 
         dst += dst_stride;
 
140
         uint32_t *row = (uint32_t *)dst;
 
141
         for (j = 0; j < width; j++)
 
142
            *row++ = uc->ui;
 
143
         dst += dst_stride;
 
144
      }
 
145
      break;
 
146
   case 8:
 
147
   case 12:
 
148
   case 16:
 
149
   case 24:
 
150
   case 32:
 
151
      for (i = 0; i < height; i++) {
 
152
         ubyte *row = dst;
 
153
         for (j = 0; j < width; j++) {
 
154
            memcpy(row, uc, blocksize);
 
155
            row += blocksize;
 
156
         }
 
157
         dst += dst_stride;
147
158
      }
148
159
      break;
149
160
   default:
150
 
         assert(0);
151
 
         break;
152
 
   }
153
 
}
154
 
 
155
 
 
156
 
 
157
 
/**
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...
162
 
 */
163
 
void
164
 
util_surface_copy(struct pipe_context *pipe,
165
 
                  boolean do_flip,
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)
171
 
{
172
 
   struct pipe_screen *screen = pipe->screen;
173
 
   struct pipe_transfer *src_trans, *dst_trans;
174
 
   void *dst_map;
175
 
   const void *src_map;
176
 
   enum pipe_format src_format, dst_format;
177
 
 
178
 
   assert(src->texture && dst->texture);
179
 
   if (!src->texture || !dst->texture)
180
 
      return;
181
 
 
182
 
   src_format = src->texture->format;
183
 
   dst_format = dst->texture->format;
184
 
 
185
 
   src_trans = screen->get_tex_transfer(screen,
186
 
                                        src->texture,
187
 
                                        src->face,
188
 
                                        src->level,
189
 
                                        src->zslice,
190
 
                                        PIPE_TRANSFER_READ,
191
 
                                        src_x, src_y, w, h);
192
 
 
193
 
   dst_trans = screen->get_tex_transfer(screen,
194
 
                                        dst->texture,
195
 
                                        dst->face,
196
 
                                        dst->level,
197
 
                                        dst->zslice,
198
 
                                        PIPE_TRANSFER_WRITE,
199
 
                                        dst_x, dst_y, w, h);
200
 
 
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));
204
 
 
205
 
   src_map = pipe->screen->transfer_map(screen, src_trans);
206
 
   dst_map = pipe->screen->transfer_map(screen, dst_trans);
207
 
 
208
 
   assert(src_map);
209
 
   assert(dst_map);
210
 
 
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,
214
 
                     dst_format,
215
 
                     dst_trans->stride,
216
 
                     0, 0,
217
 
                     w, h,
218
 
                     src_map,
219
 
                     do_flip ? -(int) src_trans->stride : src_trans->stride,
220
 
                     0,
221
 
                     do_flip ? h - 1 : 0);
222
 
   }
223
 
 
224
 
   pipe->screen->transfer_unmap(pipe->screen, src_trans);
225
 
   pipe->screen->transfer_unmap(pipe->screen, dst_trans);
226
 
 
227
 
   screen->tex_transfer_destroy(src_trans);
228
 
   screen->tex_transfer_destroy(dst_trans);
229
 
}
230
 
 
231
 
 
232
 
 
233
 
#define UBYTE_TO_USHORT(B) ((B) | ((B) << 8))
234
 
 
235
 
 
236
 
/**
237
 
 * Fallback for pipe->surface_fill() function.
238
 
 * XXX should probably put this in new u_surface.c file...
239
 
 */
240
 
void
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)
245
 
{
246
 
   struct pipe_screen *screen = pipe->screen;
247
 
   struct pipe_transfer *dst_trans;
248
 
   void *dst_map;
249
 
 
250
 
   assert(dst->texture);
251
 
   if (!dst->texture)
252
 
      return;
253
 
   dst_trans = screen->get_tex_transfer(screen,
254
 
                                        dst->texture,
255
 
                                        dst->face,
256
 
                                        dst->level,
257
 
                                        dst->zslice,
258
 
                                        PIPE_TRANSFER_WRITE,
259
 
                                        dstx, dsty, width, height);
260
 
 
261
 
   dst_map = pipe->screen->transfer_map(screen, dst_trans);
262
 
 
263
 
   assert(dst_map);
264
 
 
265
 
   if (dst_map) {
266
 
      assert(dst_trans->stride > 0);
267
 
 
268
 
      switch (util_format_get_blocksize(dst_trans->texture->format)) {
269
 
      case 1:
270
 
      case 2:
271
 
      case 4:
272
 
         util_fill_rect(dst_map, dst_trans->texture->format, dst_trans->stride,
273
 
                        0, 0, width, height, value);
274
 
         break;
275
 
      case 8:
276
 
         {
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);
283
 
            unsigned i, j;
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++) {
290
 
                  row[j*4+0] = val0;
291
 
                  row[j*4+1] = val1;
292
 
                  row[j*4+2] = val2;
293
 
                  row[j*4+3] = val3;
294
 
               }
295
 
               row += dst_trans->stride/2;
296
 
            }
297
 
         }
298
 
         break;
299
 
      default:
300
 
         assert(0);
301
 
         break;
302
 
      }
303
 
   }
304
 
 
305
 
   pipe->screen->transfer_unmap(pipe->screen, dst_trans);
306
 
   screen->tex_transfer_destroy(dst_trans);
 
161
      assert(0);
 
162
      break;
 
163
   }
307
164
}