Merge branch '7.8'
authorBrian Paul <brianp@vmware.com>
Wed, 10 Mar 2010 17:44:12 +0000 (10:44 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 10 Mar 2010 17:44:12 +0000 (10:44 -0700)
1  2 
src/mesa/state_tracker/st_cb_drawpixels.c

index c609435a158a1600d6f3a35fd69b3f6730d5bd57,43dc8d1b836f181be43bf8afb4c75b661ac3d121..5f23e8afed3f620124eb4977662d4693855377de
@@@ -405,7 -405,7 +405,7 @@@ make_texture(struct st_context *st
  
  /**
   * Draw quad with texcoords and optional color.
-  * Coords are window coords with y=0=bottom.
+  * Coords are gallium window coords with y=0=top.
   * \param color  may be null
   * \param invertTex  if true, flip texcoords vertically
   */
@@@ -529,7 -529,6 +529,7 @@@ draw_textured_quad(GLcontext *ctx, GLin
     cso_save_sampler_textures(cso);
     cso_save_fragment_shader(cso);
     cso_save_vertex_shader(cso);
 +   cso_save_vertex_elements(cso);
  
     /* rasterizer state: just scissor */
     {
        cso_set_viewport(cso, &vp);
     }
  
 +   cso_set_vertex_elements(cso, 3, st->velems_util_draw);
 +
     /* texture state: */
     if (st->pixel_xfer.pixelmap_enabled) {
        struct pipe_texture *textures[2];
        pipe->set_fragment_sampler_textures(pipe, 1, &pt);
     }
  
-    /* Compute window coords (y=0=bottom) with pixel zoom.
+    /* Compute Gallium window coords (y=0=top) with pixel zoom.
      * Recall that these coords are transformed by the current
      * vertex shader and viewport transformation.
      */
+    if (st_fb_orientation(ctx->DrawBuffer) == Y_0_BOTTOM) {
+       y = ctx->DrawBuffer->Height - (int) (y + height * ctx->Pixel.ZoomY);
+       invertTex = !invertTex;
+    }
     x0 = (GLfloat) x;
     x1 = x + width * ctx->Pixel.ZoomX;
     y0 = (GLfloat) y;
     cso_restore_sampler_textures(cso);
     cso_restore_fragment_shader(cso);
     cso_restore_vertex_shader(cso);
 +   cso_restore_vertex_elements(cso);
  }
  
  
@@@ -936,6 -937,7 +941,7 @@@ st_CopyPixels(GLcontext *ctx, GLint src
     GLfloat *color;
     enum pipe_format srcFormat, texFormat;
     int ptw, pth;
+    GLboolean invertTex = GL_FALSE;
  
     pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
  
        }
     }
  
-    if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
-       srcy = ctx->DrawBuffer->Height - srcy - height;
+    if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
+       srcy = ctx->ReadBuffer->Height - srcy - height;
  
        if (srcy < 0) {
           height -= -srcy;
  
        if (height < 0)
           return;
+       invertTex = !invertTex;
     }
  
     /* Need to use POT texture? */
     if (!pt)
        return;
  
+    /* Make temporary texture which is a copy of the src region.
+     * We'll draw a quad with this texture to draw the dest image.
+     */
     if (srcFormat == texFormat) {
        /* copy source framebuffer surface into mipmap/texture */
        struct pipe_surface *psRead = screen->get_tex_surface(screen,
                             psRead,
                             srcx, srcy, width, height);
        }
+       if (0) {
+          /* debug */
+          debug_dump_surface("copypixsrcsurf", psRead);
+          debug_dump_surface("copypixtemptex", psTex);
+       }
        pipe_surface_reference(&psRead, NULL); 
        pipe_surface_reference(&psTex, NULL);
     }
                        pt, 
                        driver_vp, 
                        driver_fp,
-                       color, GL_TRUE);
+                       color, invertTex);
  
     pipe_texture_reference(&pt, NULL);
  }