1/* 2 *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved. 3 * 4 *Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files (the 6 *"Software"), to deal in the Software without restriction, including 7 *without limitation the rights to use, copy, modify, merge, publish, 8 *distribute, sublicense, and/or sell copies of the Software, and to 9 *permit persons to whom the Software is furnished to do so, subject to 10 *the following conditions: 11 * 12 *The above copyright notice and this permission notice shall be 13 *included in all copies or substantial portions of the Software. 14 * 15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR 19 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 20 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 * 23 *Except as contained in this notice, the name of Harold L Hunt II 24 *shall not be used in advertising or otherwise to promote the sale, use 25 *or other dealings in this Software without prior written authorization 26 *from Harold L Hunt II. 27 * 28 * Authors: Harold L Hunt II 29 */ 30 31#ifdef HAVE_XWIN_CONFIG_H 32#include <xwin-config.h> 33#endif 34#include "win.h" 35 36void 37winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg); 38 39 40/* 41 * Local prototypes 42 */ 43 44#if 0 45static void 46winChangeGCNativeGDI (GCPtr pGC, unsigned long ulChanges); 47#endif 48 49static void 50winValidateGCNativeGDI (GCPtr pGC, 51 unsigned long changes, 52 DrawablePtr pDrawable); 53 54#if 0 55static void 56winCopyGCNativeGDI (GCPtr pGCsrc, unsigned long ulMask, GCPtr pGCdst); 57#endif 58 59static void 60winDestroyGCNativeGDI (GCPtr pGC); 61 62#if 0 63static void 64winChangeClipNativeGDI (GCPtr pGC, int nType, pointer pValue, int nRects); 65 66static void 67winDestroyClipNativeGDI (GCPtr pGC); 68 69static void 70winCopyClipNativeGDI (GCPtr pGCdst, GCPtr pGCsrc); 71#endif 72 73#if 0 74/* GC Handling Routines */ 75const GCFuncs winGCFuncs = { 76 winValidateGCNativeGDI, 77 winChangeGCNativeGDI, 78 winCopyGCNativeGDI, 79 winDestroyGCNativeGDI, 80 winChangeClipNativeGDI, 81 winDestroyClipNativeGDI, 82 winCopyClipNativeGDI, 83}; 84#else 85const GCFuncs winGCFuncs = { 86 winValidateGCNativeGDI, 87 miChangeGC, 88 miCopyGC, 89 winDestroyGCNativeGDI, 90 miChangeClip, 91 miDestroyClip, 92 miCopyClip, 93}; 94#endif 95 96/* Drawing Primitives */ 97const GCOps winGCOps = { 98 winFillSpansNativeGDI, 99 winSetSpansNativeGDI, 100 miPutImage, 101 miCopyArea, 102 miCopyPlane, 103 miPolyPoint, 104 winPolyLineNativeGDI, 105 miPolySegment, 106 miPolyRectangle, 107 miPolyArc, 108 miFillPolygon, 109 miPolyFillRect, 110 miPolyFillArc, 111 miPolyText8, 112 miPolyText16, 113 miImageText8, 114 miImageText16, 115#if 0 116 winImageGlyphBltNativeGDI, 117 winPolyGlyphBltNativeGDI, 118#else 119 miImageGlyphBlt, 120 miPolyGlyphBlt, 121#endif 122 miPushPixels, 123}; 124 125 126/* See Porting Layer Definition - p. 45 */ 127/* See mfb/mfbgc.c - mfbCreateGC() */ 128/* See Strategies for Porting - pp. 15, 16 */ 129Bool 130winCreateGCNativeGDI (GCPtr pGC) 131{ 132 winPrivGCPtr pGCPriv = NULL; 133 winPrivScreenPtr pScreenPriv = NULL; 134 135#if 0 136 ErrorF ("winCreateGCNativeGDI - depth: %d\n", 137 pGC->depth); 138#endif 139 140 pGC->ops = (GCOps *) &winGCOps; 141 pGC->funcs = (GCFuncs *) &winGCFuncs; 142 143 /* We want all coordinates passed to spans functions to be screen relative */ 144 pGC->miTranslate = TRUE; 145 146 /* Allocate privates for this GC */ 147 pGCPriv = winGetGCPriv (pGC); 148 if (pGCPriv == NULL) 149 { 150 ErrorF ("winCreateGCNativeGDI () - Privates pointer was NULL\n"); 151 return FALSE; 152 } 153 154 /* Create a new screen DC for the display window */ 155 pScreenPriv = winGetScreenPriv (pGC->pScreen); 156 pGCPriv->hdc = GetDC (pScreenPriv->hwndScreen); 157 158 /* Allocate a memory DC for the GC */ 159 pGCPriv->hdcMem = CreateCompatibleDC (pGCPriv->hdc); 160 161 return TRUE; 162} 163 164 165#if 0 166/* See Porting Layer Definition - p. 45 */ 167static void 168winChangeGCNativeGDI (GCPtr pGC, unsigned long ulChanges) 169{ 170#if 0 171 ErrorF ("winChangeGCNativeGDI () - Doing nothing\n"); 172#endif 173} 174#endif 175 176 177static void 178winValidateGCNativeGDI (GCPtr pGC, 179 unsigned long ulChanges, 180 DrawablePtr pDrawable) 181{ 182 if ((ulChanges & (GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode)) 183 || (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))) 184 { 185 miComputeCompositeClip (pGC, pDrawable); 186 } 187} 188 189 190#if 0 191/* See Porting Layer Definition - p. 46 */ 192static void 193winCopyGCNativeGDI (GCPtr pGCsrc, unsigned long ulMask, GCPtr pGCdst) 194{ 195 196} 197#endif 198 199 200/* See Porting Layer Definition - p. 46 */ 201static void 202winDestroyGCNativeGDI (GCPtr pGC) 203{ 204 winGCPriv(pGC); 205 winScreenPriv(pGC->pScreen); 206 207 if (pGC->freeCompClip) 208 RegionDestroy(pGC->pCompositeClip); 209 210 /* Free the memory DC */ 211 if (pGCPriv->hdcMem != NULL) 212 { 213 DeleteDC (pGCPriv->hdcMem); 214 pGCPriv->hdcMem = NULL; 215 } 216 217 /* Release the screen DC for the display window */ 218 if (pGCPriv->hdc != NULL) 219 { 220 ReleaseDC (pScreenPriv->hwndScreen, pGCPriv->hdc); 221 pGCPriv->hdc = NULL; 222 } 223 224 /* Invalidate the GC privates pointer */ 225 winSetGCPriv (pGC, NULL); 226} 227 228#if 0 229/* See Porting Layer Definition - p. 46 */ 230static void 231winChangeClipNativeGDI (GCPtr pGC, int nType, pointer pValue, int nRects) 232{ 233 234} 235 236 237/* See Porting Layer Definition - p. 47 */ 238static void 239winDestroyClipNativeGDI (GCPtr pGC) 240{ 241 242} 243 244 245/* See Porting Layer Definition - p. 47 */ 246static void 247winCopyClipNativeGDI (GCPtr pGCdst, GCPtr pGCsrc) 248{ 249 250} 251#endif 252