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

« back to all changes in this revision

Viewing changes to hw/xfree86/xaa/xaaPaintWin.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
/* $XdotOrg: xserver/xorg/hw/xfree86/xaa/xaaPaintWin.c,v 1.6 2005/07/03 08:53:49 daniels Exp $ */
 
2
/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaPaintWin.c,v 1.10 2001/10/28 03:34:04 tsi Exp $ */
 
3
 
 
4
#ifdef HAVE_XORG_CONFIG_H
 
5
#include <xorg-config.h>
 
6
#endif
 
7
 
 
8
#include "misc.h"
 
9
#include "xf86.h"
 
10
#include "xf86_ansic.h"
 
11
#include "xf86_OSproc.h"
 
12
 
 
13
#include <X11/X.h>
 
14
#include "scrnintstr.h"
 
15
#include "windowstr.h"
 
16
#include "xf86str.h"
 
17
#include "xaa.h"
 
18
#include "xaalocal.h"
 
19
#include "gcstruct.h"
 
20
#include "pixmapstr.h"
 
21
#include "xaawrap.h"
 
22
 
 
23
#ifdef PANORAMIX
 
24
#include "panoramiX.h"
 
25
#include "panoramiXsrv.h"
 
26
#endif
 
27
 
 
28
void
 
29
XAAPaintWindow(
 
30
  WindowPtr pWin,
 
31
  RegionPtr prgn,
 
32
  int what 
 
33
)
 
34
{
 
35
    ScreenPtr  pScreen = pWin->drawable.pScreen;
 
36
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
 
37
    int nBox = REGION_NUM_RECTS(prgn);
 
38
    BoxPtr pBox = REGION_RECTS(prgn);
 
39
    int fg = -1;
 
40
    PixmapPtr pPix = NULL;
 
41
 
 
42
    if(!infoRec->pScrn->vtSema) goto BAILOUT;   
 
43
 
 
44
    switch (what) {
 
45
    case PW_BACKGROUND:
 
46
        switch(pWin->backgroundState) {
 
47
        case None: return;
 
48
        case ParentRelative:
 
49
            do { pWin = pWin->parent; }
 
50
            while(pWin->backgroundState == ParentRelative);
 
51
            (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, what);
 
52
            return;
 
53
        case BackgroundPixel:
 
54
            fg = pWin->background.pixel;
 
55
            break;
 
56
        case BackgroundPixmap:
 
57
            pPix = pWin->background.pixmap;
 
58
            break;
 
59
        }
 
60
        break;
 
61
    case PW_BORDER:
 
62
        if (pWin->borderIsPixel) 
 
63
            fg = pWin->border.pixel;
 
64
        else    /* pixmap */ 
 
65
            pPix = pWin->border.pixmap;
 
66
        break;
 
67
    default: return;
 
68
    }
 
69
 
 
70
 
 
71
    if(!pPix) {
 
72
        if(infoRec->FillSolidRects &&
 
73
           (!(infoRec->FillSolidRectsFlags & RGB_EQUAL) || 
 
74
                (CHECK_RGB_EQUAL(fg))) )  {
 
75
            (*infoRec->FillSolidRects)(infoRec->pScrn, fg, GXcopy, ~0,
 
76
                                        nBox, pBox);
 
77
            return;
 
78
        }
 
79
    } else {    /* pixmap */
 
80
        XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
 
81
        WindowPtr pBgWin = pWin;
 
82
        Bool NoCache = FALSE;
 
83
        int xorg, yorg;
 
84
 
 
85
        /* Hack so we can use this with the dual framebuffer layers
 
86
           which only support the pixmap cache in the primary bpp */
 
87
        if(pPix->drawable.bitsPerPixel != infoRec->pScrn->bitsPerPixel)
 
88
            NoCache = TRUE;
 
89
 
 
90
        if (what == PW_BORDER) {
 
91
            for (pBgWin = pWin;
 
92
                 pBgWin->backgroundState == ParentRelative;
 
93
                 pBgWin = pBgWin->parent);
 
94
        }
 
95
 
 
96
        xorg = pBgWin->drawable.x;
 
97
        yorg = pBgWin->drawable.y;
 
98
 
 
99
#ifdef PANORAMIX
 
100
        if(!noPanoramiXExtension) {
 
101
            int index = pScreen->myNum;
 
102
            if(WindowTable[index] == pBgWin) {
 
103
                xorg -= panoramiXdataPtr[index].x;
 
104
                yorg -= panoramiXdataPtr[index].y;
 
105
            }
 
106
        }
 
107
#endif
 
108
 
 
109
        if(IS_OFFSCREEN_PIXMAP(pPix) && infoRec->FillCacheBltRects) {
 
110
            XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
 
111
 
 
112
            pCache->x = pPriv->offscreenArea->box.x1;
 
113
            pCache->y = pPriv->offscreenArea->box.y1;
 
114
            pCache->w = pCache->orig_w = 
 
115
                pPriv->offscreenArea->box.x2 - pCache->x;
 
116
            pCache->h = pCache->orig_h = 
 
117
                pPriv->offscreenArea->box.y2 - pCache->y;
 
118
            pCache->trans_color = -1;
 
119
             
 
120
            (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, ~0,
 
121
                                nBox, pBox, xorg, yorg, pCache);
 
122
            return;
 
123
        }
 
124
 
 
125
        if(pPriv->flags & DIRTY) {
 
126
            pPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK);
 
127
            pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 
128
        }
 
129
 
 
130
        if(!(pPriv->flags & REDUCIBILITY_CHECKED) &&
 
131
            (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
 
132
            XAACheckTileReducibility(pPix, infoRec->CanDoMono8x8);
 
133
        }
 
134
 
 
135
        if(pPriv->flags & REDUCIBLE_TO_8x8) {
 
136
            if((pPriv->flags & REDUCIBLE_TO_2_COLOR) &&
 
137
                infoRec->CanDoMono8x8 && infoRec->FillMono8x8PatternRects &&
 
138
                !(infoRec->FillMono8x8PatternRectsFlags & TRANSPARENCY_ONLY) && 
 
139
                (!(infoRec->FillMono8x8PatternRectsFlags & RGB_EQUAL) || 
 
140
                (CHECK_RGB_EQUAL(pPriv->fg) && CHECK_RGB_EQUAL(pPriv->bg)))) {
 
141
 
 
142
                (*infoRec->FillMono8x8PatternRects)(infoRec->pScrn,
 
143
                        pPriv->fg, pPriv->bg, GXcopy, ~0, nBox, pBox,
 
144
                        pPriv->pattern0, pPriv->pattern1, xorg, yorg);
 
145
                return;
 
146
            }
 
147
            if(infoRec->CanDoColor8x8 && !NoCache &&
 
148
                                infoRec->FillColor8x8PatternRects) {
 
149
                XAACacheInfoPtr pCache = (*infoRec->CacheColor8x8Pattern)(
 
150
                                        infoRec->pScrn, pPix, -1, -1);
 
151
 
 
152
                (*infoRec->FillColor8x8PatternRects) ( infoRec->pScrn, 
 
153
                                GXcopy, ~0, nBox, pBox, xorg, yorg, pCache);
 
154
                return;
 
155
            }        
 
156
        }
 
157
 
 
158
        /* The window size check is to reduce pixmap cache thrashing
 
159
           when there are lots of little windows with pixmap backgrounds
 
160
           like are sometimes used for buttons, etc... */
 
161
 
 
162
        if(infoRec->UsingPixmapCache && 
 
163
            infoRec->FillCacheBltRects && !NoCache &&
 
164
            ((what == PW_BORDER) ||
 
165
                (pPix->drawable.height != pWin->drawable.height) ||
 
166
                (pPix->drawable.width != pWin->drawable.width)) &&
 
167
            (pPix->drawable.height <= infoRec->MaxCacheableTileHeight) &&
 
168
            (pPix->drawable.width <= infoRec->MaxCacheableTileWidth)) {
 
169
 
 
170
             XAACacheInfoPtr pCache = 
 
171
                        (*infoRec->CacheTile)(infoRec->pScrn, pPix);
 
172
             (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, ~0,
 
173
                                        nBox, pBox, xorg, yorg, pCache);
 
174
             return;
 
175
        }
 
176
 
 
177
        if(infoRec->FillImageWriteRects && 
 
178
                !(infoRec->FillImageWriteRectsFlags & NO_GXCOPY)) {
 
179
            (*infoRec->FillImageWriteRects) (infoRec->pScrn, GXcopy, 
 
180
                                ~0, nBox, pBox, xorg, yorg, pPix);
 
181
            return;
 
182
        }
 
183
    }
 
184
 
 
185
 
 
186
    if(infoRec->NeedToSync) {
 
187
        (*infoRec->Sync)(infoRec->pScrn);
 
188
        infoRec->NeedToSync = FALSE;
 
189
    }
 
190
 
 
191
BAILOUT:
 
192
 
 
193
    if(what == PW_BACKGROUND) {
 
194
        XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBackground);
 
195
        (*pScreen->PaintWindowBackground) (pWin, prgn, what);
 
196
        XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBackground, XAAPaintWindow);
 
197
    } else {
 
198
        XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBorder);
 
199
        (*pScreen->PaintWindowBorder) (pWin, prgn, what);
 
200
        XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBorder, XAAPaintWindow);
 
201
    }
 
202
 
 
203
}