Contained Within
Find More Documentation
Featured Support Resources
| PDF로 이 문서 다운로드
Multiple Plane Group Interface
5
- Some devices contain multiple plane groups (MPG) to support overlays and visuals of varying depths. The MPG utility library provides the following features for those devices:
-
- Windowing Operations
These functions are necessary to operate on windows with multiple plane groups. When a window is moved, all of its physical plane groups need to be moved; when a window is exposed, all of its damaged plane groups need to be repaired.
- Minimizing Exposure Events
These functions minimize exposure events between windows that reside in separate plane groups. See "CopyPlanes and AggregatePlanes" on page 61 for more information.
- Leveraging of Existing DDX Interfaces
MPG is designed to use existing rendering and windowing libraries, such as CFB or MFB.
MPG Architectural Overview
- MPG is data-driven; DDX handlers need to inform MPG which plane groups are used by which windows and how they are used within the windows. Then the MPG windowing operations take care of moving, preparing and computing exposures to the plane groups.
-
Figure 5-1 shows the MPG library's interfaces to other DDX utility libraries.

Figure 5-1
- The MPG DDX library does not actually do any rendering. Instead, it is designed to lie on top of other DDX libraries, such as CFB and MFB or device-specific code, which provide all of the rendering and some of the windowing functions. This way a frame buffer with a 24-bit color plane group and a 1-bit overlay plane group can use CFB32 and MFB for its depth-specific rendering and windowing functions. MPG manages the depth-specific setup and switching between the underlying DDX libraries, and provides the rest of the windowing functions. MPG does not explicitly call CFB or MFB, and can use any device-specific functions.
- Each physical plane group requires a screen pixmap, which is a pixmap structure that points to an on-screen data area. Each window uses one or more plane groups. Two windows can share the same plane group, but use it differently.
- The MPG info of a window is comprised of its plane group combination and usage. The MPG info is stored in the mpgInfoRec structure that may be shared among windows. The flavor of a window is defined by its MPG info and visual. There is a one-to-many relationship between MPG infos and visuals. A sample device, such as the CG8, might have:
-
- three plane groups: 24-bit color, 1-bit overlay, 1-bit overlay enable
- and might provide:
-
- two MPG infos: color underlay and monochrome overlay, and
- three visuals: StaticGray, TrueColor, and DirectColor
- In the above example, windows with TrueColor or DirectColor visuals share the same color underlay MPG info. Each supported visual is matched by an MPG info in the mpgPerVisInfo structure. Each window is assigned to an MPG info based on its visual.
Data Structure Initialization
- In a single plane group (SPG) device, some members of the screen structure apply to only a single depth. In an MPG device that supports various depths, this depth-specific information must be stored somewhere else. Currently, most of this information is stored in the mpgInfoRec structure; the rest stored in the mpgPerDepthInfo structure which is arranged by depth. Pointers to all mpgInfoRec structures are listed in the mpgPerVisInfo structure arranged by visual.
- The mpgPerVisInfo and mpgPerDepthInfo structures are initialized directly in the device's DDX handler and attached to the screen private structure via the mpgScreenInit function. Each mpgInfoRec structure is
- initialized indirectly via mpgGetScreenState and mpgInsertPlanegroup functions. See "MPG Functional Interface" for a detailed description of these functions.
-
Code Example 5-1 MPG Data Structure Direct Initialization
-
#define NUMVISUALS 3
#define NUMVISUALS1 1
#define NUMVISUALS24 2
#define NUMDEPTHS 2 /* 1 and 24 bit */
static mpgInfoRec overlay_info, color_info;
static mpgPerVisInfo cg8MPGPerVisInfo[NUMVISUALS] = {
(VisualID)0, &overlay_info,
(VisualID)0, &color_info,
(VisualID)0, &color_info,
};
static const mpgPerDepthInfo cg8MPGPerDepthInfo[NUMDEPTHS] = {
{1, mfbCreateGC, mfbCreatePixmap, mfbDestroyPixmap,
mfbGetImage, mfbGetSpans},
{24, cfb32CreateGC, cfb32CreatePixmap, cfb32DestroyPixmap,
cfb32GetImage, cfb32GetSpans}
};
|
MPG Functional Interface
initPixmap
-
void
initPixmap(ScreenPtr pScreen, int width, int height,
int linebytes, int depth,
PixmapPtr pScreenPixmap, pointer data)
|
-
| Purpose | This function initializes the screen pixmap of a plane group. |
| Arguments | width, height and depth are the plane group dimensions. |
-
linebytes is the number of bytes to pad a scan line on the plane group of a given width and depth.
-
data is a pointer to a memory-mapped on-screen data area that is used to initialize the devPrivate field of the screen pixmap.
- The following code shows you a few samples of how to use initPixmap.
-
Code Example 5-2 initPixmap
-
initPixmap(pScreen, width, height, PixmapBytePad(width, 1), 1,
&cg8Private->pixmaps[CG8_ENABLE], overlay_enable_data);
initPixmap(pScreen, width, height, PixmapBytePad(width, 1), 1,
&cg8Private->pixmaps[CG8_OVERLAY], overlay_data);
initPixmap(pScreen, width, height, PixmapBytePad(width, 24), 24,
&cg8Private->pixmaps[CG8_COLOR_24], color_data);
|
mpgGetScreenState
-
Bool
mpgGetScreenState(ScreenPtr pScreen, mpgInfoPtr pMPGInfo,
void (*SetupScreen)(), miBSFuncPtr pBSFuncs)
|
-
Purpose....This function stores depth-specific information about the screen in the mpgInfoRec structure pointed to by pMPGInfo. It stores the blackPixel and whitePixel values, a set of depth-specific screen functions, a plane group-specific SetupScreen function, and a set of depth-specific backing store functions pointed to by pBSFuncs.
- The following depth-specific screen functions are currently stored by
-
-
mpgGetScreenState:
· GetImage
· GetSpans
· ResolveColor
· CreateColormap
· DestroyColormap
· CopyWindow
· CreateWindow
· DestroyWindow
· RealizeWindow
· PositionWindow
· UnrealizeWindow
-
-
· PaintWindowBorder
· PaintWindowBackground
· ChangeWindowAttributes
SetupScreen
-
void
(* SetupScreen)(ScreenPtr pScreen)
|
-
Purpose....This function normally initializes the devPrivate field of the screen structure to point to the screen pixmap of a specific plane group. It may also perform other software set up for rendering on that specific plane group.
- The following code shows you a few samples of how to set up screens.
-
Code Example 5-3 SetupScreen
-
static void
cg8MFBSetup(ScreenPtr pScreen)
{
pScreen->devPrivate = (pointer)&pCG8Private->pixmaps[CG8_OVERLAY];
}
static void
cg8CFB32Setup(ScreenPtr pScreen)
{
pScreen->devPrivate = (pointer)&pCG8Private->pixmaps[CG8_COLOR_24];
pScreen->devPrivates[cfb32ScreenPrivateIndex].ptr = pScreen->devPrivate;
}
|
-
mpgGetScreenState extracts most of its information from the current state of the screen. Do not over-initialize the screen before calling mpgGetScreenState. Routines like mfbScreenInit and cfbScreenInit usually do too much, such as bringing in much of the MI library that might not be necessary or allocating a lot of redundant memory. Use routines like mfbSetupScreen and cfbSetupScreen instead.
- The following code shows you a few samples of how to get the screen state.
-
Code Example 5-4 mpgGetScreenState
-
mfbSetupScreen(pScreen, pCG8Private->pixmaps[CG8_OVERLAY].devPrivate,
pScreen->width, pScreen->height, monitorResolution,
monitorResolution, pScreen->width);
mpgGetScreenState(pScreen, &overlay_info, cg8MFBSetup,
&mfbBSFuncRec);
cfb32SetupScreen(pScreen,
pCG8Private->pixmaps[CG8_COLOR_24].devPrivate, pScreen->width,
pScreen->height, monitorResolution, monitorResolution,
pScreen->width);
mpgGetScreenState(pScreen, &color_info, cg8CFB32Setup,
&cfb32BSFuncRec);
|
-
mpgGetScreenState returns TRUE if it's successful, FALSE otherwise.
mpgInsertPlanegroup
-
Bool
mpgInsertPlanegroup(mpgInfoPtr pMPGInfo, mpgPlaneId iid,
mpgPlaneId eid, mpgType type, mpgOp op, unsigned long val)
|
-
| Purpose | This function builds the MPG info by filling the mpgInfoRec structure pointed to by pMPGInfo with information on plane group combination and usage. |
| Arguments | iid and eid are the plane group internal and external identifiers. Plane group identifiers are unique small integers. Each device can enumerate its own plane groups to uniquely identify them. Plane group identifiers are normally used to index arrays of screen pixmaps. They are also bit-encoded and combined together to create plane group bit masks that express the plane group combination in each window and |
- facilitate the plane group interaction among windows. MPG provides the following macros to create and perform set operations on plane group bit masks:
-
#define mpg_bit_encoded(i) (1<<(i))
#define mpg_union(a,b) ((a)|(b))
#define mpg_intersect(a,b) ((a)&(b))
#define mpg_subtract(a,b) ((a)&(~(b)))
#define mpg_subset(a,b) ((a)==((a)&(b)))
|
- Currently the bit-encoding scheme limits plane group identifiers to be between 0 and 31 inclusive. iid is used to represent a plane group internally within the window, while eid is used to represent a plane group externally with respect to other windows. For example, iid is used in rendering and preparing plane groups in each window, while eid is used in checking plane group interference among windows and moving a family of windows across the screen. Windows that share the same eid damage each other on that plane group. Normally the eid of a plane group is identical to its iid. For backward compatibility, entering 0 for the eid currently forces it to be identical to the iid.
-
type describes the usage of each plane group within its window. Entering MPG_VISIBLE for type means the plane group is used for describing visibility. Entering MPG_DRAWABLE for type means the plane group is used for client rendering or to assist client rendering, for example, as the Z buffer in 3D rendering or the WID (window ID) buffer in hardware clipping. (See Chapter 7, "Window ID Interface" for detailed information on WIDs.) Entering MPG_VISIBLE_DRAWABLE for type means the plane group is used for all of the purposes stated above. Each window has one plane group of type MPG_VISIBLE or MPG_VISIBLE_DRAWABLE to describe visibility. Entering MPG_OTHER for type means the plane group is used for purposes other than the ones stated above, such as clearing buffers or switching colormaps.
- Each plane group with a unique eid has a region that represents the area of the screen pixmap claimed by its window with respect to other windows. The region of a plane group of type MPG_VISIBLE or MPG_VISIBLE_DRAWABLE is used in processing VisibilityNotify events--it is used to describe if its window is unobstructed, fully obscured, or partially obscured by other windows that share the same plane group. The region of a plane group of type MPG_DRAWABLE or
-
MPG_VISIBLE_DRAWABLE is used in processing Expose events--it is used to compute the effective rendering clip of its window. A window does not receive an Expose event until all of its plane groups of type MPG_DRAWABLE or MPG_VISIBLE_DRAWABLE are exposed.
-
op is performed on each plane group when it is exposed. Entering MPG_NOOP for op means the plane group is not filled or rendered--it does not contain data. A plane group with MPG_NOOP operation can be viewed as a virtual plane group. It is normally used to force interference among windows with different plane group combinations. A virtual plane group is not copied when its window is moved.
- Entering MPG_DRAW for op means the plane group is rendered by clients--it contains data. Multiple plane groups can have the MPG_DRAW operation. The last plane group inserted is the drawing plane group. The iid of this plane group is used to render color data.
-
Note - In the current release, use MPG_DRAW with plane groups of type MPG_DRAWABLE or MPG_VISIBLE_DRAWABLE.
- Entering MPG_FILL for op means the plane group is filled with the value supplied in val, which is constant throughout the window's existence. Entering MPG_FILL_WID for op means the plane group is filled with the window id value associated with its window. Window ids are a finite resource that can be shared and rotated among windows.
-
val is the value to fill the plane group with when op is MPG_FILL. It is ignored for all other cases.
Plane Group Aliasing
- In addition to supporting plane groups with multiple purposes, MPG also supports multiple ways of addressing them. MPG allows plane group aliasing-- the ability to address a plane group partially, internal or external to the window. This enables a plane group to be split into several disjoint partitions or aggregated with other plane groups to form a larger cohesive entity. For example, a 24-bit color plane group is internally addressed as an 8-bit color plane group to support 8-bit windows, or is split into three disjoint 8-bit color
- plane groups, in which mutually non-interfering 8-bit windows coexist. Enter a different iid and eid per plane group with mpgInsertPlanegroup to use plane group aliasing.
-
Note - Currently a one-to-many relationship between iids and eids in each window is supported.
- The following examples show you how to implement plane group aliasing with mpgInsertPlanegroup. Each example gets more complex--the first example shows the most common ways to plane group alias, while the last example shows a disjointed plane group.
-
Code Example 5-5 Common use of mpgInsertPlanegroup
-
mpgInsertPlanegroup(&overlay_info, CG8_OVERLAY, CG8_OVERLAY,
MPG_DRAWABLE, MPG_DRAW, 0);
mpgInsertPlanegroup(&overlay_info, CG8_ENABLE, CG8_ENABLE,
MPG_VISIBLE, MPG_FILL, 1);
mpgInsertPlanegroup(&color_info, CG8_COLOR_24, CG8_COLOR_24,
MPG_DRAWABLE, MPG_DRAW, 0);
mpgInsertPlanegroup(&color_info, CG8_OVERLAY, CG8_OVERLAY,
MPG_OTHER, MPG_FILL, 0);
mpgInsertPlanegroup(&color_info, CG8_ENABLE, CG8_ENABLE,
MPG_VISIBLE, MPG_FILL, 0);
|
-
Code Example 5-6 Complex use of mpgInsertPlanegroup
-
mpgInsertPlanegroup(&overlay_info, CG8_OVERLAY, CG8_OVERLAY,
MPG_DRAWABLE, MPG_DRAW, 0);
mpgInsertPlanegroup(&overlay_info, CG8_ENABLE, CG8_ENABLE,
MPG_VISIBLE, MPG_FILL, 1);
mpgInsertPlanegroup(&color8_info, CG8_COLOR_8, CG8_COLOR_24,
MPG_DRAWABLE, MPG_DRAW, 0);
mpgInsertPlanegroup(&color8_info, CG8_OVERLAY, CG8_OVERLAY,
MPG_OTHER, MPG_FILL, 0);
mpgInsertPlanegroup(&color8_info, CG8_ENABLE, CG8_ENABLE,
MPG_VISIBLE, MPG_FILL, 0);
mpgInsertPlanegroup(&color24_info, CG8_COLOR_24, CG8_COLOR_24,
MPG_DRAWABLE, MPG_DRAW, 0);
mpgInsertPlanegroup(&color24_info, CG8_OVERLAY, CG8_OVERLAY,
MPG_OTHER, MPG_FILL, 0);
mpgInsertPlanegroup(&color24_info, CG8_ENABLE, CG8_ENABLE,
MPG_VISIBLE, MPG_FILL, 0);
|
-
Code Example 5-7 More Complex use of mpgInsertPlanegroup
-
mpgInsertPlanegroup(&overlay_info, CG8_OVERLAY, CG8_OVERLAY,
MPG_DRAWABLE, MPG_DRAW, 0);
mpgInsertPlanegroup(&overlay_info, CG8_ENABLE, CG8_ENABLE,
MPG_VISIBLE, MPG_FILL, 1);
mpgInsertPlanegroup(&color8A_info, CG8_COLOR_8A, CG8_COLOR_8A,
MPG_DRAWABLE, MPG_DRAW, 0);
mpgInsertPlanegroup(&color8A_info, CG8_OVERLAY, CG8_OVERLAY,
MPG_OTHER, MPG_FILL, 0);
mpgInsertPlanegroup(&color8A_info, CG8_ENABLE, CG8_ENABLE,
MPG_VISIBLE, MPG_FILL, 0);
mpgInsertPlanegroup(&color8B_info, CG8_COLOR_8B, CG8_COLOR_8B,
MPG_DRAWABLE, MPG_DRAW, 0);
mpgInsertPlanegroup(&color8B_info, CG8_OVERLAY, CG8_OVERLAY,
MPG_OTHER, MPG_FILL, 0);
mpgInsertPlanegroup(&color8B_info, CG8_ENABLE, CG8_ENABLE,
MPG_VISIBLE, MPG_FILL, 0);
mpgInsertPlanegroup(&color24_info, CG8_COLOR_24, CG8_COLOR_8A,
MPG_DRAWABLE, MPG_DRAW, 0);
mpgInsertPlanegroup(&color24_info, CG8_COLOR_24, CG8_COLOR_8B,
MPG_DRAWABLE, MPG_DRAW, 0);
mpgInsertPlanegroup(&color24_info, CG8_COLOR_24, CG8_COLOR_8C,
MPG_DRAWABLE, MPG_DRAW, 0);
mpgInsertPlanegroup(&color24_info, CG8_OVERLAY, CG8_OVERLAY,
MPG_OTHER, MPG_FILL, 0);
mpgInsertPlanegroup(&color24_info, CG8_ENABLE, CG8_ENABLE,
MPG_VISIBLE, MPG_FILL, 0);
|
-
mpgInsertPlanegroup returns TRUE if successful, FALSE otherwise.
mpgScreenInit
-
Bool
mpgScreenInit(ScreenPtr pScreen, int numPlanes,
PixmapPtr pScreenPixmaps, mpgPlanes dispPlanes,
mpgPerVisInfoPtr pMPGPerVisInfo,
mpgPerDepthInfo pMPGPerDepthInfo,
void (* SwitchScreen)());
|
-
| Purpose | This function completes the MPG screen initialization. |
| Arguments | numPlanes is the total number of plane groups in the device. |
-
pScreenPixmaps is a pointer to an array of screen pixmaps.
-
dispPlanes is the displayable plane groups in the device. Displayable plane groups are plane groups that are visible at one time or another on the screen. For example, in CG8, the 24-bit color and 1-bit overlay plane groups are displayable, but not the 1-bit overlay enable plane group. dispPlanes is entered as a plane group bit mask, created by combining bit-encoded displayable plane group identifiers.
-
pMPGPerVisInfo is a pointer to the mpgPerVisInfo structure, which is an arranged-by-visual array of MPG infos.
-
pMPGPerDepthInfo is a pointer to the mpgPerDepthInfo structure, which is an arranged-by-depth array of depth-specific screen functions.
SwitchScreen
-
void
(* SwitchScreen)(ScreenPtr pScreen, mpgPlaneId pid)
|
-
| Purpose | This function is a pointer to a function that performs the hardware set up for rendering on a specific plane group. Entering NULL means the device does not need it. pid is the identifier of a plane group to which the screen has to be switched. |
| Returns | TRUE if successful; FALSE otherwise |
- The following fields in the screen structure should be initialized before calling
-
-
mpgScreenInit:
· visuals
· numDepths
· numVisuals
· CloseScreen
· allowedDepths
- The following code shows you a sample of how to use mpgScreenInit.
-
mpgScreenInit(pScreen, NUM_CG8_PLANEGROUPS, pCG8Private->pixmaps,
mpg_union(mpg_bit_encoded(CG8_OVERLAY),
mpg_bit_encoded(CG8_COLOR_24)), cg8MPGPerVisInfo,
cg8MPGPerDepthInfo, NULL);
|
-
Note - The initialization order for devices that use both MPG and DGA is: MPG, DGA, and then the screen pixmap devPrivates at the end of your DDX handler initialization,
getMpgInfoFromVisual
-
mpgInfoPtr
getMpgInfoFromVisual(ScreenPtr pScreen, VisualID vid)
|
-
| Purpose | This function uses vid to search the arranged-by-visual mpgPerVisInfo structure, which is attached to the screen private structure. |
| ReturnsmpgChangeInfo | A pointer to the matching mpgInfoRec structure. |
| void |
| Purpose | This function replaces the MPG info of a window with a new mpgInfoRec structure pointed to by pNewMPGInfo. It can be used to change the flavor of a window at any given time. Changing the MPG info is similar to adding, subtracting, or replacing plane groups, or changing their types and operations. |
- The following code shows you a sample of how to use mpgChangeInfo.
-
/* migrate pWin from 8-bit color plane group A to 8-bit color */
/* plane group B */
if (getMpgInfoFromVisual(pScreen, pWin->optional->visual) ==
&color8A_info)
mpgChangeInfo(pWin, &color8B_info);
|
freeMpgInfo
-
void
freeMpgInfo(mpgInfoPtr pMPGInfo)
|
-
Purpose....This function frees the memory associated with the mpgInfoRec structure pointed to by pMPGInfo, but not the structure itself. The freed memory has been previously allocated by mpgGetScreenState and mpgInsertPlanegroup.
- The following code shows you a few samples of how to use freeMpgInfo.
-
freeMpgInfo(&overlay_info);
freeMpgInfo(&color_info);
|
mpgCursorInitialize
-
Bool
mpgCursorInitialize(ScreenPtr pScreen,
mpgPlaneId cid, mpgPlaneId eid, Bool isDedicated)
|
-
| Purpose | This function sets up the screen to use the MPG software cursor. If the device has a hardware cursor there is no need to call mpgCursorInitialize. |
| Arguments | cid is the identifier for the cursor plane group, on which the cursor image is rendered with the default foreground and background colors of 1 and 0, respectively. |
-
eid is the identifier for the cursor enable plane group, on which the cursor mask is filled with the default value of 1.
-
isDedicated is TRUE if the cursor and the cursor enable plane groups are dedicated to the cursor and not used by any window. Otherwise, MPG has to lift the cursor for any conflicting rendering operation and drop it again afterwards.
-
Returns....TRUE if successful, FALSE otherwise
mpgSetCursorValues
-
void
mpgSetCursorValues(ScreenPtr pScreen, unsigned long eval,
unsigned long fval, unsigned long bval)
|
-
| PurposempgSetCursorHasEnable | This function resets the cursor enable plane group's fill value, the cursor's foreground color, and the cursor's background color with eval, fval and bval, respectively. |
| void |
| Purpose | This function resets the need for the cursor enable plane group. |
| Arguments | hasEnable is FALSE if the cursor enable plane group is not needed. |
- The following code shows you a sample of how to use mpgSetCursorHasEnable.
-
mpgCursorInitialize(pScreen, CG8_OVERLAY, CG8_ENABLE, FALSE);
mpgSetCursorValues(pScreen, 1, 0, 1);/* reverse */
mpgSetCursorHasEnable(pScreen, FALSE);
|
CopyPlanes and AggregatePlanes
- To minimize window exposures, MPG wraps, or replaces the existing X windowing screen functions. For example, it cannot use the basic CopyWindow screen function for moving a family of windows with various depths and other attributes across the screen, since this operation involves copying different regions on several plane groups. Instead, it allocates two function pointers in the MPG screen private structure, CopyPlanes and AggregatePlanes, and uses them. AggregatePlanes is a complement to CopyPlanes, and is called
- inside any CopyPlanes implementation. AggregatePlanes notifies CopyPlanes if the device can copy several plane groups simultaneously, so that CopyPlanes adjusts accordingly and improves its performance; otherwise, CopyPlanes copies those plane groups one-by-one.
CopyPlanes
-
void
(* CopyPlanes)(ScreenPtr pScreen, WindowPtr pWin,
RegionPtr pRegions[], mpgPlanes planes, int dx, int dy)
|
-
Note - MPG provides a generic implementation of CopyPlanes in mpgCopyPlanes. It is highly recommended that you use mpgCopyPlanes directly, or wrap it in conjunction with AggregatePlanes, instead of providing your own implementations.
-
Arguments..pWin is a pointer to the highest window in the window subtree being moved--it is the root of the subtree. Currently it serves as a flag to override AggregatePlanes. When pWin is NULL, CopyPlanes still copies plane groups one at a time, even though AggregatePlanes insists that the device is capable of copying them simultaneously. In mpgCopyPlanes, pWin is used as a starting point to repair the damage on the window subtree being moved that may be caused by copying plane groups simultaneously.
-
pRegions is a pointer to an indexed-by-plane group array of regions to be copied. These regions often differ from each other.
-
planes is a plane group bit mask indicating which entries are valid in the array of regions pointed to by pRegions.
-
dx and dy are the horizontal and vertical distances to copy those regions on their plane groups.
AggregatePlanes
-
int
(* AggregatePlanes)(ScreenPtr pScreen, mpgPlanes planes)
|
-
| Purpose | MPG does not provide a generic implementation of AggregatePlanes. By default, mpgCopyPlanes copies plane groups one-by-one. Providing an implementation of AggregatePlanes and attaching it to the screen private structure are sufficient to allow mpgCopyPlanes to copy plane groups simultaneously. Some devices might also need to wrap mpgCopyPlanes. |
| Arguments | planes is a plane group bit mask indicating which plane groups have regions to be copied. |
| Returns | A plane group identifier representing the aggregate of all plane groups in planes if they can be aggregated; a negative number otherwise. |
-
Note - Currently CopyPlanes and AggregatePlanes are initialized by mpgScreenInit to mpgCopyPlanes and NULL, respectively. These default function assignments should be sufficient for a lot of devices.
- When a device needs to reset AggregatePlanes, wrap mpgCopyPlanes or implement your own CopyPlanes,
- MPG provides a macro, mpg_priv_scr, to access the screen private structure:
-
#define mpg_priv_scr(pScreen) ((mpgPrivScreenPtr)(
(pScreen)->devPrivates[mpgScreenPrivateIndex].ptr))
(pScreen)->devPrivates[mpgScreenPrivateIndex].ptr))
|
- The following code shows you samples of how to use CopyPlanes and AggregatePlanes.
-
Code Example 5-8 CopyPlanes and AggregatePlanes
-
/* after calling mpgScreenInit, wrap mpgCopyPlanes and initialize */
/* AggregatePlanes */
{
mpgPrivScreenPtr pMPGPrivScreen = mpg_priv_scr(pScreen);
pMPGPrivScreen->CopyPlanes = cg8CopyPlanes;
pMPGPrivScreen->AggregatePlanes = cg8AggregatePlanes;
}
int
cg8AggregatePlanes(ScreenPtr pScreen, mpgPlanes planes)
{
switch (planes) {
case mpg_union(mpg_bit_encoded(CG8_COLOR_8A),
mpg_union(mpg_bit_encoded(CG8_COLOR_8B),
mpg_bit_encoded(CG8_COLOR_8C))):
return CG8_COLOR_24;
default:
return -1;
}
}
void
cg8CopyPlanes(ScreenPtr pScreen, WindowPtr pWin,
RegionPtr pRegions[], mpgPlanes planes, int dx, int dy)
{
mpgPlanes plns = mpg_union(mpg_bit_encoded(CG8_COLOR_8A),
mpg_union(mpg_bit_encoded(CG8_COLOR_8B),
mpg_bit_encoded(CG8_COLOR_8C)));
if (mpg_subset(plns, planes)) {
mpgCopyPlanes(pScreen, pWin, pRegions, plns, dx, dy);
mpgCopyPlanes(pScreen, pWin, pRegions,
pg_subtract(planes, plns), dx, dy);
} else
mpgCopyPlanes(pScreen, pWin, pRegions, planes, dx, dy);
}
|
mpgSetScreenFuncs
-
long
mpgSetScreenFuncs(pScreen, funcs, mask, oldfuncs)
|
-
| Purpose | This function allows the device developer to supply an arbitrary number of wrapper functions. |
| Arguments | funcs is a structure containing the wrapper functions. |
-
mask indicating which of the wrapper functions is valid.
-
oldfuncs contains previous wrapper functions.
-
Returns....The previous values of the indicated function vectors so that devices may make use of the more generalized default implementation to handle the more obscure cases of the particular function they are wrapping.
- The mpgSetScreenFuncs() function examines the mask parameter to determine which functions are being wrapped. For each wrapper indicated, this function stores the previous wrapper function (or NULL if there was no default value) into the appropriate member of the oldfuncs structure (if supplied) and then loads the new wrapper function from the appropriate member of the funcs structure into the internal MPG function vector.
- The oldfuncs parameter may be NULL if the device does not need to refer to the previous versions of any of the functions which it is overriding. The oldfuncs parameter may also be a pointer to the same structure as the funcs parameter, in which case mpgSetScreenFuncs() safely swaps the two function values.
|
|