st/mesa: plug in default for pipe_context::surface_copy() if needed
authorBrian Paul <brianp@vmware.com>
Wed, 17 Mar 2010 16:31:57 +0000 (10:31 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 17 Mar 2010 16:31:59 +0000 (10:31 -0600)
This lets us avoid conditionals and duplicated code in several places.

src/mesa/state_tracker/st_atom_framebuffer.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_texture.c

index fba7bfe2cea6d7a81b40fc0a78275341ad03bb94..79ad70909a9e5e03031d216d7a81bfe17483d8f9 100644 (file)
@@ -38,7 +38,6 @@
 #include "st_texture.h"
 #include "pipe/p_context.h"
 #include "cso_cache/cso_context.h"
-#include "util/u_rect.h"
 #include "util/u_math.h"
 #include "util/u_inlines.h"
 
@@ -164,17 +163,10 @@ update_framebuffer_state( struct st_context *st )
          (void) st_get_framebuffer_surface(stfb, ST_SURFACE_FRONT_LEFT, &surf_front);
          (void) st_get_framebuffer_surface(stfb, ST_SURFACE_BACK_LEFT, &surf_back);
 
-         if (st->pipe->surface_copy) {
-            st->pipe->surface_copy(st->pipe,
-                                   surf_front, 0, 0,  /* dest */
-                                   surf_back, 0, 0,   /* src */
-                                   fb->Width, fb->Height);
-         } else {
-            util_surface_copy(st->pipe, FALSE,
-                              surf_front, 0, 0,
-                              surf_back, 0, 0,
-                              fb->Width, fb->Height);
-         }
+         st->pipe->surface_copy(st->pipe,
+                                surf_front, 0, 0,  /* dest */
+                                surf_back, 0, 0,   /* src */
+                                fb->Width, fb->Height);
       }
       /* we're assuming we'll really draw to the front buffer */
       st->frontbuffer_status = FRONT_STATUS_DIRTY;
index 72a2ddb379ba37ba85f37c7b0647caf78aaaaf4a..07529ab6af79d9ab46afbcdc50d4d134bb3defea 100644 (file)
@@ -59,7 +59,6 @@
 #include "util/u_draw_quad.h"
 #include "util/u_format.h"
 #include "util/u_math.h"
-#include "util/u_rect.h"
 #include "shader/prog_instruction.h"
 #include "cso_cache/cso_context.h"
 
@@ -1057,19 +1056,11 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
                                        PIPE_BUFFER_USAGE_GPU_READ);
       struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, 
                                       PIPE_BUFFER_USAGE_GPU_WRITE );
-      if (pipe->surface_copy) {
-         pipe->surface_copy(pipe,
-                            psTex,                               /* dest surf */
-                            unpack.SkipPixels, unpack.SkipRows,  /* dest pos */
-                            psRead,                              /* src surf */
-                            readX, readY, readW, readH);         /* src region */
-      } else {
-         util_surface_copy(pipe, FALSE,
-                           psTex,
-                           unpack.SkipPixels, unpack.SkipRows,
-                           psRead,
-                           readX, readY, readW, readH);
-      }
+      pipe->surface_copy(pipe,
+                         psTex,                               /* dest surf */
+                         unpack.SkipPixels, unpack.SkipRows,  /* dest pos */
+                         psRead,                              /* src surf */
+                         readX, readY, readW, readH);         /* src region */
 
       if (0) {
          /* debug */
index 4ccba1db85db03fb4dd93ee525d24219518c9044..84c2474038d0a7194c81ccc3982831c1b8bf469d 100644 (file)
@@ -51,7 +51,6 @@
 #include "st_manager.h"
 
 #include "util/u_format.h"
-#include "util/u_rect.h"
 #include "util/u_inlines.h"
 
 
@@ -518,17 +517,10 @@ copy_back_to_front(struct st_context *st,
    (void) st_get_framebuffer_surface(stfb, backIndex, &surf_back);
 
    if (surf_front && surf_back) {
-      if (st->pipe->surface_copy) {
-         st->pipe->surface_copy(st->pipe,
-                                surf_front, 0, 0,  /* dest */
-                                surf_back, 0, 0,   /* src */
-                                fb->Width, fb->Height);
-      } else {
-         util_surface_copy(st->pipe, FALSE,
-                           surf_front, 0, 0,
-                           surf_back, 0, 0,
-                           fb->Width, fb->Height);
-      }
+      st->pipe->surface_copy(st->pipe,
+                             surf_front, 0, 0,  /* dest */
+                             surf_back, 0, 0,   /* src */
+                             fb->Width, fb->Height);
    }
 }
 
index 3fe01c4721bb9aa95cb3af0fb5ba7d63872bd701..d7a774aa409940d05d01a7ad513a10cbcfde849d 100644 (file)
@@ -1560,8 +1560,7 @@ st_copy_texsubimage(GLcontext *ctx,
 
    if (ctx->_ImageTransferState == 0x0) {
 
-      if (pipe->surface_copy &&
-          matching_base_formats &&
+      if (matching_base_formats &&
           src_format == dest_format &&
           !do_flip) 
       {
index 0885ad77c7c9db616edc56b7f5b06006ba93f970..72f5a9c1e0b787bfd5e29c7d64ae63431aec6652 100644 (file)
@@ -63,6 +63,7 @@
 #include "st_program.h"
 #include "pipe/p_context.h"
 #include "util/u_inlines.h"
+#include "util/u_rect.h"
 #include "draw/draw_context.h"
 #include "cso_cache/cso_context.h"
 
@@ -97,6 +98,19 @@ st_get_msaa(void)
 }
 
 
+/** Default method for pipe_context::surface_copy() */
+static void
+st_surface_copy(struct pipe_context *pipe,
+                struct pipe_surface *dst,
+                unsigned dst_x, unsigned dst_y,
+                struct pipe_surface *src,
+                unsigned src_x, unsigned src_y, 
+                unsigned w, unsigned h)
+{
+   util_surface_copy(pipe, FALSE, dst, dst_x, dst_y, src, src_x, src_y, w, h);
+}
+
+
 static struct st_context *
 st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
 {
@@ -166,6 +180,10 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
    st_init_limits(st);
    st_init_extensions(st);
 
+   /* plug in helper driver functions if needed */
+   if (!pipe->surface_copy)
+      pipe->surface_copy = st_surface_copy;
+
    return st;
 }
 
index ef97d873e5076fa9ffb69bdddc6e953e4d4d6cab..5809927852d4a87e6cd794bba6fa876ab0ab3229 100644 (file)
@@ -342,21 +342,12 @@ st_texture_image_copy(struct pipe_context *pipe,
       src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
                                             PIPE_BUFFER_USAGE_GPU_READ);
 
-      if (pipe->surface_copy) {
-         pipe->surface_copy(pipe,
-                           dst_surface,
-                           0, 0, /* destX, Y */
-                           src_surface,
-                           0, 0, /* srcX, Y */
-                           width, height);
-      } else {
-         util_surface_copy(pipe, FALSE,
-                          dst_surface,
-                          0, 0, /* destX, Y */
-                          src_surface,
-                          0, 0, /* srcX, Y */
-                          width, height);
-      }
+      pipe->surface_copy(pipe,
+                         dst_surface,
+                         0, 0, /* destX, Y */
+                         src_surface,
+                         0, 0, /* srcX, Y */
+                         width, height);
 
       pipe_surface_reference(&src_surface, NULL);
       pipe_surface_reference(&dst_surface, NULL);