a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/******************************************************************************
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Copyright (c) 1994, 1995 Hewlett-Packard Company
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Permission is hereby granted, free of charge, to any person obtaining
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * a copy of this software and associated documentation files (the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * "Software"), to deal in the Software without restriction, including
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * without limitation the rights to use, copy, modify, merge, publish,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * distribute, sublicense, and/or sell copies of the Software, and to
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * permit persons to whom the Software is furnished to do so, subject to
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * the following conditions:
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * The above copyright notice and this permission notice shall be included
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * in all copies or substantial portions of the Software.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Except as contained in this notice, the name of the Hewlett-Packard
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Company shall not be used in advertising or otherwise to promote the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * sale, use or other dealings in this Software without prior written
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * authorization from the Hewlett-Packard Company.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Header file for DIX-related DBE
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *****************************************************************************/
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#ifndef DBE_STRUCT_H
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define DBE_STRUCT_H
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* INCLUDES */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define NEED_DBE_PROTOCOL
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#include <X11/extensions/dbeproto.h>
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#include "windowstr.h"
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#include "privates.h"
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync VisualID visual; /* one visual ID that supports double-buffering */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int depth; /* depth of visual in bits */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int perflevel; /* performance level of visual */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync} XdbeVisualInfo;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int count; /* number of items in visual_depth */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync XdbeVisualInfo *visinfo; /* list of visuals & depths for scrn */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync} XdbeScreenVisualInfo;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* DEFINES */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define DBE_SCREEN_PRIV(pScreen) ((DbeScreenPrivPtr) \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync dixLookupPrivate(&(pScreen)->devPrivates, dbeScreenPrivKey))
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync DBE_SCREEN_PRIV((pDrawable)->pScreen)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(pDbeWindowPriv) \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync DBE_SCREEN_PRIV((pDbeWindowPriv)->pWindow->drawable.pScreen)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define DBE_SCREEN_PRIV_FROM_WINDOW(pWindow) \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync DBE_SCREEN_PRIV((pWindow)->drawable.pScreen)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define DBE_SCREEN_PRIV_FROM_PIXMAP(pPixmap) \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync DBE_SCREEN_PRIV((pPixmap)->drawable.pScreen)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define DBE_SCREEN_PRIV_FROM_GC(pGC)\
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync DBE_SCREEN_PRIV((pGC)->pScreen)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define DBE_WINDOW_PRIV(pWin) ((DbeWindowPrivPtr) \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync dixLookupPrivate(&(pWin)->devPrivates, dbeWindowPrivKey))
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Initial size of the buffer ID array in the window priv. */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define DBE_INIT_MAX_IDS 2
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Reallocation increment for the buffer ID array. */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define DBE_INCR_MAX_IDS 4
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Marker for free elements in the buffer ID array. */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define DBE_FREE_ID_ELEMENT 0
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* TYPEDEFS */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Record used to pass swap information between DIX and DDX swapping
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * procedures.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct _DbeSwapInfoRec {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync WindowPtr pWindow;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync unsigned char swapAction;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync} DbeSwapInfoRec, *DbeSwapInfoPtr;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ******************************************************************************
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ** Per-window data
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ******************************************************************************
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct _DbeWindowPrivRec {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* A pointer to the window with which the DBE window private (buffer) is
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * associated.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync WindowPtr pWindow;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Last known swap action for this buffer. Legal values for this field
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * are XdbeUndefined, XdbeBackground, XdbeUntouched, and XdbeCopied.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync unsigned char swapAction;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Last known buffer size.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync unsigned short width, height;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Coordinates used for static gravity when the window is positioned.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync short x, y;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Number of XIDs associated with this buffer.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int nBufferIDs;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Capacity of the current buffer ID array, IDs. */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int maxAvailableIDs;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Pointer to the array of buffer IDs. This initially points to initIDs.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * When the static limit of the initIDs array is reached, the array is
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * reallocated and this pointer is set to the new array instead of initIDs.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync XID *IDs;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Initial array of buffer IDs. We are defining the XID array within the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * window priv to optimize for data locality. In most cases, only one
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * buffer will be associated with a window. Having the array declared
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * here can prevent us from accessing the data in another memory page,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * possibly resulting in a page swap and loss of performance. Initially we
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * will use this array to store buffer IDs. For situations where we have
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * more IDs than can fit in this static array, we will allocate a larger
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * array to use, possibly suffering a performance loss.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync XID initIDs[DBE_INIT_MAX_IDS];
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Pointer to a drawable that contains the contents of the back buffer.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync PixmapPtr pBackBuffer;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Pointer to a drawable that contains the contents of the front buffer.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * This pointer is only used for the XdbeUntouched swap action. For that
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * swap action, we need to copy the front buffer (window) contents into
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * this drawable, copy the contents of current back buffer drawable (the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * back buffer) into the window, swap the front and back drawable pointers,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * and then swap the drawable/resource associations in the resource
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * database.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync PixmapPtr pFrontBuffer;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Device-specific private information.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync PrivateRec *devPrivates;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync} DbeWindowPrivRec, *DbeWindowPrivPtr;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ******************************************************************************
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ** Per-screen data
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ******************************************************************************
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct _DbeScreenPrivRec {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Wrapped functions
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * It is the responsibilty of the DDX layer to wrap PositionWindow().
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * DbeExtensionInit wraps DestroyWindow().
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync PositionWindowProcPtr PositionWindow;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync DestroyWindowProcPtr DestroyWindow;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Per-screen DIX routines */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync Bool (*SetupBackgroundPainter) (WindowPtr /*pWin */ ,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync GCPtr /*pGC */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync );
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Per-screen DDX routines */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync Bool (*GetVisualInfo) (ScreenPtr /*pScreen */ ,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync XdbeScreenVisualInfo * /*pVisInfo */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync );
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int (*AllocBackBufferName) (WindowPtr /*pWin */ ,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync XID /*bufId */ ,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int /*swapAction */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync );
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int (*SwapBuffers) (ClientPtr /*client */ ,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int * /*pNumWindows */ ,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync DbeSwapInfoPtr /*swapInfo */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync );
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync void (*WinPrivDelete) (DbeWindowPrivPtr /*pDbeWindowPriv */ ,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync XID /*bufId */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync );
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync} DbeScreenPrivRec, *DbeScreenPrivPtr;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#endif /* DBE_STRUCT_H */