Merge commit 'origin/7.8'
[mesa.git] / src / mesa / drivers / dri / intel / intel_pixel_copy.c
index 757f2f7d4db9cc8cbad602f4700572c359ab6f48..56faf076c7e9d26d83cd9bf15486699657f713a6 100644 (file)
@@ -116,6 +116,7 @@ do_blit_copypixels(GLcontext * ctx,
    GLint orig_dsty;
    GLint orig_srcx;
    GLint orig_srcy;
+   GLboolean flip = GL_FALSE;
 
    if (type == GL_DEPTH || type == GL_STENCIL) {
       if (INTEL_DEBUG & DEBUG_FALLBACKS)
@@ -143,8 +144,6 @@ do_blit_copypixels(GLcontext * ctx,
 
    intelFlush(&intel->ctx);
 
-   /* XXX: We fail to handle different inversion between read and draw framebuffer. */
-
    /* Clip to destination buffer. */
    orig_dstx = dstx;
    orig_dsty = dsty;
@@ -167,23 +166,23 @@ do_blit_copypixels(GLcontext * ctx,
    dstx += srcx - orig_srcx;
    dsty += srcy - orig_srcy;
 
-   /* Convert from GL to hardware coordinates: */
+   /* Flip dest Y if it's a window system framebuffer. */
    if (fb->Name == 0) {
-      /* copypixels to a system framebuffer */
+      /* copypixels to a window system framebuffer */
       dsty = fb->Height - dsty - height;
-   } else {
-      /* copypixels to a user framebuffer object */
-      dsty = dsty;
+      flip = !flip;
    }
 
-   /* Flip source Y if it's a system framebuffer. */
-   if (read_fb->Name == 0)
-      srcy = fb->Height - srcy - height;
+   /* Flip source Y if it's a window system framebuffer. */
+   if (read_fb->Name == 0) {
+      srcy = read_fb->Height - srcy - height;
+      flip = !flip;
+   }
 
    if (!intel_region_copy(intel,
                          dst, 0, dstx, dsty,
                          src, 0, srcx, srcy,
-                         width, height,
+                         width, height, flip,
                          ctx->Color.ColorLogicOpEnabled ?
                          ctx->Color.LogicOp : GL_COPY)) {
       DBG("%s: blit failure\n", __FUNCTION__);