saa_priv.h revision 3bfa90b6
1/* 2 * 3 * Copyright (C) 2000 Keith Packard, member of The XFree86 Project, Inc. 4 * 2005 Zack Rusin, Trolltech 5 * Copyright 2011 VMWare, inc. All rights reserved. 6 * 7 * Permission to use, copy, modify, distribute, and sell this software and its 8 * documentation for any purpose is hereby granted without fee, provided that 9 * the above copyright notice appear in all copies and that both that 10 * copyright notice and this permission notice appear in supporting 11 * documentation, and that the name of Keith Packard not be used in 12 * advertising or publicity pertaining to distribution of the software without 13 * specific, written prior permission. Keith Packard makes no 14 * representations about the suitability of this software for any purpose. It 15 * is provided "as is" without express or implied warranty. 16 * 17 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 18 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 19 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 21 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 22 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 23 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 24 * SOFTWARE. 25 * 26 * Authors: Based on exa_priv.h 27 * Authors: Thomas Hellstrom <thellstrom@vmware.com> 28 */ 29 30#ifndef _SAA_PRIV_H 31#define _SAA_PRIV_H 32 33#ifdef HAVE_CONFIG_H 34#include <config.h> 35#endif 36#ifdef HAVE_DIX_CONFIG_H 37#include <dix-config.h> 38#else 39#include <xorg-server.h> 40#endif 41#include "xf86.h" 42 43#include "saa.h" 44 45#include <X11/X.h> 46#include <X11/Xproto.h> 47#include "scrnintstr.h" 48#include "pixmapstr.h" 49#include "windowstr.h" 50#include "servermd.h" 51#include "colormapst.h" 52#include "gcstruct.h" 53#include "input.h" 54#include "mipointer.h" 55#include "mi.h" 56#include "dix.h" 57#include "fb.h" 58#ifdef RENDER 59#include "glyphstr.h" 60#endif 61#include "damage.h" 62 63#define SAA_INVALID_ADDRESS \ 64 ((void *) ((unsigned long) 0xFFFFFFFF - 1024*1024)) 65 66struct saa_gc_priv { 67 /* GC values from the layer below. */ 68 GCOps *saved_ops; 69 GCFuncs *saved_funcs; 70}; 71 72struct saa_screen_priv { 73 struct saa_driver *driver; 74 CreateGCProcPtr saved_CreateGC; 75 CloseScreenProcPtr saved_CloseScreen; 76 GetImageProcPtr saved_GetImage; 77 GetSpansProcPtr saved_GetSpans; 78 CreatePixmapProcPtr saved_CreatePixmap; 79 DestroyPixmapProcPtr saved_DestroyPixmap; 80 CopyWindowProcPtr saved_CopyWindow; 81 ChangeWindowAttributesProcPtr saved_ChangeWindowAttributes; 82 BitmapToRegionProcPtr saved_BitmapToRegion; 83 ModifyPixmapHeaderProcPtr saved_ModifyPixmapHeader; 84#ifdef RENDER 85 CompositeProcPtr saved_Composite; 86 CompositeRectsProcPtr saved_CompositeRects; 87 TrianglesProcPtr saved_Triangles; 88 GlyphsProcPtr saved_Glyphs; 89 TrapezoidsProcPtr saved_Trapezoids; 90 AddTrapsProcPtr saved_AddTraps; 91 UnrealizeGlyphProcPtr saved_UnrealizeGlyph; 92 SourceValidateProcPtr saved_SourceValidate; 93#endif 94 Bool fallback_debug; 95 96 unsigned int fallback_count; 97 98 RegionRec srcReg; 99 RegionRec maskReg; 100 DrawablePtr srcDraw; 101}; 102 103extern GCOps saa_gc_ops; 104 105#if DEBUG_TRACE_FALL 106#define SAA_FALLBACK(x) \ 107do { \ 108 ErrorF("SAA fallback at %s: ", __FUNCTION__); \ 109 ErrorF x; \ 110} while (0) 111 112#define saa_drawable_location() ("u") 113#else 114#define SAA_FALLBACK(x) 115#endif 116 117/* 118 * Some macros to deal with function wrapping. 119 */ 120#define saa_wrap(priv, real, mem, func) {\ 121 (priv)->saved_##mem = (real)->mem; \ 122 (real)->mem = func; \ 123} 124 125#define saa_unwrap(priv, real, mem) {\ 126 (real)->mem = (priv)->saved_##mem; \ 127} 128 129#define saa_swap(priv, real, mem) {\ 130 void *tmp = (priv)->saved_##mem; \ 131 (priv)->saved_##mem = (real)->mem; \ 132 (real)->mem = tmp; \ 133} 134 135#if (GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 8) 136#define SAA_DEVPRIVATEKEYREC 1 137 138extern DevPrivateKeyRec saa_screen_index; 139extern DevPrivateKeyRec saa_pixmap_index; 140extern DevPrivateKeyRec saa_gc_index; 141 142static inline struct saa_screen_priv * 143saa_screen(ScreenPtr screen) 144{ 145 return (struct saa_screen_priv *)dixGetPrivate(&screen->devPrivates, 146 &saa_screen_index); 147} 148 149static inline struct saa_gc_priv * 150saa_gc(GCPtr gc) 151{ 152 return (struct saa_gc_priv *)dixGetPrivateAddr(&gc->devPrivates, 153 &saa_gc_index); 154} 155 156static inline struct saa_pixmap * 157saa_pixmap(PixmapPtr pix) 158{ 159 return (struct saa_pixmap *)dixGetPrivateAddr(&pix->devPrivates, 160 &saa_pixmap_index); 161} 162#else 163#undef SAA_DEVPRIVATEKEYREC 164extern int saa_screen_index; 165extern int saa_pixmap_index; 166extern int saa_gc_index; 167 168static inline struct saa_screen_priv * 169saa_screen(ScreenPtr screen) 170{ 171 return (struct saa_screen_priv *)dixLookupPrivate(&screen->devPrivates, 172 &saa_screen_index); 173} 174 175static inline struct saa_gc_priv * 176saa_gc(GCPtr gc) 177{ 178 return (struct saa_gc_priv *)dixLookupPrivateAddr(&gc->devPrivates, 179 &saa_gc_index); 180} 181 182static inline struct saa_pixmap * 183saa_pixmap(PixmapPtr pix) 184{ 185 return (struct saa_pixmap *)dixLookupPrivateAddr(&pix->devPrivates, 186 &saa_pixmap_index); 187} 188 189#endif 190 191extern void 192saa_check_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int nspans, 193 DDXPointPtr ppt, int *pwidth, int fSorted); 194extern void 195saa_check_poly_fill_rect(DrawablePtr pDrawable, GCPtr pGC, 196 int nrect, xRectangle * prect); 197extern RegionPtr 198saa_check_copy_area(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, 199 int srcx, int srcy, int w, int h, int dstx, int dsty); 200extern void 201saa_check_copy_nton(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, 202 BoxPtr pbox, int nbox, int dx, int dy, Bool reverse, 203 Bool upsidedown, Pixel bitplane, void *closure); 204 205extern void 206saa_unaccel_setup(ScreenPtr pScreen); 207 208extern void 209saa_unaccel_takedown(ScreenPtr pScreen); 210 211extern RegionPtr 212saa_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, 213 int srcx, int srcy, int width, int height, int dstx, int dsty); 214 215extern Bool 216saa_hw_copy_nton(DrawablePtr pSrcDrawable, 217 DrawablePtr pDstDrawable, 218 GCPtr pGC, 219 BoxPtr pbox, 220 int nbox, int dx, int dy, Bool reverse, Bool upsidedown); 221 222#ifdef RENDER 223extern void 224saa_render_setup(ScreenPtr pScreen); 225 226extern void 227saa_render_takedown(ScreenPtr pScreen); 228 229 230extern void 231saa_check_composite(CARD8 op, 232 PicturePtr pSrc, 233 PicturePtr pMask, 234 PicturePtr pDst, 235 INT16 xSrc, 236 INT16 ySrc, 237 INT16 xMask, 238 INT16 yMask, 239 INT16 xDst, INT16 yDst, CARD16 width, CARD16 height, 240 RegionPtr src_region, 241 RegionPtr mask_region, 242 RegionPtr dst_region); 243#endif 244 245extern Bool 246saa_modify_pixmap_header(PixmapPtr pPixmap, int width, int height, int depth, 247 int bitsPerPixel, int devKind, pointer pPixData); 248 249extern PixmapPtr 250saa_create_pixmap(ScreenPtr pScreen, int w, int h, int depth, 251 unsigned usage_hint); 252 253extern Bool 254saa_destroy_pixmap(PixmapPtr pPixmap); 255 256static inline RegionPtr 257saa_pix_damage_pending(struct saa_pixmap *spix) 258{ 259 return (spix->damage ? DamagePendingRegion(spix->damage) : NULL); 260} 261 262extern RegionPtr 263saa_boxes_to_region(ScreenPtr pScreen, int nbox, BoxPtr pbox, int ordering); 264 265 266Bool 267saa_compute_composite_regions(ScreenPtr pScreen, 268 PicturePtr pSrc, 269 PicturePtr pMask, 270 PicturePtr pDst, 271 INT16 xSrc, INT16 ySrc, INT16 xMask, 272 INT16 yMask, INT16 xDst, 273 INT16 yDst, INT16 width, INT16 height, 274 RegionPtr dst_reg, 275 RegionPtr *src_reg, 276 RegionPtr *mask_reg); 277 278#endif 279