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

« back to all changes in this revision

Viewing changes to hw/xgl/xglsolid.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 © 2004 David Reveman
 
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
 * David Reveman not be used in advertising or publicity pertaining to
 
10
 * distribution of the software without specific, written prior permission.
 
11
 * David Reveman 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
 * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
16
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
17
 * NO EVENT SHALL DAVID REVEMAN 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
#include <X11/fonts/fontstruct.h>
 
29
#include "dixfontstr.h"
 
30
 
 
31
Bool
 
32
xglSolid (DrawablePtr      pDrawable,
 
33
          glitz_operator_t op,
 
34
          glitz_surface_t  *solid,
 
35
          xglGeometryPtr   pGeometry,
 
36
          int              x,
 
37
          int              y,
 
38
          int              width,
 
39
          int              height,
 
40
          BoxPtr           pBox,
 
41
          int              nBox)
 
42
{
 
43
    glitz_surface_t *surface;
 
44
    int             xOff, yOff;
 
45
 
 
46
    if (nBox < 1)
 
47
        return TRUE;
 
48
 
 
49
    if (!xglPrepareTarget (pDrawable))
 
50
        return FALSE;
 
51
 
 
52
    XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
 
53
 
 
54
    if (pGeometry)
 
55
    {
 
56
        glitz_surface_set_clip_region (surface, xOff, yOff,
 
57
                                       (glitz_box_t *) pBox, nBox);
 
58
    }
 
59
    else
 
60
    {
 
61
        pGeometry = xglGetScratchVertexGeometry (pDrawable->pScreen, 4 * nBox);
 
62
        GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox);
 
63
    }
 
64
 
 
65
    GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
 
66
 
 
67
    if (!GEOMETRY_ENABLE (pGeometry, surface))
 
68
        return FALSE;
 
69
 
 
70
    glitz_composite (op,
 
71
                     solid, NULL, surface,
 
72
                     0, 0,
 
73
                     0, 0,
 
74
                     x + xOff,
 
75
                     y + yOff,
 
76
                     width, height);
 
77
 
 
78
    glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
 
79
 
 
80
    if (glitz_surface_get_status (surface))
 
81
        return FALSE;
 
82
 
 
83
    return TRUE;
 
84
}
 
85
 
 
86
Bool
 
87
xglSolidGlyph (DrawablePtr  pDrawable,
 
88
               GCPtr        pGC,
 
89
               int          x,
 
90
               int          y,
 
91
               unsigned int nGlyph,
 
92
               CharInfoPtr  *ppci,
 
93
               pointer      pglyphBase)
 
94
{
 
95
    xglGeometryRec geometry;
 
96
    int            xBack, widthBack;
 
97
    int            yBack, heightBack;
 
98
 
 
99
    XGL_GC_PRIV (pGC);
 
100
 
 
101
    x += pDrawable->x;
 
102
    y += pDrawable->y;
 
103
 
 
104
    GEOMETRY_INIT (pDrawable->pScreen, &geometry,
 
105
                   GLITZ_GEOMETRY_TYPE_BITMAP,
 
106
                   GEOMETRY_USAGE_SYSMEM, 0);
 
107
 
 
108
    GEOMETRY_FOR_GLYPH (pDrawable->pScreen,
 
109
                        &geometry,
 
110
                        nGlyph,
 
111
                        ppci,
 
112
                        pglyphBase);
 
113
 
 
114
    GEOMETRY_TRANSLATE (&geometry, x, y);
 
115
 
 
116
    widthBack = 0;
 
117
    while (nGlyph--)
 
118
        widthBack += (*ppci++)->metrics.characterWidth;
 
119
 
 
120
    xBack = x;
 
121
    if (widthBack < 0)
 
122
    {
 
123
        xBack += widthBack;
 
124
        widthBack = -widthBack;
 
125
    }
 
126
    yBack = y - FONTASCENT (pGC->font);
 
127
    heightBack = FONTASCENT (pGC->font) + FONTDESCENT (pGC->font);
 
128
 
 
129
    if (xglSolid (pDrawable,
 
130
                  pGCPriv->op,
 
131
                  pGCPriv->bg,
 
132
                  NULL,
 
133
                  xBack,
 
134
                  yBack,
 
135
                  widthBack,
 
136
                  heightBack,
 
137
                  REGION_RECTS (pGC->pCompositeClip),
 
138
                  REGION_NUM_RECTS (pGC->pCompositeClip)))
 
139
    {
 
140
        if (xglSolid (pDrawable,
 
141
                      pGCPriv->op,
 
142
                      pGCPriv->fg,
 
143
                      &geometry,
 
144
                      xBack,
 
145
                      yBack,
 
146
                      widthBack,
 
147
                      heightBack,
 
148
                      REGION_RECTS (pGC->pCompositeClip),
 
149
                      REGION_NUM_RECTS (pGC->pCompositeClip)))
 
150
        {
 
151
            GEOMETRY_UNINIT (&geometry);
 
152
            xglAddCurrentBitDamage (pDrawable);
 
153
            return TRUE;
 
154
        }
 
155
    }
 
156
 
 
157
    GEOMETRY_UNINIT (&geometry);
 
158
    return FALSE;
 
159
}