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#include "../src/common_compat.h" 63 64#define SAA_INVALID_ADDRESS \ 65 ((void *) ((unsigned long) 0xFFFFFFFF - 1024*1024)) 66 67struct saa_gc_priv { 68 /* GC values from the layer below. */ 69 CONST_ABI_18_0 GCOps *saved_ops; 70 CONST_ABI_18_0 GCFuncs *saved_funcs; 71}; 72 73struct saa_screen_priv { 74 struct saa_driver *driver; 75 CreateGCProcPtr saved_CreateGC; 76 CloseScreenProcPtr saved_CloseScreen; 77 CloseScreenProcPtr saved_early_CloseScreen; 78 GetImageProcPtr saved_GetImage; 79 GetSpansProcPtr saved_GetSpans; 80 CreatePixmapProcPtr saved_CreatePixmap; 81 DestroyPixmapProcPtr saved_DestroyPixmap; 82 CopyWindowProcPtr saved_CopyWindow; 83 ChangeWindowAttributesProcPtr saved_ChangeWindowAttributes; 84 BitmapToRegionProcPtr saved_BitmapToRegion; 85 ModifyPixmapHeaderProcPtr saved_ModifyPixmapHeader; 86#ifdef RENDER 87 CompositeProcPtr saved_Composite; 88 CompositeRectsProcPtr saved_CompositeRects; 89 TrianglesProcPtr saved_Triangles; 90 GlyphsProcPtr saved_Glyphs; 91 TrapezoidsProcPtr saved_Trapezoids; 92 AddTrapsProcPtr saved_AddTraps; 93 UnrealizeGlyphProcPtr saved_UnrealizeGlyph; 94 SourceValidateProcPtr saved_SourceValidate; 95#endif 96 Bool fallback_debug; 97 98 unsigned int fallback_count; 99 100 RegionRec srcReg; 101 RegionRec maskReg; 102 DrawablePtr srcDraw; 103}; 104 105extern GCOps saa_gc_ops; 106 107#if DEBUG_TRACE_FALL 108#define SAA_FALLBACK(x) \ 109do { \ 110 ErrorF("SAA fallback at %s: ", __FUNCTION__); \ 111 ErrorF x; \ 112} while (0) 113 114#define saa_drawable_location() ("u") 115#else 116#define SAA_FALLBACK(x) 117#endif 118 119/* 120 * Some macros to deal with function wrapping. 121 */ 122#define saa_wrap(priv, real, mem, func) {\ 123 (priv)->saved_##mem = (real)->mem; \ 124 (real)->mem = func; \ 125} 126 127#define saa_unwrap(priv, real, mem) {\ 128 (real)->mem = (priv)->saved_##mem; \ 129} 130 131#define saa_wrap_early(priv, real, mem, func) { \ 132 (priv)->saved_early_##mem = (real)->mem; \ 133 (real)->mem = func; \ 134} 135 136#define saa_unwrap_early(priv, real, mem) { \ 137 (real)->mem = (priv)->saved_early_##mem; \ 138} 139 140#define saa_swap(priv, real, mem) {\ 141 CONST_ABI_18_0 void *tmp = (priv)->saved_##mem; \ 142 (priv)->saved_##mem = (real)->mem; \ 143 (real)->mem = tmp; \ 144} 145 146#if (GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 8) 147#define SAA_DEVPRIVATEKEYREC 1 148 149extern DevPrivateKeyRec saa_screen_index; 150extern DevPrivateKeyRec saa_pixmap_index; 151extern DevPrivateKeyRec saa_gc_index; 152 153static inline struct saa_screen_priv * 154saa_screen(ScreenPtr screen) 155{ 156 return (struct saa_screen_priv *)dixGetPrivate(&screen->devPrivates, 157 &saa_screen_index); 158} 159 160static inline struct saa_gc_priv * 161saa_gc(GCPtr gc) 162{ 163 return (struct saa_gc_priv *)dixGetPrivateAddr(&gc->devPrivates, 164 &saa_gc_index); 165} 166 167static inline struct saa_pixmap * 168saa_pixmap(PixmapPtr pix) 169{ 170 return (struct saa_pixmap *)dixGetPrivateAddr(&pix->devPrivates, 171 &saa_pixmap_index); 172} 173#else 174#undef SAA_DEVPRIVATEKEYREC 175extern int saa_screen_index; 176extern int saa_pixmap_index; 177extern int saa_gc_index; 178 179static inline struct saa_screen_priv * 180saa_screen(ScreenPtr screen) 181{ 182 return (struct saa_screen_priv *)dixLookupPrivate(&screen->devPrivates, 183 &saa_screen_index); 184} 185 186static inline struct saa_gc_priv * 187saa_gc(GCPtr gc) 188{ 189 return (struct saa_gc_priv *)dixLookupPrivateAddr(&gc->devPrivates, 190 &saa_gc_index); 191} 192 193static inline struct saa_pixmap * 194saa_pixmap(PixmapPtr pix) 195{ 196 return (struct saa_pixmap *)dixLookupPrivateAddr(&pix->devPrivates, 197 &saa_pixmap_index); 198} 199 200#endif 201 202extern void 203saa_check_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int nspans, 204 DDXPointPtr ppt, int *pwidth, int fSorted); 205extern void 206saa_check_poly_fill_rect(DrawablePtr pDrawable, GCPtr pGC, 207 int nrect, xRectangle * prect); 208extern RegionPtr 209saa_check_copy_area(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, 210 int srcx, int srcy, int w, int h, int dstx, int dsty); 211extern void 212saa_check_copy_nton(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, 213 BoxPtr pbox, int nbox, int dx, int dy, Bool reverse, 214 Bool upsidedown, Pixel bitplane, void *closure); 215 216extern void 217saa_unaccel_setup(ScreenPtr pScreen); 218 219extern void 220saa_unaccel_takedown(ScreenPtr pScreen); 221 222extern RegionPtr 223saa_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, 224 int srcx, int srcy, int width, int height, int dstx, int dsty); 225 226extern Bool 227saa_hw_copy_nton(DrawablePtr pSrcDrawable, 228 DrawablePtr pDstDrawable, 229 GCPtr pGC, 230 BoxPtr pbox, 231 int nbox, int dx, int dy, Bool reverse, Bool upsidedown); 232 233#ifdef RENDER 234extern void 235saa_render_setup(ScreenPtr pScreen); 236 237extern void 238saa_render_takedown(ScreenPtr pScreen); 239 240 241extern void 242saa_check_composite(CARD8 op, 243 PicturePtr pSrc, 244 PicturePtr pMask, 245 PicturePtr pDst, 246 INT16 xSrc, 247 INT16 ySrc, 248 INT16 xMask, 249 INT16 yMask, 250 INT16 xDst, INT16 yDst, CARD16 width, CARD16 height, 251 RegionPtr src_region, 252 RegionPtr mask_region, 253 RegionPtr dst_region); 254#endif 255 256extern Bool 257saa_modify_pixmap_header(PixmapPtr pPixmap, int width, int height, int depth, 258 int bitsPerPixel, int devKind, pointer pPixData); 259 260extern PixmapPtr 261saa_create_pixmap(ScreenPtr pScreen, int w, int h, int depth, 262 unsigned usage_hint); 263 264extern Bool 265saa_destroy_pixmap(PixmapPtr pPixmap); 266 267static inline RegionPtr 268saa_pix_damage_pending(struct saa_pixmap *spix) 269{ 270 return (spix->damage ? DamagePendingRegion(spix->damage) : NULL); 271} 272 273extern RegionPtr 274saa_boxes_to_region(ScreenPtr pScreen, int nbox, BoxPtr pbox, int ordering); 275 276 277Bool 278saa_compute_composite_regions(ScreenPtr pScreen, 279 PicturePtr pSrc, 280 PicturePtr pMask, 281 PicturePtr pDst, 282 INT16 xSrc, INT16 ySrc, INT16 xMask, 283 INT16 yMask, INT16 xDst, 284 INT16 yDst, INT16 width, INT16 height, 285 RegionPtr dst_reg, 286 RegionPtr *src_reg, 287 RegionPtr *mask_reg); 288 289#endif 290