Merge branch 'gallium-docs'
[mesa.git] / src / gallium / state_trackers / xorg / xorg_exa.c
index 16e683019c1aef49a6c9b924af64378ca425c3cc..aa68570b9c07bcce6ee2c99ba1efeff1ee2d6ad0 100644 (file)
@@ -43,6 +43,7 @@
 #include "pipe/p_state.h"
 #include "pipe/p_inlines.h"
 
+#include "util/u_format.h"
 #include "util/u_rect.h"
 #include "util/u_math.h"
 #include "util/u_debug.h"
@@ -202,7 +203,7 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x,  int y, int w,  int h, char *dst,
                  x, y, w, h, dst_pitch);
 #endif
 
-    util_copy_rect((unsigned char*)dst, &priv->tex->block, dst_pitch, 0, 0,
+    util_copy_rect((unsigned char*)dst, priv->tex->format, dst_pitch, 0, 0,
                   w, h, exa->scrn->transfer_map(exa->scrn, transfer),
                   transfer->stride, 0, 0);
 
@@ -242,7 +243,7 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src,
 #endif
 
     util_copy_rect(exa->scrn->transfer_map(exa->scrn, transfer),
-                  &priv->tex->block, transfer->stride, 0, 0, w, h,
+                  priv->tex->format, transfer->stride, 0, 0, w, h,
                   (unsigned char*)src, src_pitch, 0, 0);
 
     exa->scrn->transfer_unmap(exa->scrn, transfer);
@@ -283,13 +284,9 @@ ExaPrepareAccess(PixmapPtr pPix, int index)
                                        PIPE_TRANSFER_MAP_DIRECTLY |
 #endif
                                        PIPE_TRANSFER_READ_WRITE,
-<<<<<<< HEAD:src/gallium/state_trackers/xorg/xorg_exa.c
-                                       0, 0, priv->tex->width0, priv->tex->height0);
-=======
                                        0, 0, 
                                         pPix->drawable.width,
                                         pPix->drawable.height );
->>>>>>> origin/mesa_7_7_branch:src/gallium/state_trackers/xorg/xorg_exa.c
        if (!priv->map_transfer)
 #ifdef EXA_MIXED_PIXMAPS
            return FALSE;
@@ -347,6 +344,9 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
 #if DEBUG_PRINT
     debug_printf("ExaPrepareSolid(0x%x)\n", fg);
 #endif
+    if (!exa->accel)
+       return FALSE;
+
     if (!exa->pipe)
        XORG_FALLBACK("accle not enabled");
 
@@ -365,7 +365,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
        XORG_FALLBACK("format %s", pf_name(priv->tex->format));
     }
 
-    return exa->accel && xorg_solid_bind_state(exa, priv, fg);
+    return xorg_solid_bind_state(exa, priv, fg);
 }
 
 static void
@@ -421,6 +421,10 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
 #if DEBUG_PRINT
     debug_printf("ExaPrepareCopy\n");
 #endif
+
+    if (!exa->accel)
+       return FALSE;
+
     if (!exa->pipe)
        XORG_FALLBACK("accle not enabled");
 
@@ -494,7 +498,7 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
     }
 
 
-    return exa->accel;
+    return TRUE;
 }
 
 static void
@@ -512,6 +516,7 @@ ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
 #endif
 
    debug_assert(priv == exa->copy.dst);
+   (void) priv;
 
    if (exa->copy.use_surface_copy) {
       /* XXX: consider exposing >1 box in surface_copy interface.
@@ -602,15 +607,19 @@ ExaCheckComposite(int op,
    ScrnInfoPtr pScrn = xf86Screens[pDstPicture->pDrawable->pScreen->myNum];
    modesettingPtr ms = modesettingPTR(pScrn);
    struct exa_context *exa = ms->exa;
-   boolean accelerated = xorg_composite_accelerated(op,
-                                                    pSrcPicture,
-                                                    pMaskPicture,
-                                                    pDstPicture);
+
 #if DEBUG_PRINT
    debug_printf("ExaCheckComposite(%d, %p, %p, %p) = %d\n",
                 op, pSrcPicture, pMaskPicture, pDstPicture, accelerated);
 #endif
-   return exa->accel && accelerated;
+
+   if (!exa->accel)
+       return FALSE;
+
+   return xorg_composite_accelerated(op,
+                                    pSrcPicture,
+                                    pMaskPicture,
+                                    pDstPicture);
 }
 
 
@@ -624,6 +633,9 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
    struct exa_context *exa = ms->exa;
    struct exa_pixmap_priv *priv;
 
+   if (!exa->accel)
+       return FALSE;
+
 #if DEBUG_PRINT
    debug_printf("ExaPrepareComposite(%d, src=0x%p, mask=0x%p, dst=0x%p)\n",
                 op, pSrcPicture, pMaskPicture, pDstPicture);
@@ -682,8 +694,7 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
                        render_format_name(pMaskPicture->format));
    }
 
-   return exa->accel &&
-          xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture,
+   return xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture,
                                     pDstPicture,
                                     pSrc ? exaGetPixmapDriverPrivate(pSrc) : NULL,
                                     pMask ? exaGetPixmapDriverPrivate(pMask) : NULL,
@@ -903,7 +914,6 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
        memset(&template, 0, sizeof(template));
        template.target = PIPE_TEXTURE_2D;
        exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &priv->picture_format);
-       pf_get_block(template.format, &template.block);
         if (ROUND_UP_TEXTURES && priv->flags == 0) {
            template.width0 = util_next_power_of_two(width);
            template.height0 = util_next_power_of_two(height);
@@ -989,7 +999,6 @@ xorg_exa_create_root_texture(ScrnInfoPtr pScrn,
     memset(&template, 0, sizeof(template));
     template.target = PIPE_TEXTURE_2D;
     exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &dummy);
-    pf_get_block(template.format, &template.block);
     template.width0 = width;
     template.height0 = height;
     template.depth0 = 1;
@@ -1011,6 +1020,9 @@ xorg_exa_close(ScrnInfoPtr pScrn)
 
    if (exa->pipe)
       exa->pipe->destroy(exa->pipe);
+   exa->pipe = NULL;
+   /* Since this was shared be proper with the pointer */
+   ms->ctx = NULL;
 
    exaDriverFini(pScrn->pScreen);
    xfree(exa);