2 * Copyright IBM Corporation 1987,1988,1989
6 * Permission to use, copy, modify, and distribute this software and its
7 * documentation for any purpose and without fee is hereby granted,
8 * provided that the above copyright notice appear in all copies and that
9 * both that copyright notice and this permission notice appear in
10 * supporting documentation, and that the name of IBM not be
11 * used in advertising or publicity pertaining to distribution of the
12 * software without specific, written prior permission.
14 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16 * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
24 #ifdef HAVE_XORG_CONFIG_H
25 #include <xorg-config.h>
31 #include "OScompiler.h"
33 #include "scrnintstr.h"
36 /* Was MIGETIMAGE -- public entry for the GetImage Request
37 * We're getting the image into a memory buffer. While we have to use GetSpans
38 * to read a line from the device ( since we don't know what that looks like ) ,
39 * we can just write into the destination buffer
41 * two different strategies are used, depending on whether we're getting the
42 * image in Z format or XY format
44 * Line at a time, GetSpans a line and bcopy it to the destination
45 * buffer, except that if the planemask is not all ones, we create a
46 * temporary pixmap and do a SetSpans into it ( to get bits turned off )
47 * and then another GetSpans to get stuff back ( because pixmaps are
48 * opaque, and we are passed in the memory to write into ) . This is
49 * completely ugly and slow but works, but the interfaces just aren't
50 * designed for this case. Life is hard.
52 * get the single plane specified in planemask
55 xf4bppGetImage( pDraw
, sx
, sy
, w
, h
, format
, planeMask
, pdstLine
)
59 unsigned long planeMask
;
63 int depth
, i
, linelength
, width
;
67 PixmapPtr pPixmap
= (PixmapPtr
) NULL
;
69 char *pDst
= pdstLine
;
71 depth
= pDraw
->depth
;
72 if ( format
== ZPixmap
) {
73 linelength
= PixmapBytePad( w
, depth
) ;
74 /* if ( pDraw->type == DRAWABLE_WINDOW ) { */
78 if ( ( ( ( 1 << pDraw
->depth
) - 1 ) & planeMask
)
79 != (unsigned)( 1 << pDraw
->depth
) - 1 ) {
80 pGC
= GetScratchGC( depth
, pDraw
->pScreen
) ;
82 (* pDraw
->pScreen
->CreatePixmap
)( pDraw
->pScreen
, w
, h
, depth
) ;
85 DoChangeGC( pGC
, GCPlaneMask
| GCFunction
, gcv
, 0 ) ;
86 ValidateGC( (DrawablePtr
)pPixmap
, pGC
) ;
88 pbits
= (char *)ALLOCATE_LOCAL(w
);
90 for ( i
= 0 ; i
< h
; i
++ ) {
94 (* pDraw
->pScreen
->GetSpans
)( pDraw
, w
, &pt
, &width
, 1, pbits
) ;
98 if ( planeMask
& ((1 << depth
) - 1) ) /* GJA -- mfb bug */
99 (* pGC
->ops
->SetSpans
)( (DrawablePtr
)pPixmap
, pGC
, pbits
, &pt
, &width
, 1, TRUE
) ;
100 (* pDraw
->pScreen
->GetSpans
)( (DrawablePtr
)pPixmap
, w
, &pt
, &width
, 1, pDst
) ;
104 DEALLOCATE_LOCAL(pbits
) ;
105 (* pGC
->pScreen
->DestroyPixmap
)( pPixmap
) ;
106 FreeScratchGC( pGC
) ;
110 for ( i
= 0 ; i
< h
; i
++ ) {
114 (* pDraw
->pScreen
->GetSpans
)( pDraw
, w
, &pt
, &width
, 1, pDst
) ;
120 miGetImage( pDraw
, sx
, sy
, w
, h
, format
, planeMask
, pdstLine
) ;