1706f2543Smrg/*
2706f2543Smrg *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
3706f2543Smrg *
4706f2543Smrg *Permission is hereby granted, free of charge, to any person obtaining
5706f2543Smrg * a copy of this software and associated documentation files (the
6706f2543Smrg *"Software"), to deal in the Software without restriction, including
7706f2543Smrg *without limitation the rights to use, copy, modify, merge, publish,
8706f2543Smrg *distribute, sublicense, and/or sell copies of the Software, and to
9706f2543Smrg *permit persons to whom the Software is furnished to do so, subject to
10706f2543Smrg *the following conditions:
11706f2543Smrg *
12706f2543Smrg *The above copyright notice and this permission notice shall be
13706f2543Smrg *included in all copies or substantial portions of the Software.
14706f2543Smrg *
15706f2543Smrg *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16706f2543Smrg *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17706f2543Smrg *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18706f2543Smrg *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
19706f2543Smrg *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20706f2543Smrg *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21706f2543Smrg *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22706f2543Smrg *
23706f2543Smrg *Except as contained in this notice, the name of Harold L Hunt II
24706f2543Smrg *shall not be used in advertising or otherwise to promote the sale, use
25706f2543Smrg *or other dealings in this Software without prior written authorization
26706f2543Smrg *from Harold L Hunt II.
27706f2543Smrg *
28706f2543Smrg * Authors:	Harold L Hunt II
29706f2543Smrg */
30706f2543Smrg
31706f2543Smrg#ifdef HAVE_XWIN_CONFIG_H
32706f2543Smrg#include <xwin-config.h>
33706f2543Smrg#endif
34706f2543Smrg#include "win.h"
35706f2543Smrg
36706f2543Smrgvoid
37706f2543SmrgwinPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg);
38706f2543Smrg
39706f2543Smrg
40706f2543Smrg/*
41706f2543Smrg * Local prototypes
42706f2543Smrg */
43706f2543Smrg
44706f2543Smrg#if 0
45706f2543Smrgstatic void
46706f2543SmrgwinChangeGCNativeGDI (GCPtr pGC, unsigned long ulChanges);
47706f2543Smrg#endif
48706f2543Smrg
49706f2543Smrgstatic void
50706f2543SmrgwinValidateGCNativeGDI (GCPtr pGC,
51706f2543Smrg			unsigned long changes,
52706f2543Smrg			DrawablePtr pDrawable);
53706f2543Smrg
54706f2543Smrg#if 0
55706f2543Smrgstatic void
56706f2543SmrgwinCopyGCNativeGDI (GCPtr pGCsrc, unsigned long ulMask, GCPtr pGCdst);
57706f2543Smrg#endif
58706f2543Smrg
59706f2543Smrgstatic void
60706f2543SmrgwinDestroyGCNativeGDI (GCPtr pGC);
61706f2543Smrg
62706f2543Smrg#if 0
63706f2543Smrgstatic void
64706f2543SmrgwinChangeClipNativeGDI (GCPtr pGC, int nType, pointer pValue, int nRects);
65706f2543Smrg
66706f2543Smrgstatic void
67706f2543SmrgwinDestroyClipNativeGDI (GCPtr pGC);
68706f2543Smrg
69706f2543Smrgstatic void
70706f2543SmrgwinCopyClipNativeGDI (GCPtr pGCdst, GCPtr pGCsrc);
71706f2543Smrg#endif
72706f2543Smrg
73706f2543Smrg#if 0
74706f2543Smrg/* GC Handling Routines */
75706f2543Smrgconst GCFuncs winGCFuncs = {
76706f2543Smrg  winValidateGCNativeGDI,
77706f2543Smrg  winChangeGCNativeGDI,
78706f2543Smrg  winCopyGCNativeGDI,
79706f2543Smrg  winDestroyGCNativeGDI,
80706f2543Smrg  winChangeClipNativeGDI,
81706f2543Smrg  winDestroyClipNativeGDI,
82706f2543Smrg  winCopyClipNativeGDI,
83706f2543Smrg};
84706f2543Smrg#else
85706f2543Smrgconst GCFuncs winGCFuncs = {
86706f2543Smrg  winValidateGCNativeGDI,
87706f2543Smrg  miChangeGC,
88706f2543Smrg  miCopyGC,
89706f2543Smrg  winDestroyGCNativeGDI,
90706f2543Smrg  miChangeClip,
91706f2543Smrg  miDestroyClip,
92706f2543Smrg  miCopyClip,
93706f2543Smrg};
94706f2543Smrg#endif
95706f2543Smrg
96706f2543Smrg/* Drawing Primitives */
97706f2543Smrgconst GCOps winGCOps = {
98706f2543Smrg  winFillSpansNativeGDI,
99706f2543Smrg  winSetSpansNativeGDI,
100706f2543Smrg  miPutImage,
101706f2543Smrg  miCopyArea,
102706f2543Smrg  miCopyPlane,
103706f2543Smrg  miPolyPoint,
104706f2543Smrg  winPolyLineNativeGDI,
105706f2543Smrg  miPolySegment,
106706f2543Smrg  miPolyRectangle,
107706f2543Smrg  miPolyArc,
108706f2543Smrg  miFillPolygon,
109706f2543Smrg  miPolyFillRect,
110706f2543Smrg  miPolyFillArc,
111706f2543Smrg  miPolyText8,
112706f2543Smrg  miPolyText16,
113706f2543Smrg  miImageText8,
114706f2543Smrg  miImageText16,
115706f2543Smrg#if 0
116706f2543Smrg  winImageGlyphBltNativeGDI,
117706f2543Smrg  winPolyGlyphBltNativeGDI,
118706f2543Smrg#else
119706f2543Smrg  miImageGlyphBlt,
120706f2543Smrg  miPolyGlyphBlt,
121706f2543Smrg#endif
122706f2543Smrg  miPushPixels,
123706f2543Smrg};
124706f2543Smrg
125706f2543Smrg
126706f2543Smrg/* See Porting Layer Definition - p. 45 */
127706f2543Smrg/* See mfb/mfbgc.c - mfbCreateGC() */
128706f2543Smrg/* See Strategies for Porting - pp. 15, 16 */
129706f2543SmrgBool
130706f2543SmrgwinCreateGCNativeGDI (GCPtr pGC)
131706f2543Smrg{
132706f2543Smrg  winPrivGCPtr		pGCPriv = NULL;
133706f2543Smrg  winPrivScreenPtr	pScreenPriv = NULL;
134706f2543Smrg
135706f2543Smrg#if 0
136706f2543Smrg  ErrorF ("winCreateGCNativeGDI - depth: %d\n",
137706f2543Smrg	  pGC->depth);
138706f2543Smrg#endif
139706f2543Smrg
140706f2543Smrg  pGC->ops = (GCOps *) &winGCOps;
141706f2543Smrg  pGC->funcs = (GCFuncs *) &winGCFuncs;
142706f2543Smrg
143706f2543Smrg  /* We want all coordinates passed to spans functions to be screen relative */
144706f2543Smrg  pGC->miTranslate = TRUE;
145706f2543Smrg
146706f2543Smrg  /* Allocate privates for this GC */
147706f2543Smrg  pGCPriv = winGetGCPriv (pGC);
148706f2543Smrg  if (pGCPriv == NULL)
149706f2543Smrg    {
150706f2543Smrg      ErrorF ("winCreateGCNativeGDI () - Privates pointer was NULL\n");
151706f2543Smrg      return FALSE;
152706f2543Smrg    }
153706f2543Smrg
154706f2543Smrg  /* Create a new screen DC for the display window */
155706f2543Smrg  pScreenPriv = winGetScreenPriv (pGC->pScreen);
156706f2543Smrg  pGCPriv->hdc = GetDC (pScreenPriv->hwndScreen);
157706f2543Smrg
158706f2543Smrg  /* Allocate a memory DC for the GC */
159706f2543Smrg  pGCPriv->hdcMem = CreateCompatibleDC (pGCPriv->hdc);
160706f2543Smrg
161706f2543Smrg  return TRUE;
162706f2543Smrg}
163706f2543Smrg
164706f2543Smrg
165706f2543Smrg#if 0
166706f2543Smrg/* See Porting Layer Definition - p. 45 */
167706f2543Smrgstatic void
168706f2543SmrgwinChangeGCNativeGDI (GCPtr pGC, unsigned long ulChanges)
169706f2543Smrg{
170706f2543Smrg#if 0
171706f2543Smrg  ErrorF ("winChangeGCNativeGDI () - Doing nothing\n");
172706f2543Smrg#endif
173706f2543Smrg}
174706f2543Smrg#endif
175706f2543Smrg
176706f2543Smrg
177706f2543Smrgstatic void
178706f2543SmrgwinValidateGCNativeGDI (GCPtr pGC,
179706f2543Smrg			unsigned long ulChanges,
180706f2543Smrg			DrawablePtr pDrawable)
181706f2543Smrg{
182706f2543Smrg  if ((ulChanges & (GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode))
183706f2543Smrg      || (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)))
184706f2543Smrg  {
185706f2543Smrg    miComputeCompositeClip (pGC, pDrawable);
186706f2543Smrg  }
187706f2543Smrg}
188706f2543Smrg
189706f2543Smrg
190706f2543Smrg#if 0
191706f2543Smrg/* See Porting Layer Definition - p. 46 */
192706f2543Smrgstatic void
193706f2543SmrgwinCopyGCNativeGDI (GCPtr pGCsrc, unsigned long ulMask, GCPtr pGCdst)
194706f2543Smrg{
195706f2543Smrg
196706f2543Smrg}
197706f2543Smrg#endif
198706f2543Smrg
199706f2543Smrg
200706f2543Smrg/* See Porting Layer Definition - p. 46 */
201706f2543Smrgstatic void
202706f2543SmrgwinDestroyGCNativeGDI (GCPtr pGC)
203706f2543Smrg{
204706f2543Smrg  winGCPriv(pGC);
205706f2543Smrg  winScreenPriv(pGC->pScreen);
206706f2543Smrg
207706f2543Smrg  if (pGC->freeCompClip)
208706f2543Smrg	RegionDestroy(pGC->pCompositeClip);
209706f2543Smrg
210706f2543Smrg  /* Free the memory DC */
211706f2543Smrg  if (pGCPriv->hdcMem != NULL)
212706f2543Smrg    {
213706f2543Smrg      DeleteDC (pGCPriv->hdcMem);
214706f2543Smrg      pGCPriv->hdcMem = NULL;
215706f2543Smrg    }
216706f2543Smrg
217706f2543Smrg  /* Release the screen DC for the display window */
218706f2543Smrg  if (pGCPriv->hdc != NULL)
219706f2543Smrg    {
220706f2543Smrg      ReleaseDC (pScreenPriv->hwndScreen, pGCPriv->hdc);
221706f2543Smrg      pGCPriv->hdc = NULL;
222706f2543Smrg    }
223706f2543Smrg
224706f2543Smrg  /* Invalidate the GC privates pointer */
225706f2543Smrg  winSetGCPriv (pGC, NULL);
226706f2543Smrg}
227706f2543Smrg
228706f2543Smrg#if 0
229706f2543Smrg/* See Porting Layer Definition - p. 46 */
230706f2543Smrgstatic void
231706f2543SmrgwinChangeClipNativeGDI (GCPtr pGC, int nType, pointer pValue, int nRects)
232706f2543Smrg{
233706f2543Smrg
234706f2543Smrg}
235706f2543Smrg
236706f2543Smrg
237706f2543Smrg/* See Porting Layer Definition - p. 47 */
238706f2543Smrgstatic void
239706f2543SmrgwinDestroyClipNativeGDI (GCPtr pGC)
240706f2543Smrg{
241706f2543Smrg
242706f2543Smrg}
243706f2543Smrg
244706f2543Smrg
245706f2543Smrg/* See Porting Layer Definition - p. 47 */
246706f2543Smrgstatic void
247706f2543SmrgwinCopyClipNativeGDI (GCPtr pGCdst, GCPtr pGCsrc)
248706f2543Smrg{
249706f2543Smrg
250706f2543Smrg}
251706f2543Smrg#endif
252