Merge branch '7.8'
[mesa.git] / src / gallium / auxiliary / util / u_rect.c
index 72725b59d2c94fb3ca199b1d971cbdcb7739e9e2..e73797f1b7e62d64a7837619a777472d9c0d0f71 100644 (file)
 #include "pipe/p_format.h"
 #include "pipe/p_context.h"
 #include "pipe/p_screen.h"
+#include "util/u_format.h"
 #include "util/u_rect.h"
 
 
 /**
  * Copy 2D rect from one place to another.
  * Position and sizes are in pixels.
- * src_pitch may be negative to do vertical flip of pixels from source.
+ * src_stride may be negative to do vertical flip of pixels from source.
  */
 void
 util_copy_rect(ubyte * dst,
@@ -53,21 +54,17 @@ util_copy_rect(ubyte * dst,
                const ubyte * src,
                int src_stride,
                unsigned src_x, 
-               int src_y)
+               unsigned src_y)
 {
    unsigned i;
    int src_stride_pos = src_stride < 0 ? -src_stride : src_stride;
-   int blocksize = pf_get_blocksize(format);
-   int blockwidth = pf_get_blockwidth(format);
-   int blockheight = pf_get_blockheight(format);
+   int blocksize = util_format_get_blocksize(format);
+   int blockwidth = util_format_get_blockwidth(format);
+   int blockheight = util_format_get_blockheight(format);
 
    assert(blocksize > 0);
    assert(blockwidth > 0);
    assert(blockheight > 0);
-   assert(src_x >= 0);
-   assert(src_y >= 0);
-   assert(dst_x >= 0);
-   assert(dst_y >= 0);
 
    dst_x /= blockwidth;
    dst_y /= blockheight;
@@ -105,15 +102,13 @@ util_fill_rect(ubyte * dst,
 {
    unsigned i, j;
    unsigned width_size;
-   int blocksize = pf_get_blocksize(format);
-   int blockwidth = pf_get_blockwidth(format);
-   int blockheight = pf_get_blockheight(format);
+   int blocksize = util_format_get_blocksize(format);
+   int blockwidth = util_format_get_blockwidth(format);
+   int blockheight = util_format_get_blockheight(format);
 
    assert(blocksize > 0);
    assert(blockwidth > 0);
    assert(blockheight > 0);
-   assert(dst_x >= 0);
-   assert(dst_y >= 0);
 
    dst_x /= blockwidth;
    dst_y /= blockheight;
@@ -174,7 +169,6 @@ util_surface_copy(struct pipe_context *pipe,
                   unsigned src_x, unsigned src_y, 
                   unsigned w, unsigned h)
 {
-   struct pipe_screen *screen = pipe->screen;
    struct pipe_transfer *src_trans, *dst_trans;
    void *dst_map;
    const void *src_map;
@@ -187,7 +181,7 @@ util_surface_copy(struct pipe_context *pipe,
    src_format = src->texture->format;
    dst_format = dst->texture->format;
 
-   src_trans = screen->get_tex_transfer(screen,
+   src_trans = pipe->get_tex_transfer(pipe,
                                         src->texture,
                                         src->face,
                                         src->level,
@@ -195,7 +189,7 @@ util_surface_copy(struct pipe_context *pipe,
                                         PIPE_TRANSFER_READ,
                                         src_x, src_y, w, h);
 
-   dst_trans = screen->get_tex_transfer(screen,
+   dst_trans = pipe->get_tex_transfer(pipe,
                                         dst->texture,
                                         dst->face,
                                         dst->level,
@@ -203,12 +197,12 @@ util_surface_copy(struct pipe_context *pipe,
                                         PIPE_TRANSFER_WRITE,
                                         dst_x, dst_y, w, h);
 
-   assert(pf_get_blocksize(dst_format) == pf_get_blocksize(src_format));
-   assert(pf_get_blockwidth(dst_format) == pf_get_blockwidth(src_format));
-   assert(pf_get_blockheight(dst_format) == pf_get_blockheight(src_format));
+   assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format));
+   assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format));
+   assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format));
 
-   src_map = pipe->screen->transfer_map(screen, src_trans);
-   dst_map = pipe->screen->transfer_map(screen, dst_trans);
+   src_map = pipe->transfer_map(pipe, src_trans);
+   dst_map = pipe->transfer_map(pipe, dst_trans);
 
    assert(src_map);
    assert(dst_map);
@@ -226,11 +220,11 @@ util_surface_copy(struct pipe_context *pipe,
                      do_flip ? h - 1 : 0);
    }
 
-   pipe->screen->transfer_unmap(pipe->screen, src_trans);
-   pipe->screen->transfer_unmap(pipe->screen, dst_trans);
+   pipe->transfer_unmap(pipe, src_trans);
+   pipe->transfer_unmap(pipe, dst_trans);
 
-   screen->tex_transfer_destroy(src_trans);
-   screen->tex_transfer_destroy(dst_trans);
+   pipe->tex_transfer_destroy(pipe, src_trans);
+   pipe->tex_transfer_destroy(pipe, dst_trans);
 }
 
 
@@ -248,14 +242,13 @@ util_surface_fill(struct pipe_context *pipe,
                   unsigned dstx, unsigned dsty,
                   unsigned width, unsigned height, unsigned value)
 {
-   struct pipe_screen *screen = pipe->screen;
    struct pipe_transfer *dst_trans;
    void *dst_map;
 
    assert(dst->texture);
    if (!dst->texture)
       return;
-   dst_trans = screen->get_tex_transfer(screen,
+   dst_trans = pipe->get_tex_transfer(pipe,
                                         dst->texture,
                                         dst->face,
                                         dst->level,
@@ -263,14 +256,14 @@ util_surface_fill(struct pipe_context *pipe,
                                         PIPE_TRANSFER_WRITE,
                                         dstx, dsty, width, height);
 
-   dst_map = pipe->screen->transfer_map(screen, dst_trans);
+   dst_map = pipe->transfer_map(pipe, dst_trans);
 
    assert(dst_map);
 
    if (dst_map) {
       assert(dst_trans->stride > 0);
 
-      switch (pf_get_blocksize(dst_trans->texture->format)) {
+      switch (util_format_get_blocksize(dst_trans->texture->format)) {
       case 1:
       case 2:
       case 4:
@@ -307,6 +300,6 @@ util_surface_fill(struct pipe_context *pipe,
       }
    }
 
-   pipe->screen->transfer_unmap(pipe->screen, dst_trans);
-   screen->tex_transfer_destroy(dst_trans);
+   pipe->transfer_unmap(pipe, dst_trans);
+   pipe->tex_transfer_destroy(pipe, dst_trans);
 }