X Server(xorg-server-1.20.8)定义了119个接口(0号和120之外的初始的时候都是ProcBadRequest)。
128之外的接口都是给扩展用的(#define EXTENSION_BASE 128)。
但是每个扩展可能实现了多个接口,而ProcVector仅仅为每个扩展准备了一个入口。所以扩展协议如果有多个接口,就需要自行分发。所以这里的MainProc其实就是扩展协议的入口。对于XRender协议,MainProc就是ProcRenderDispatch。
所以XRenderComposite的分发过程是:
X服务器将来自X客户端的请求通过ProcVector分发给MainProc ProcRenderDispatch。然后ProcRenderDispatch通过ProcRenderVector将命令分发给ProcRenderComposite。
XRrenderComposite => Xlib => ProcRenderDispatch => XRender => ProcRenderComposite
但是XRender本身并没有具体的实现。具体的实现,是通过glamor或者fb实现的。glamor可以通过OpenGL来实现合成。如果没有OpenGL,那么回退到fb。
int (*ProcVector[256]) (ClientPtr /* client */) = {
ProcBadRequest,
ProcCreateWindow,
ProcChangeWindowAttributes,
ProcGetWindowAttributes,
ProcDestroyWindow,
ProcDestroySubwindows, /* 5 */
ProcChangeSaveSet,
ProcReparentWindow,
ProcMapWindow,
ProcMapSubwindows,
ProcUnmapWindow, /* 10 */
ProcUnmapSubwindows,
ProcConfigureWindow,
ProcCirculateWindow,
ProcGetGeometry,
ProcQueryTree, /* 15 */
ProcInternAtom,
ProcGetAtomName,
ProcChangeProperty,
ProcDeleteProperty,
ProcGetProperty, /* 20 */
ProcListProperties,
ProcSetSelectionOwner,
ProcGetSelectionOwner,
ProcConvertSelection,
ProcSendEvent, /* 25 */
ProcGrabPointer,
ProcUngrabPointer,
ProcGrabButton,
ProcUngrabButton,
ProcChangeActivePointerGrab, /* 30 */
ProcGrabKeyboard,
ProcUngrabKeyboard,
ProcGrabKey,
ProcUngrabKey,
ProcAllowEvents, /* 35 */
ProcGrabServer,
ProcUngrabServer,
ProcQueryPointer,
ProcGetMotionEvents,
ProcTranslateCoords, /* 40 */
ProcWarpPointer,
ProcSetInputFocus,
ProcGetInputFocus,
ProcQueryKeymap,
ProcOpenFont, /* 45 */
ProcCloseFont,
ProcQueryFont,
ProcQueryTextExtents,
ProcListFonts,
ProcListFontsWithInfo, /* 50 */
ProcSetFontPath,
ProcGetFontPath,
ProcCreatePixmap,
ProcFreePixmap,
ProcCreateGC, /* 55 */
ProcChangeGC,
ProcCopyGC,
ProcSetDashes,
ProcSetClipRectangles,
ProcFreeGC, /* 60 */
ProcClearToBackground,
ProcCopyArea,
ProcCopyPlane,
ProcPolyPoint,
ProcPolyLine, /* 65 */
ProcPolySegment,
ProcPolyRectangle,
ProcPolyArc,
ProcFillPoly,
ProcPolyFillRectangle, /* 70 */
ProcPolyFillArc,
ProcPutImage,
ProcGetImage,
ProcPolyText,
ProcPolyText, /* 75 */
ProcImageText8,
ProcImageText16,
ProcCreateColormap,
ProcFreeColormap,
ProcCopyColormapAndFree, /* 80 */
ProcInstallColormap,
ProcUninstallColormap,
ProcListInstalledColormaps,
ProcAllocColor,
ProcAllocNamedColor, /* 85 */
ProcAllocColorCells,
ProcAllocColorPlanes,
ProcFreeColors,
ProcStoreColors,
ProcStoreNamedColor, /* 90 */
ProcQueryColors,
ProcLookupColor,
ProcCreateCursor,
ProcCreateGlyphCursor,
ProcFreeCursor, /* 95 */
ProcRecolorCursor,
ProcQueryBestSize,
ProcQueryExtension,
ProcListExtensions,
ProcChangeKeyboardMapping, /* 100 */
ProcGetKeyboardMapping,
ProcChangeKeyboardControl,
ProcGetKeyboardControl,
ProcBell,
ProcChangePointerControl, /* 105 */
ProcGetPointerControl,
ProcSetScreenSaver,
ProcGetScreenSaver,
ProcChangeHosts,
ProcListHosts, /* 110 */
ProcChangeAccessControl,
ProcChangeCloseDownMode,
ProcKillClient,
ProcRotateProperties,
ProcForceScreenSaver, /* 115 */
ProcSetPointerMapping,
ProcGetPointerMapping,
ProcSetModifierMapping,
ProcGetModifierMapping,
ProcBadRequest, /* 120 */