1706f2543Smrg/* 2706f2543Smrg * Copyright © 1998 Keith Packard 3706f2543Smrg * 4706f2543Smrg * Permission to use, copy, modify, distribute, and sell this software and its 5706f2543Smrg * documentation for any purpose is hereby granted without fee, provided that 6706f2543Smrg * the above copyright notice appear in all copies and that both that 7706f2543Smrg * copyright notice and this permission notice appear in supporting 8706f2543Smrg * documentation, and that the name of Keith Packard not be used in 9706f2543Smrg * advertising or publicity pertaining to distribution of the software without 10706f2543Smrg * specific, written prior permission. Keith Packard makes no 11706f2543Smrg * representations about the suitability of this software for any purpose. It 12706f2543Smrg * is provided "as is" without express or implied warranty. 13706f2543Smrg * 14706f2543Smrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15706f2543Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16706f2543Smrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17706f2543Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18706f2543Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19706f2543Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 20706f2543Smrg * PERFORMANCE OF THIS SOFTWARE. 21706f2543Smrg */ 22706f2543Smrg 23706f2543Smrg#ifdef HAVE_DIX_CONFIG_H 24706f2543Smrg#include <dix-config.h> 25706f2543Smrg#endif 26706f2543Smrg 27706f2543Smrg#include <stdlib.h> 28706f2543Smrg 29706f2543Smrg#include "fb.h" 30706f2543Smrg 31706f2543SmrgBool 32706f2543SmrgfbCreateWindow(WindowPtr pWin) 33706f2543Smrg{ 34706f2543Smrg dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), 35706f2543Smrg fbGetScreenPixmap(pWin->drawable.pScreen)); 36706f2543Smrg#ifdef FB_SCREEN_PRIVATE 37706f2543Smrg if (pWin->drawable.bitsPerPixel == 32) 38706f2543Smrg pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp; 39706f2543Smrg#endif 40706f2543Smrg return TRUE; 41706f2543Smrg} 42706f2543Smrg 43706f2543SmrgBool 44706f2543SmrgfbDestroyWindow(WindowPtr pWin) 45706f2543Smrg{ 46706f2543Smrg return TRUE; 47706f2543Smrg} 48706f2543Smrg 49706f2543SmrgBool 50706f2543SmrgfbMapWindow(WindowPtr pWindow) 51706f2543Smrg{ 52706f2543Smrg return TRUE; 53706f2543Smrg} 54706f2543Smrg 55706f2543SmrgBool 56706f2543SmrgfbPositionWindow(WindowPtr pWin, int x, int y) 57706f2543Smrg{ 58706f2543Smrg return TRUE; 59706f2543Smrg} 60706f2543Smrg 61706f2543SmrgBool 62706f2543SmrgfbUnmapWindow(WindowPtr pWindow) 63706f2543Smrg{ 64706f2543Smrg return TRUE; 65706f2543Smrg} 66706f2543Smrg 67706f2543Smrgvoid 68706f2543SmrgfbCopyWindowProc (DrawablePtr pSrcDrawable, 69706f2543Smrg DrawablePtr pDstDrawable, 70706f2543Smrg GCPtr pGC, 71706f2543Smrg BoxPtr pbox, 72706f2543Smrg int nbox, 73706f2543Smrg int dx, 74706f2543Smrg int dy, 75706f2543Smrg Bool reverse, 76706f2543Smrg Bool upsidedown, 77706f2543Smrg Pixel bitplane, 78706f2543Smrg void *closure) 79706f2543Smrg{ 80706f2543Smrg FbBits *src; 81706f2543Smrg FbStride srcStride; 82706f2543Smrg int srcBpp; 83706f2543Smrg int srcXoff, srcYoff; 84706f2543Smrg FbBits *dst; 85706f2543Smrg FbStride dstStride; 86706f2543Smrg int dstBpp; 87706f2543Smrg int dstXoff, dstYoff; 88706f2543Smrg 89706f2543Smrg fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff); 90706f2543Smrg fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); 91706f2543Smrg 92706f2543Smrg while (nbox--) 93706f2543Smrg { 94706f2543Smrg fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride, 95706f2543Smrg srcStride, 96706f2543Smrg (pbox->x1 + dx + srcXoff) * srcBpp, 97706f2543Smrg 98706f2543Smrg dst + (pbox->y1 + dstYoff) * dstStride, 99706f2543Smrg dstStride, 100706f2543Smrg (pbox->x1 + dstXoff) * dstBpp, 101706f2543Smrg 102706f2543Smrg (pbox->x2 - pbox->x1) * dstBpp, 103706f2543Smrg (pbox->y2 - pbox->y1), 104706f2543Smrg 105706f2543Smrg GXcopy, 106706f2543Smrg FB_ALLONES, 107706f2543Smrg dstBpp, 108706f2543Smrg 109706f2543Smrg reverse, 110706f2543Smrg upsidedown); 111706f2543Smrg pbox++; 112706f2543Smrg } 113706f2543Smrg 114706f2543Smrg fbFinishAccess (pDstDrawable); 115706f2543Smrg fbFinishAccess (pSrcDrawable); 116706f2543Smrg} 117706f2543Smrg 118706f2543Smrgvoid 119706f2543SmrgfbCopyWindow(WindowPtr pWin, 120706f2543Smrg DDXPointRec ptOldOrg, 121706f2543Smrg RegionPtr prgnSrc) 122706f2543Smrg{ 123706f2543Smrg RegionRec rgnDst; 124706f2543Smrg int dx, dy; 125706f2543Smrg 126706f2543Smrg PixmapPtr pPixmap = fbGetWindowPixmap (pWin); 127706f2543Smrg DrawablePtr pDrawable = &pPixmap->drawable; 128706f2543Smrg 129706f2543Smrg dx = ptOldOrg.x - pWin->drawable.x; 130706f2543Smrg dy = ptOldOrg.y - pWin->drawable.y; 131706f2543Smrg RegionTranslate(prgnSrc, -dx, -dy); 132706f2543Smrg 133706f2543Smrg RegionNull(&rgnDst); 134706f2543Smrg 135706f2543Smrg RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc); 136706f2543Smrg 137706f2543Smrg#ifdef COMPOSITE 138706f2543Smrg if (pPixmap->screen_x || pPixmap->screen_y) 139706f2543Smrg RegionTranslate(&rgnDst, 140706f2543Smrg -pPixmap->screen_x, -pPixmap->screen_y); 141706f2543Smrg#endif 142706f2543Smrg 143706f2543Smrg miCopyRegion (pDrawable, pDrawable, 144706f2543Smrg 0, 145706f2543Smrg &rgnDst, dx, dy, fbCopyWindowProc, 0, 0); 146706f2543Smrg 147706f2543Smrg RegionUninit(&rgnDst); 148706f2543Smrg fbValidateDrawable (&pWin->drawable); 149706f2543Smrg} 150706f2543Smrg 151706f2543SmrgBool 152706f2543SmrgfbChangeWindowAttributes(WindowPtr pWin, unsigned long mask) 153706f2543Smrg{ 154706f2543Smrg PixmapPtr pPixmap; 155706f2543Smrg 156706f2543Smrg if (mask & CWBackPixmap) 157706f2543Smrg { 158706f2543Smrg if (pWin->backgroundState == BackgroundPixmap) 159706f2543Smrg { 160706f2543Smrg pPixmap = pWin->background.pixmap; 161706f2543Smrg#ifdef FB_24_32BIT 162706f2543Smrg if (pPixmap->drawable.bitsPerPixel != pWin->drawable.bitsPerPixel) 163706f2543Smrg { 164706f2543Smrg pPixmap = fb24_32ReformatTile (pPixmap, 165706f2543Smrg pWin->drawable.bitsPerPixel); 166706f2543Smrg if (pPixmap) 167706f2543Smrg { 168706f2543Smrg (*pWin->drawable.pScreen->DestroyPixmap) (pWin->background.pixmap); 169706f2543Smrg pWin->background.pixmap = pPixmap; 170706f2543Smrg } 171706f2543Smrg } 172706f2543Smrg#endif 173706f2543Smrg if (FbEvenTile (pPixmap->drawable.width * 174706f2543Smrg pPixmap->drawable.bitsPerPixel)) 175706f2543Smrg fbPadPixmap (pPixmap); 176706f2543Smrg } 177706f2543Smrg } 178706f2543Smrg if (mask & CWBorderPixmap) 179706f2543Smrg { 180706f2543Smrg if (pWin->borderIsPixel == FALSE) 181706f2543Smrg { 182706f2543Smrg pPixmap = pWin->border.pixmap; 183706f2543Smrg#ifdef FB_24_32BIT 184706f2543Smrg if (pPixmap->drawable.bitsPerPixel != 185706f2543Smrg pWin->drawable.bitsPerPixel) 186706f2543Smrg { 187706f2543Smrg pPixmap = fb24_32ReformatTile (pPixmap, 188706f2543Smrg pWin->drawable.bitsPerPixel); 189706f2543Smrg if (pPixmap) 190706f2543Smrg { 191706f2543Smrg (*pWin->drawable.pScreen->DestroyPixmap) (pWin->border.pixmap); 192706f2543Smrg pWin->border.pixmap = pPixmap; 193706f2543Smrg } 194706f2543Smrg } 195706f2543Smrg#endif 196706f2543Smrg if (FbEvenTile (pPixmap->drawable.width * 197706f2543Smrg pPixmap->drawable.bitsPerPixel)) 198706f2543Smrg fbPadPixmap (pPixmap); 199706f2543Smrg } 200706f2543Smrg } 201706f2543Smrg return TRUE; 202706f2543Smrg} 203706f2543Smrg 204706f2543Smrgvoid 205706f2543SmrgfbFillRegionSolid (DrawablePtr pDrawable, 206706f2543Smrg RegionPtr pRegion, 207706f2543Smrg FbBits and, 208706f2543Smrg FbBits xor) 209706f2543Smrg{ 210706f2543Smrg FbBits *dst; 211706f2543Smrg FbStride dstStride; 212706f2543Smrg int dstBpp; 213706f2543Smrg int dstXoff, dstYoff; 214706f2543Smrg int n = RegionNumRects(pRegion); 215706f2543Smrg BoxPtr pbox = RegionRects(pRegion); 216706f2543Smrg 217706f2543Smrg#ifndef FB_ACCESS_WRAPPER 218706f2543Smrg int try_mmx = 0; 219706f2543Smrg if (!and) 220706f2543Smrg try_mmx = 1; 221706f2543Smrg#endif 222706f2543Smrg 223706f2543Smrg fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); 224706f2543Smrg 225706f2543Smrg while (n--) 226706f2543Smrg { 227706f2543Smrg#ifndef FB_ACCESS_WRAPPER 228706f2543Smrg if (!try_mmx || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp, 229706f2543Smrg pbox->x1 + dstXoff, pbox->y1 + dstYoff, 230706f2543Smrg (pbox->x2 - pbox->x1), 231706f2543Smrg (pbox->y2 - pbox->y1), 232706f2543Smrg xor)) 233706f2543Smrg { 234706f2543Smrg#endif 235706f2543Smrg fbSolid (dst + (pbox->y1 + dstYoff) * dstStride, 236706f2543Smrg dstStride, 237706f2543Smrg (pbox->x1 + dstXoff) * dstBpp, 238706f2543Smrg dstBpp, 239706f2543Smrg (pbox->x2 - pbox->x1) * dstBpp, 240706f2543Smrg pbox->y2 - pbox->y1, 241706f2543Smrg and, xor); 242706f2543Smrg#ifndef FB_ACCESS_WRAPPER 243706f2543Smrg } 244706f2543Smrg#endif 245706f2543Smrg fbValidateDrawable (pDrawable); 246706f2543Smrg pbox++; 247706f2543Smrg } 248706f2543Smrg 249706f2543Smrg fbFinishAccess (pDrawable); 250706f2543Smrg} 251