~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/xgl/xglshm.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
Import upstream version 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2005 Novell, Inc.
 
3
 *
 
4
 * Permission to use, copy, modify, distribute, and sell this software
 
5
 * and its documentation for any purpose is hereby granted without
 
6
 * fee, provided that the above copyright notice appear in all copies
 
7
 * and that both that copyright notice and this permission notice
 
8
 * appear in supporting documentation, and that the name of
 
9
 * Novell, Inc. not be used in advertising or publicity pertaining to
 
10
 * distribution of the software without specific, written prior permission.
 
11
 * Novell, Inc. makes no representations about the suitability of this
 
12
 * software for any purpose. It is provided "as is" without express or
 
13
 * implied warranty.
 
14
 *
 
15
 * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
16
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
17
 * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
18
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
19
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
20
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
21
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
22
 *
 
23
 * Author: David Reveman <davidr@novell.com>
 
24
 */
 
25
 
 
26
#include "xgl.h"
 
27
#include "gcstruct.h"
 
28
 
 
29
#ifdef MITSHM
 
30
 
 
31
void
 
32
xglShmPutImage (DrawablePtr  pDrawable,
 
33
                GCPtr        pGC,
 
34
                int          depth,
 
35
                unsigned int format,
 
36
                int          w,
 
37
                int          h,
 
38
                int          sx,
 
39
                int          sy,
 
40
                int          sw,
 
41
                int          sh,
 
42
                int          dx,
 
43
                int          dy,
 
44
                char         *data)
 
45
{
 
46
    ScreenPtr pScreen = pDrawable->pScreen;
 
47
    PixmapPtr pPixmapHeader = NULL;
 
48
    PixmapPtr pPixmap;
 
49
    int       saveTarget;
 
50
 
 
51
    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
 
52
 
 
53
    if ((format == ZPixmap) || (depth == 1))
 
54
    {
 
55
        pPixmap = pPixmapHeader =
 
56
            GetScratchPixmapHeader (pScreen, w, h, depth,
 
57
                                    BitsPerPixel (depth),
 
58
                                    PixmapBytePad (w, depth),
 
59
                                    (pointer) data);
 
60
 
 
61
        /* disable any possible acceleration of this pixmap */
 
62
        if (pPixmap)
 
63
            xglSetPixmapVisual (pPixmap, 0);
 
64
    }
 
65
    else
 
66
    {
 
67
        pPixmap = (*pScreen->CreatePixmap) (pScreen, sw, sh, depth);
 
68
        if (pPixmap)
 
69
        {
 
70
            GCPtr pScratchGC;
 
71
 
 
72
            if (!xglAllocatePixmapBits (pPixmap,
 
73
                                        XGL_PIXMAP_USAGE_HINT_DEFAULT))
 
74
            {
 
75
                (*pScreen->DestroyPixmap) (pPixmap);
 
76
                return;
 
77
            }
 
78
 
 
79
            xglSetPixmapVisual (pPixmap, 0);
 
80
 
 
81
            pScratchGC = GetScratchGC (depth, pScreen);
 
82
            if (!pScratchGC)
 
83
            {
 
84
                (*pScreen->DestroyPixmap) (pPixmap);
 
85
                return;
 
86
            }
 
87
 
 
88
            ValidateGC ((DrawablePtr) pPixmap, pScratchGC);
 
89
            (*pGC->ops->PutImage) ((DrawablePtr) pPixmap, pScratchGC, depth,
 
90
                                   -sx, -sy, w, h, 0,
 
91
                                   (format == XYPixmap) ? XYPixmap : ZPixmap,
 
92
                                   data);
 
93
 
 
94
            FreeScratchGC (pScratchGC);
 
95
 
 
96
            sx = sy = 0;
 
97
        }
 
98
    }
 
99
 
 
100
    if (!pPixmap)
 
101
        return;
 
102
 
 
103
    /* CopyArea should always be done in software */
 
104
    saveTarget = pPixmapPriv->target;
 
105
    pPixmapPriv->target = xglPixmapTargetNo;
 
106
 
 
107
    if (format == XYBitmap)
 
108
        (*pGC->ops->CopyPlane) ((DrawablePtr) pPixmap, pDrawable, pGC,
 
109
                                sx, sy, sw, sh, dx, dy, 1L);
 
110
    else
 
111
        (*pGC->ops->CopyArea) ((DrawablePtr) pPixmap, pDrawable, pGC,
 
112
                               sx, sy, sw, sh, dx, dy);
 
113
 
 
114
    pPixmapPriv->target = saveTarget;
 
115
 
 
116
    if (pPixmapHeader)
 
117
        FreeScratchPixmapHeader (pPixmapHeader);
 
118
    else
 
119
        (*pScreen->DestroyPixmap) (pPixmap);
 
120
}
 
121
 
 
122
#endif