summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GL/apple/aglGlx.c796
-rw-r--r--GL/apple/indirect.c897
-rw-r--r--GL/glx/g_disptab.c40
-rw-r--r--GL/glx/g_disptab.h6
-rw-r--r--GL/glx/g_render.c1
-rw-r--r--GL/glx/g_renderswap.c1
-rw-r--r--GL/glx/glxcmds.c377
-rw-r--r--GL/glx/glxcmdsswap.c190
-rw-r--r--GL/glx/glxcontext.h1
-rw-r--r--GL/glx/glxdrawable.h5
-rw-r--r--GL/glx/glxext.c5
-rw-r--r--GL/glx/glxext.h12
-rw-r--r--GL/glx/glxscreens.c103
-rw-r--r--GL/glx/glxscreens.h6
-rw-r--r--GL/glx/glxserver.h1
-rw-r--r--GL/glx/glxutil.c62
-rw-r--r--GL/glx/glxutil.h4
-rw-r--r--GL/glx/render2.c8
-rw-r--r--GL/glx/rensize.c2
-rw-r--r--GL/glx/singlesize.c57
-rw-r--r--GL/windows/ChangeLog8
-rw-r--r--GL/windows/glwindows.h4
-rwxr-xr-xGL/windows/indirect.c212
-rw-r--r--XTrap/xtrapdi.c2
-rw-r--r--Xext/panoramiX.c107
-rw-r--r--Xext/panoramiX.h2
-rw-r--r--Xext/panoramiXsrv.h2
-rw-r--r--Xext/saver.c2
-rw-r--r--Xext/security.c2
-rw-r--r--Xext/shape.c21
-rw-r--r--Xext/shm.c1
-rw-r--r--Xext/xres.c2
-rw-r--r--Xext/xtest.c2
-rw-r--r--Xext/xtest1di.c2
-rw-r--r--Xext/xvdisp.c2
-rw-r--r--Xext/xvmain.c2
-rw-r--r--XpConfig/C/print/Xprinters8
-rw-r--r--XpConfig/C/print/attributes/document17
-rw-r--r--XpConfig/C/print/attributes/printer18
-rw-r--r--XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias1
-rw-r--r--XpConfig/C/print/models/HPDJ1600C/model-config34
-rw-r--r--XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias1
-rw-r--r--XpConfig/C/print/models/HPLJ4family/model-config35
-rw-r--r--XpConfig/C/print/models/SPSPARC2/model-config25
-rw-r--r--Xprint/AttrValid.c6
-rw-r--r--Xprint/AttrValid.h11
-rw-r--r--Xprint/DiPrint.h2
-rw-r--r--Xprint/Init.c387
-rw-r--r--Xprint/Oid.c21
-rw-r--r--Xprint/Oid.h3
-rw-r--r--Xprint/OidDefs.h8
-rw-r--r--Xprint/OidStrs.h268
-rw-r--r--Xprint/attributes.c162
-rw-r--r--Xprint/attributes.h49
-rw-r--r--Xprint/ddxInit.c54
-rw-r--r--Xprint/etc/init.d/xprint.cpp1274
-rw-r--r--Xprint/mediaSizes.c28
-rw-r--r--Xprint/ps/Ps.h95
-rw-r--r--Xprint/ps/PsArea.c138
-rw-r--r--Xprint/ps/PsAttVal.c99
-rw-r--r--Xprint/ps/PsAttr.c2
-rw-r--r--Xprint/ps/PsCache.c194
-rw-r--r--Xprint/ps/PsColor.c5
-rw-r--r--Xprint/ps/PsFonts.c698
-rw-r--r--Xprint/ps/PsGC.c32
-rw-r--r--Xprint/ps/PsInit.c90
-rw-r--r--Xprint/ps/PsLine.c1
-rw-r--r--Xprint/ps/PsMisc.c1
-rw-r--r--Xprint/ps/PsPixel.c1
-rw-r--r--Xprint/ps/PsPixmap.c14
-rw-r--r--Xprint/ps/PsPolygon.c4
-rw-r--r--Xprint/ps/PsPrint.c43
-rw-r--r--Xprint/ps/PsText.c334
-rw-r--r--Xprint/ps/PsWindow.c16
-rw-r--r--Xprint/ps/psout.c399
-rw-r--r--Xprint/ps/psout.h95
-rw-r--r--Xprint/ps/ttf2pt1wrap.c10
-rw-r--r--Xprint/raster/Raster.h5
-rw-r--r--cfb/cfbpntwin.c2
-rw-r--r--cfb/stipsparc.s11
-rw-r--r--cfb/stipsprc32.s11
-rw-r--r--composite/compalloc.c552
-rw-r--r--composite/compinit.c389
-rw-r--r--composite/compint.h256
-rw-r--r--composite/compwindow.c754
-rw-r--r--dbe/dbe.c2
-rw-r--r--dix/colormap.c22
-rw-r--r--dix/cursor.c12
-rw-r--r--dix/dispatch.c38
-rw-r--r--dix/dixfonts.c6
-rw-r--r--dix/dixutils.c70
-rw-r--r--dix/events.c123
-rw-r--r--dix/globals.c2
-rw-r--r--dix/main.c25
-rw-r--r--dix/privates.c2
-rw-r--r--dix/resource.c4
-rw-r--r--dix/window.c56
-rw-r--r--fb/fb.h17
-rw-r--r--fb/fballpriv.c12
-rw-r--r--fb/fbcompose.c136
-rw-r--r--fb/fbedge.c134
-rw-r--r--fb/fbedgeimp.h134
-rw-r--r--fb/fbfill.c6
-rw-r--r--fb/fbgc.c2
-rw-r--r--fb/fbglyph.c2
-rw-r--r--fb/fboverlay.c11
-rw-r--r--fb/fboverlay.h7
-rw-r--r--fb/fbpict.c290
-rw-r--r--fb/fbpict.h103
-rw-r--r--fb/fbpixmap.c5
-rw-r--r--fb/fbscreen.c6
-rw-r--r--fb/fbsolid.c1
-rw-r--r--fb/fbtrap.c1495
-rw-r--r--fb/fbwindow.c19
-rw-r--r--hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp104
-rw-r--r--hw/darwin/bundle/Japanese.lproj/Credits.rtf2
-rw-r--r--hw/darwin/bundle/XDarwin.icnsbin69461 -> 69465 bytes
-rw-r--r--hw/darwin/darwin.c38
-rw-r--r--hw/darwin/iokit/xfIOKit.c12
-rw-r--r--hw/darwin/quartz/Preferences.h2
-rw-r--r--hw/darwin/quartz/Preferences.m21
-rw-r--r--hw/darwin/quartz/XDarwin.pbproj/project.pbxproj4
-rw-r--r--hw/darwin/quartz/XServer.h7
-rw-r--r--hw/darwin/quartz/XServer.m145
-rw-r--r--hw/darwin/quartz/cr/crFrame.m1
-rw-r--r--hw/darwin/quartz/cr/crScreen.m192
-rw-r--r--hw/darwin/quartz/fullscreen/fullscreen.c15
-rw-r--r--hw/darwin/quartz/pseudoramiX.c14
-rw-r--r--hw/darwin/quartz/pseudoramiX.h3
-rw-r--r--hw/darwin/quartz/quartz.c91
-rw-r--r--hw/darwin/quartz/quartz.h13
-rw-r--r--hw/darwin/quartz/quartzCocoa.m7
-rw-r--r--hw/darwin/quartz/quartzCommon.h9
-rw-r--r--hw/darwin/quartz/xpr/xpr.h2
-rw-r--r--hw/darwin/quartz/xpr/xprFrame.c2
-rw-r--r--hw/darwin/quartz/xpr/xprScreen.c97
-rw-r--r--hw/dmx/dmx.c1129
-rw-r--r--hw/dmx/dmxdpms.c209
-rw-r--r--hw/vfb/InitOutput.c131
-rw-r--r--hw/vfb/Xvfb.man.pre2
-rw-r--r--hw/xfree86/common/compiler.h71
-rw-r--r--hw/xfree86/common/xf86Bus.c2
-rw-r--r--hw/xfree86/common/xf86Config.c65
-rw-r--r--hw/xfree86/common/xf86Configure.c9
-rw-r--r--hw/xfree86/common/xf86Cursor.c2
-rw-r--r--hw/xfree86/common/xf86DGA.c2
-rw-r--r--hw/xfree86/common/xf86DPMS.c10
-rw-r--r--hw/xfree86/common/xf86Date.h2
-rw-r--r--hw/xfree86/common/xf86Events.c16
-rw-r--r--hw/xfree86/common/xf86Globals.c2
-rw-r--r--hw/xfree86/common/xf86Helper.c20
-rw-r--r--hw/xfree86/common/xf86Init.c67
-rw-r--r--hw/xfree86/common/xf86Io.c5
-rw-r--r--hw/xfree86/common/xf86Mode.c2
-rw-r--r--hw/xfree86/common/xf86PciInfo.h46
-rw-r--r--hw/xfree86/common/xf86RandR.c83
-rw-r--r--hw/xfree86/common/xf86Version.h4
-rw-r--r--hw/xfree86/common/xf86cmap.c11
-rw-r--r--hw/xfree86/common/xf86fbman.c6
-rw-r--r--hw/xfree86/common/xf86pciBus.c12
-rw-r--r--hw/xfree86/common/xf86str.h24
-rw-r--r--hw/xfree86/common/xorgHelper.c2
-rw-r--r--hw/xfree86/common/xorgVersion.h6
-rw-r--r--hw/xfree86/ddc/interpret_edid.c4
-rw-r--r--hw/xfree86/ddc/xf86DDC.c8
-rw-r--r--hw/xfree86/ddc/xf86DDC.h4
-rw-r--r--hw/xfree86/dixmods/GLcoremodule.c2
-rw-r--r--hw/xfree86/dixmods/afbmodule.c2
-rw-r--r--hw/xfree86/dixmods/bitmapmod.c2
-rw-r--r--hw/xfree86/dixmods/cfb16module.c2
-rw-r--r--hw/xfree86/dixmods/cfb24module.c2
-rw-r--r--hw/xfree86/dixmods/cfb32module.c2
-rw-r--r--hw/xfree86/dixmods/cfbmodule.c2
-rw-r--r--hw/xfree86/dixmods/dbemodule.c2
-rw-r--r--hw/xfree86/dixmods/extmod/modinit.c2
-rw-r--r--hw/xfree86/dixmods/extmod/modinit.h2
-rw-r--r--hw/xfree86/dixmods/extmod/xf86vmode.c2
-rw-r--r--hw/xfree86/dixmods/fbmodule.c2
-rw-r--r--hw/xfree86/dixmods/ftmodule.c2
-rw-r--r--hw/xfree86/dixmods/glxmodule.c5
-rw-r--r--hw/xfree86/dixmods/laymodule.c2
-rw-r--r--hw/xfree86/dixmods/mfbmodule.c2
-rw-r--r--hw/xfree86/dixmods/recordmod.c2
-rw-r--r--hw/xfree86/dixmods/shmodule.c2
-rw-r--r--hw/xfree86/dixmods/type1mod.c2
-rw-r--r--hw/xfree86/dixmods/xf86XTrapModule.c2
-rw-r--r--hw/xfree86/doc/README.DRI1
-rw-r--r--hw/xfree86/doc/README.fonts86
-rw-r--r--hw/xfree86/doc/devel/README.DRIcomp1
-rw-r--r--hw/xfree86/doc/man/Xorg.man.pre2
-rw-r--r--hw/xfree86/doc/man/xorg.conf.man.pre2
-rw-r--r--hw/xfree86/dri/dri.c144
-rw-r--r--hw/xfree86/dri/dri.h26
-rw-r--r--hw/xfree86/dri/drimodule.c4
-rw-r--r--hw/xfree86/dri/dristruct.h14
-rw-r--r--hw/xfree86/dri/sarea.h2
-rw-r--r--hw/xfree86/dri/xf86dri.c23
-rw-r--r--hw/xfree86/fbdevhw/fbdevhw.c40
-rw-r--r--hw/xfree86/fbdevhw/fbdevhw.h9
-rw-r--r--hw/xfree86/fbdevhw/fbdevhwstub.c24
-rw-r--r--hw/xfree86/getconfig/cfg.sample2
-rw-r--r--hw/xfree86/getconfig/getconfig2
-rw-r--r--hw/xfree86/getconfig/xorg.cfg4
-rw-r--r--hw/xfree86/i2c/xf86i2c.c2
-rw-r--r--hw/xfree86/i2c/xf86i2c.h1
-rw-r--r--hw/xfree86/i2c/xf86i2cmodule.c2
-rw-r--r--hw/xfree86/int10/xf86int10module.c2
-rw-r--r--hw/xfree86/loader/dixsym.c22
-rw-r--r--hw/xfree86/loader/elfloader.c3
-rw-r--r--hw/xfree86/loader/extsym.c2
-rw-r--r--hw/xfree86/loader/hash.c2
-rw-r--r--hw/xfree86/loader/loader.c7
-rw-r--r--hw/xfree86/loader/loadmod.c2
-rw-r--r--hw/xfree86/loader/misym.c2
-rw-r--r--hw/xfree86/loader/xf86sym.c32
-rw-r--r--hw/xfree86/os-support/bsd/bsd_mouse.c2
-rw-r--r--hw/xfree86/os-support/bsd/i386_video.c114
-rw-r--r--hw/xfree86/os-support/bus/Pci.c3
-rw-r--r--hw/xfree86/os-support/bus/Pci.h6
-rw-r--r--hw/xfree86/os-support/bus/ix86Pci.c15
-rw-r--r--hw/xfree86/os-support/bus/linuxPci.c22
-rw-r--r--hw/xfree86/os-support/drm/drmmodule.c2
-rw-r--r--hw/xfree86/os-support/linux/int10/linux.c26
-rw-r--r--hw/xfree86/os-support/linux/lnx_ia64.c45
-rw-r--r--hw/xfree86/os-support/linux/lnx_init.c2
-rw-r--r--hw/xfree86/os-support/linux/lnx_io.c1
-rw-r--r--hw/xfree86/os-support/linux/lnx_kbd.c1
-rw-r--r--hw/xfree86/os-support/linux/lnx_video.c2
-rw-r--r--hw/xfree86/os-support/shared/ia64Pci.c81
-rw-r--r--hw/xfree86/os-support/shared/ia64Pci.h41
-rw-r--r--hw/xfree86/os-support/shared/libc_wrapper.c48
-rw-r--r--hw/xfree86/os-support/shared/sigio.c12
-rw-r--r--hw/xfree86/os-support/shared/sigiostubs.c3
-rw-r--r--hw/xfree86/os-support/solaris/sun_init.c19
-rw-r--r--hw/xfree86/os-support/solaris/sun_kbd.c20
-rw-r--r--hw/xfree86/os-support/solaris/sun_kbdEv.c16
-rw-r--r--hw/xfree86/os-support/solaris/sun_mouse.c243
-rw-r--r--hw/xfree86/os-support/xf86OSmouse.h4
-rw-r--r--hw/xfree86/os-support/xf86_OSlib.h4
-rw-r--r--hw/xfree86/os-support/xf86_libc.h2
-rw-r--r--hw/xfree86/parser/configProcs.h4
-rw-r--r--hw/xfree86/parser/read.c7
-rw-r--r--hw/xfree86/parser/write.c2
-rw-r--r--hw/xfree86/parser/xf86Parser.h8
-rw-r--r--hw/xfree86/rac/xf86RACmodule.c2
-rw-r--r--hw/xfree86/ramdac/IBM.c4
-rw-r--r--hw/xfree86/ramdac/IBM.h3
-rw-r--r--hw/xfree86/ramdac/TI.c4
-rw-r--r--hw/xfree86/ramdac/TI.h3
-rw-r--r--hw/xfree86/ramdac/xf86RamDacMod.c2
-rw-r--r--hw/xfree86/scanpci/extrapci.ids2
-rw-r--r--hw/xfree86/scanpci/xf86ScanPci.c4
-rw-r--r--hw/xfree86/shadowfb/sfbmodule.c2
-rw-r--r--hw/xfree86/utils/gtf/gtf.c2
-rw-r--r--hw/xfree86/utils/gtf/gtf.man.pre1
-rw-r--r--hw/xfree86/utils/xorgcfg/loader.c2
-rw-r--r--hw/xfree86/utils/xorgconfig/cards.c18
-rw-r--r--hw/xfree86/utils/xorgconfig/xorgconfig.c148
-rw-r--r--hw/xfree86/vbe/vbe.c19
-rw-r--r--hw/xfree86/vbe/vbe_module.c2
-rw-r--r--hw/xfree86/vgahw/vgaHW.c10
-rw-r--r--hw/xfree86/vgahw/vgaHW.h9
-rw-r--r--hw/xfree86/vgahw/vgaHWmodule.c2
-rw-r--r--hw/xfree86/x86emu/debug.c8
-rw-r--r--hw/xfree86/x86emu/decode.c72
-rw-r--r--hw/xfree86/x86emu/fpu.c1
-rw-r--r--hw/xfree86/x86emu/ops.c30
-rw-r--r--hw/xfree86/x86emu/ops2.c1
-rw-r--r--hw/xfree86/x86emu/prim_ops.c260
-rw-r--r--hw/xfree86/x86emu/sys.c76
-rw-r--r--hw/xfree86/x86emu/x86emu.h14
-rw-r--r--hw/xfree86/x86emu/x86emu/debug.h1
-rw-r--r--hw/xfree86/x86emu/x86emu/decode.h1
-rw-r--r--hw/xfree86/x86emu/x86emu/fpu_regs.h9
-rw-r--r--hw/xfree86/x86emu/x86emu/prim_asm.h1
-rw-r--r--hw/xfree86/x86emu/x86emu/prim_ops.h90
-rw-r--r--hw/xfree86/x86emu/x86emu/regs.h9
-rw-r--r--hw/xfree86/x86emu/x86emu/types.h3
-rw-r--r--hw/xfree86/x86emu/x86emu/x86emui.h5
-rw-r--r--hw/xfree86/xaa/xaa.h40
-rw-r--r--hw/xfree86/xaa/xaaFallback.c7
-rw-r--r--hw/xfree86/xaa/xaaInit.c18
-rw-r--r--hw/xfree86/xaa/xaaInitAccel.c10
-rw-r--r--hw/xfree86/xaa/xaaOverlay.c2
-rw-r--r--hw/xfree86/xaa/xaaPCache.c3
-rw-r--r--hw/xfree86/xaa/xaaPaintWin.c2
-rw-r--r--hw/xfree86/xaa/xaaPict.c109
-rw-r--r--hw/xfree86/xaa/xaaROP.c19
-rw-r--r--hw/xfree86/xaa/xaaStipple.c5
-rw-r--r--hw/xfree86/xaa/xaaTEGlyph.c6
-rw-r--r--hw/xfree86/xaa/xaaWideLine.c5
-rw-r--r--hw/xfree86/xaa/xaalocal.h41
-rw-r--r--hw/xfree86/xaa/xaarop.h6
-rw-r--r--hw/xfree86/xaa/xaawrap.h14
-rw-r--r--hw/xfree86/xf1bpp/mfbmap.h8
-rw-r--r--hw/xfree86/xf1bpp/mfbmodule.c2
-rw-r--r--hw/xfree86/xf4bpp/mfbbres.c6
-rw-r--r--hw/xfree86/xf4bpp/mfbbresd.c6
-rw-r--r--hw/xfree86/xf4bpp/mfbfillarc.c2
-rw-r--r--hw/xfree86/xf4bpp/mfbhrzvert.c2
-rw-r--r--hw/xfree86/xf4bpp/mfbimggblt.c6
-rw-r--r--hw/xfree86/xf4bpp/mfbline.c6
-rw-r--r--hw/xfree86/xf4bpp/mfbzerarc.c2
-rw-r--r--hw/xfree86/xf4bpp/ppcArea.c2
-rw-r--r--hw/xfree86/xf4bpp/ppcGC.c8
-rw-r--r--hw/xfree86/xf4bpp/ppcIO.c8
-rw-r--r--hw/xfree86/xf4bpp/ppcPixFS.c24
-rw-r--r--hw/xfree86/xf4bpp/ppcPntWin.c2
-rw-r--r--hw/xfree86/xf4bpp/ppcPolyPnt.c2
-rw-r--r--hw/xfree86/xf4bpp/ppcWinFS.c24
-rw-r--r--hw/xfree86/xf4bpp/ppcWindow.c2
-rw-r--r--hw/xfree86/xf4bpp/vgaGC.c2
-rw-r--r--hw/xfree86/xf4bpp/vgamodule.c2
-rw-r--r--hw/xfree86/xf8_16bpp/cfb8_16.h5
-rw-r--r--hw/xfree86/xf8_16bpp/cfb8_16module.c2
-rw-r--r--hw/xfree86/xf8_16bpp/cfbscrinit.c2
-rw-r--r--hw/xfree86/xf8_32bpp/cfb8_32.h10
-rw-r--r--hw/xfree86/xf8_32bpp/cfb8_32module.c2
-rw-r--r--hw/xfree86/xf8_32bpp/cfbpntwin.c2
-rw-r--r--hw/xfree86/xf8_32bpp/cfbscrinit.c2
-rw-r--r--hw/xfree86/xf8_32wid/cfb8_32wid.h5
-rw-r--r--hw/xfree86/xf8_32wid/cfb8_32widmodule.c2
-rw-r--r--hw/xfree86/xf8_32wid/cfbscrinit.c4
-rw-r--r--hw/xfree86/xorgconf.cpp2
-rw-r--r--hw/xnest/Args.c5
-rw-r--r--hw/xnest/Cursor.c73
-rw-r--r--hw/xnest/Events.c10
-rw-r--r--hw/xnest/GCOps.c13
-rw-r--r--hw/xnest/Keyboard.c3
-rw-r--r--hw/xnest/Screen.c65
-rw-r--r--hw/xnest/XNCursor.h9
-rw-r--r--hw/xwin/ChangeLog11
-rw-r--r--hw/xwin/InitOutput.c6
-rw-r--r--hw/xwin/README141
-rw-r--r--hw/xwin/win.h2
-rw-r--r--hw/xwin/winallpriv.c6
-rw-r--r--include/cursor.h2
-rw-r--r--include/cursorstr.h12
-rw-r--r--include/dix.h29
-rw-r--r--include/dixstruct.h24
-rw-r--r--include/globals.h13
-rw-r--r--include/input.h17
-rw-r--r--include/inputstr.h5
-rw-r--r--include/os.h4
-rw-r--r--include/pixmapstr.h4
-rw-r--r--include/regionstr.h53
-rw-r--r--include/screenint.h2
-rw-r--r--include/servermd.h4
-rw-r--r--include/window.h10
-rw-r--r--include/windowstr.h7
-rw-r--r--lbx/lbxcmap.c2
-rw-r--r--mfb/maskbits.c6
-rw-r--r--mfb/maskbits.h35
-rw-r--r--mfb/mfb.h6
-rw-r--r--mfb/mfbscrinit.c13
-rw-r--r--mi/mi.h10
-rw-r--r--mi/miarc.c2
-rw-r--r--mi/micmap.c20
-rw-r--r--mi/mieq.c2
-rw-r--r--mi/miexpose.c2
-rw-r--r--mi/miinitext.c144
-rw-r--r--mi/misprite.c1750
-rw-r--r--mi/mispritest.h56
-rw-r--r--mi/mivaltree.c39
-rw-r--r--miext/cw/cw.c685
-rw-r--r--miext/cw/cw.h164
-rw-r--r--miext/cw/cw_ops.c466
-rw-r--r--miext/cw/cw_render.c497
-rwxr-xr-xmiext/damage/damage.c1933
-rwxr-xr-xmiext/damage/damagestr.h107
-rw-r--r--miext/rootless/rootless.h13
-rw-r--r--miext/rootless/rootlessCommon.c87
-rw-r--r--miext/rootless/rootlessCommon.h45
-rw-r--r--miext/rootless/rootlessValTree.c1
-rw-r--r--miext/rootless/rootlessWindow.c57
-rw-r--r--miext/rootless/safeAlpha/safeAlphaWindow.c2
-rw-r--r--miext/shadow/shadow.h7
-rw-r--r--miext/shadow/shpacked.c2
-rw-r--r--miext/shadow/shplanar.c9
-rw-r--r--miext/shadow/shrotate.c4
-rw-r--r--os/access.c203
-rw-r--r--os/log.c14
-rw-r--r--os/utils.c78
-rw-r--r--os/xalloc.c1
-rw-r--r--os/xdmcp.c2
-rw-r--r--record/record.c2
-rw-r--r--render/filter.c48
-rw-r--r--render/glyph.c60
-rw-r--r--render/glyphstr.h21
-rw-r--r--render/mipict.c161
-rw-r--r--render/mipict.h3
-rw-r--r--render/mirect.c11
-rw-r--r--render/mitrap.c70
-rw-r--r--render/mitri.c274
-rw-r--r--render/picture.c228
-rw-r--r--render/picture.h8
-rw-r--r--render/picturestr.h64
-rw-r--r--render/render.c85
-rw-r--r--render/renderedge.c197
-rw-r--r--render/renderedge.h120
-rw-r--r--xkb/ddxFakeMtn.c2
-rw-r--r--xkb/xkbInit.c4
402 files changed, 18760 insertions, 7205 deletions
diff --git a/GL/apple/aglGlx.c b/GL/apple/aglGlx.c
index 106a6464d..fa7533e73 100644
--- a/GL/apple/aglGlx.c
+++ b/GL/apple/aglGlx.c
@@ -1,10 +1,14 @@
/*
* GLX implementation that uses Apple's AGL.framework for OpenGL
+ *
+ * FIXME: This file and indirect.c are very similar. The two should be
+ * merged by introducing suitable abstractions.
*/
/*
* Copyright (c) 2002 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
*
- * Portions of this file are copied from xf86glx.c,
+ * Large portions of this file are copied from Mesa's xf86glx.c,
* which contains the following copyright:
*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -27,10 +31,6 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
*/
/* $XFree86: xc/programs/Xserver/GL/apple/aglGlx.c,v 1.2 2003/09/16 00:36:11 torrey Exp $ */
@@ -58,6 +58,11 @@
#include <GL/internal/glcore.h>
#undef BOOL
+#include "glcontextmodes.h"
+
+// ggs: needed to call back to glx with visual configs
+extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
+
// Write debugging output, or not
#ifdef GLAQUA_DEBUG
#define GLAQUA_DEBUG_MSG ErrorF
@@ -84,14 +89,14 @@ GLboolean glIsTextureEXT (GLuint h) {
// some prototypes
static Bool glAquaScreenProbe(int screen);
static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB);
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB);
static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates);
+ void **privates);
static __GLinterface *glAquaCreateContext(__GLimports *imports,
- __GLcontextModes *mode,
- __GLinterface *shareGC);
+ __GLcontextModes *mode,
+ __GLinterface *shareGC);
static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv);
static void glAquaResetExtension(void);
@@ -102,14 +107,14 @@ static void glAquaResetExtension(void);
* __glXScreenInit to initialize each of the active screens
* (__glXActiveScreens[]). Several of the fields must be initialized by
* the screenProbe routine before they are copied to the active screens
- * struct. In particular, the contextCreate, pGlxVisual, numVisuals,
+ * struct. In particular, the contextCreate, modes, numVisuals,
* and numUsableVisuals fields must be initialized.
*/
-__GLXscreenInfo __glDDXScreenInfo = {
+static __GLXscreenInfo __glDDXScreenInfo = {
glAquaScreenProbe, /* Must be generic and handle all screens */
glAquaCreateContext, /* Substitute screen's createContext routine */
glAquaCreateBuffer, /* Substitute screen's createBuffer routine */
- NULL, /* Set up pGlxVisual in probe */
+ NULL, /* Set up modes in probe */
NULL, /* Set up pVisualPriv in probe */
0, /* Set up numVisuals in probe */
0, /* Set up numUsableVisuals in probe */
@@ -119,13 +124,20 @@ __GLXscreenInfo __glDDXScreenInfo = {
NULL /* WrappedPositionWindow is overwritten */
};
-__GLXextensionInfo __glDDXExtensionInfo = {
+void *__glXglDDXScreenInfo(void) {
+ return &__glDDXScreenInfo;
+}
+
+static __GLXextensionInfo __glDDXExtensionInfo = {
GL_CORE_APPLE,
glAquaResetExtension,
glAquaInitVisuals,
glAquaSetVisualConfigs
};
+void *__glXglDDXExtensionInfo(void) {
+ return &__glDDXExtensionInfo;
+}
// prototypes
@@ -134,7 +146,7 @@ static GLboolean glAquaLoseCurrent(__GLcontext *gc);
static GLboolean glAquaMakeCurrent(__GLcontext *gc);
static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare);
static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
- GLuint mask);
+ GLuint mask);
static GLboolean glAquaForceCurrent(__GLcontext *gc);
/* Drawing surface notification callbacks */
@@ -168,7 +180,7 @@ static __GLexports glAquaExports = {
typedef struct {
int num_vis;
- __GLXvisualConfig *glx_vis;
+ __GLcontextModes *modes;
void **priv;
// wrapped screen functions
@@ -192,6 +204,7 @@ struct __GLcontextRec {
AGLContext ctx;
AGLPixelFormat pixelFormat;
+
Bool isAttached; // TRUE if ctx is really attached to a window
};
@@ -206,22 +219,28 @@ static GLboolean glAquaDestroyContext(__GLcontext *gc)
if (gc->pixelFormat) aglDestroyPixelFormat(gc->pixelFormat);
free(gc);
}
+
return GL_TRUE;
}
static GLboolean glAquaLoseCurrent(__GLcontext *gc)
{
- // GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%x)\n", gc->ctx);
+ GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%x)\n", gc->ctx);
+
aglSetCurrentContext(NULL);
__glXLastContext = NULL; // Mesa does this; why?
+ gc->isAttached = FALSE;
+
return GL_TRUE;
}
-// (x, y, w, h) is global coordinates of view or -1
-// glPriv may be NULL
-static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv,
- int x, int y, int w, int h)
+
+/*
+ * Attach a GL context to a GL drawable
+ * If glPriv is NULL, the context is detached.
+ */
+static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv)
{
__GLXdrawablePrivate *glxPriv;
@@ -244,7 +263,15 @@ static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv,
CRWindowPtr crWinPtr;
AGLDrawable newPort;
- crWinPtr = (CRWindowPtr) quartzProcs->FrameForWindow(pWin, TRUE);
+ if (glPriv->width <= 0 || glPriv->height <= 0) {
+ // attach to zero size drawable - will really attach later
+ GLAQUA_DEBUG_MSG("couldn't attach to zero size drawable\n");
+ aglSetDrawable(gc->ctx, NULL);
+ gc->isAttached = FALSE;
+ return;
+ }
+
+ crWinPtr = (CRWindowPtr) quartzProcs->FrameForWindow(pWin, FALSE);
if (crWinPtr) {
newPort = (AGLDrawable) crWinPtr->port;
@@ -253,35 +280,43 @@ static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv,
}
if (newPort) {
- // fixme won't be a CGrafPtr if currently offscreen or fullscreen
+ // FIXME: won't be a CGrafPtr if currently offscreen or fullscreen
AGLDrawable oldPort = aglGetDrawable(gc->ctx);
// AGLDrawable newPort = GetWindowPort(window);
- GLint frame[4] = {x, y, w, h}; // fixme multi-screen?
- // frame is now X11-global
+
+ // Frame is GLdrawable in X11 global coordinates
+ // FIXME: Does this work for multiple screens?
+ GLint frame[4] = {glPriv->xOrigin, glPriv->yOrigin, glPriv->width, glPriv->height};
+ GLAQUA_DEBUG_MSG("global size %d %d %d %d\n",
+ frame[0], frame[1], frame[2], frame[3]);
+
+ // Convert to window-local coordinates
frame[0] -= topWin->drawable.x - topWin->borderWidth;
frame[1] -= topWin->drawable.y - topWin->borderWidth;
- // frame is now window-local
- // GL uses flipped coordinates
+
+ // AGL uses flipped coordinates
frame[1] = topWin->drawable.height + 2*topWin->borderWidth -
frame[1] - frame[3];
- // GLAQUA_DEBUG_MSG("local size %d %d %d %d\n",
- // frame[0], frame[1], frame[2], frame[3]);
+ GLAQUA_DEBUG_MSG("local size %d %d %d %d\n",
+ frame[0], frame[1], frame[2], frame[3]);
if (oldPort != newPort) {
- // fixme retain/release windows
- aglSetDrawable(gc->ctx, newPort);
+ // FIXME: retain/release windows
+ if (!aglSetDrawable(gc->ctx, newPort)) return;
}
- aglSetInteger(gc->ctx, AGL_BUFFER_RECT, frame);
- aglEnable(gc->ctx, AGL_BUFFER_RECT);
- // aglSetInteger(gc->ctx, AGL_SWAP_RECT, frame);
- // aglEnable(gc->ctx, AGL_SWAP_RECT);
- aglUpdateContext(gc->ctx);
+ if (!aglSetInteger(gc->ctx, AGL_BUFFER_RECT, frame)) return;
+ if (!aglEnable(gc->ctx, AGL_BUFFER_RECT)) return;
+ if (!aglSetInteger(gc->ctx, AGL_SWAP_RECT, frame)) return;
+ if (!aglEnable(gc->ctx, AGL_SWAP_RECT)) return;
+ if (!aglUpdateContext(gc->ctx)) return;
+
gc->isAttached = TRUE;
- GLAQUA_DEBUG_MSG("attached\n");
+ GLAQUA_DEBUG_MSG("attached context 0x%x to window 0x%x\n", gc->ctx,
+ pWin->drawable.id);
} else {
// attach to not-yet-realized window - will really attach later
- GLAQUA_DEBUG_MSG("couldn't attach\n");
+ GLAQUA_DEBUG_MSG("couldn't attach to unrealized window\n");
aglSetDrawable(gc->ctx, NULL);
gc->isAttached = FALSE;
}
@@ -294,14 +329,14 @@ static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv,
static GLboolean glAquaMakeCurrent(__GLcontext *gc)
{
-#if 0
__GLdrawablePrivate *glPriv = gc->interface.imports.getDrawablePrivate(gc);
+
GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%x)\n", gc->ctx);
if (!gc->isAttached) {
- attach(gc, glPriv, glPriv->xOrigin, glPriv->yOrigin, glPriv->width, glPriv->height);
+ attach(gc, glPriv);
}
-#endif
+
return aglSetCurrentContext(gc->ctx);
}
@@ -317,8 +352,8 @@ static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
GLuint mask)
{
GLAQUA_DEBUG_MSG("glAquaCopyContext\n");
- aglCopyContext(src->ctx, dst->ctx, mask);
- return GL_TRUE;
+
+ return aglCopyContext(src->ctx, dst->ctx, mask);
}
static GLboolean glAquaForceCurrent(__GLcontext *gc)
@@ -436,16 +471,15 @@ static AGLPixelFormat makeFormat(__GLcontextModes *mode)
}
static __GLinterface *glAquaCreateContext(__GLimports *imports,
- __GLcontextModes *mode,
- __GLinterface *shareGC)
+ __GLcontextModes *mode,
+ __GLinterface *shareGC)
{
__GLcontext *result;
__GLcontext *sharectx = (__GLcontext *)shareGC;
- GLint value;
GLAQUA_DEBUG_MSG("glAquaCreateContext\n");
- result = (__GLcontext *)malloc(sizeof(__GLcontext));
+ result = (__GLcontext *)calloc(1, sizeof(__GLcontext));
if (!result) return NULL;
result->interface.imports = *imports;
@@ -468,10 +502,6 @@ static __GLinterface *glAquaCreateContext(__GLimports *imports,
result->isAttached = FALSE;
- // Tell aglSwapBuffers to wait for vertical retrace
- value = 1;
- aglSetInteger(result->ctx, AGL_SWAP_INTERVAL, &value);
-
GLAQUA_DEBUG_MSG("glAquaCreateContext done\n");
return (__GLinterface *)result;
}
@@ -505,17 +535,15 @@ glAquaRealizeWindow(WindowPtr pWin)
GLAQUA_DEBUG_MSG("glAquaRealizeWindow is GL drawable!\n");
// GL contexts bound to this window for drawing
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
+ for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) {
gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv, glxPriv->xorigin, glxPriv->yorigin,
- glxPriv->width, glxPriv->height);
+ attach(gc, glPriv);
}
// GL contexts bound to this window for reading
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
+ for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv, glxPriv->xorigin, glxPriv->yorigin,
- glxPriv->width, glxPriv->height);
+ attach(gc, glPriv);
}
}
@@ -544,15 +572,15 @@ glAquaUnrealizeWindow(WindowPtr pWin)
GLAQUA_DEBUG_MSG("glAquaUnealizeWindow is GL drawable!\n");
// GL contexts bound to this window for drawing
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
+ for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) {
gc = (__GLcontext *)gx->gc;
- attach(gc, NULL, 0, 0, 0, 0);
+ attach(gc, NULL);
}
// GL contexts bound to this window for reading
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
+ for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
gc = (__GLcontext *)gx->gc;
- attach(gc, NULL, 0, 0, 0, 0);
+ attach(gc, NULL);
}
}
@@ -564,23 +592,21 @@ glAquaUnrealizeWindow(WindowPtr pWin)
}
-
-
-
-
-/*
- * In the case the driver has no GLX visuals we'll use these.
- * [0] = RGB, double buffered
- * [1] = RGB, double buffered, stencil, accum
- */
// Originally copied from Mesa
static int numConfigs = 0;
static __GLXvisualConfig *visualConfigs = NULL;
static void **visualPrivates = NULL;
-#define NUM_FALLBACK_CONFIGS 2
+/*
+ * In the case the driver defines no GLX visuals we'll use these.
+ * Note that for TrueColor and DirectColor visuals, bufferSize is the
+ * sum of redSize, greenSize, blueSize and alphaSize, which may be larger
+ * than the nplanes/rootDepth of the server's X11 visuals
+ */
+#define NUM_FALLBACK_CONFIGS 5
static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
+ /* [0] = RGB, double buffered, Z */
{
-1, /* vid */
-1, /* class */
@@ -595,11 +621,12 @@ static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
0, /* stencilSize */
0, /* auxBuffers */
0, /* level */
- GLX_NONE_EXT, /* visualRating */
- 0, /* transparentPixel */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
0 /* transparentIndex */
},
+ /* [1] = RGB, double buffered, Z, stencil, accum */
{
-1, /* vid */
-1, /* class */
@@ -614,15 +641,94 @@ static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
8, /* stencilSize */
0, /* auxBuffers */
0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ False, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [4] = CI, double buffered, Z */
+ {
+ -1, /* vid */
+ -1, /* class */
+ False, /* rgba? (false = color index) */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+};
+
+static __GLXvisualConfig NullConfig = {
+ -1, /* vid */
+ -1, /* class */
+ False, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ False, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
GLX_NONE_EXT, /* visualRating */
0, /* transparentPixel */
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
0 /* transparentIndex */
- }
};
-
static int count_bits(unsigned int n)
{
int bits = 0;
@@ -635,11 +741,10 @@ static int count_bits(unsigned int n)
}
-// Mostly copied from Mesa's xf86glx.c
static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
- VisualID *defaultVisp,
- int ndepth, DepthPtr pdepth,
- int rootDepth)
+ VisualID *defaultVisp,
+ int ndepth, DepthPtr pdepth,
+ int rootDepth)
{
int numRGBconfigs;
int numCIconfigs;
@@ -649,7 +754,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
VisualPtr pVisual = *visualp;
VisualPtr pVisualNew = NULL;
VisualID *orig_vid = NULL;
- __GLXvisualConfig *glXVisualPtr = NULL;
+ __GLcontextModes *modes;
__GLXvisualConfig *pNewVisualConfigs = NULL;
void **glXVisualPriv;
void **pNewVisualPriv;
@@ -667,14 +772,14 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
pNewVisualConfigs = (__GLXvisualConfig *)
__glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
if (!pNewVisualConfigs) {
- return FALSE;
+ return FALSE;
}
/* Alloc space for the list of new GLX visual privates */
pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
if (!pNewVisualPriv) {
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
}
/*
@@ -682,9 +787,9 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
** visual configs.
*/
if (numConfigs == 0) {
- memcpy(pNewVisualConfigs, FallbackConfigs,
+ memcpy(pNewVisualConfigs, FallbackConfigs,
NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
- memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
+ memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
}
else {
/* copy driver's visual config info */
@@ -698,18 +803,24 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
numRGBconfigs = 0;
numCIconfigs = 0;
for (i = 0; i < numNewConfigs; i++) {
- if (pNewVisualConfigs[i].rgba)
- numRGBconfigs++;
- else
- numCIconfigs++;
+ if (pNewVisualConfigs[i].rgba)
+ numRGBconfigs++;
+ else
+ numCIconfigs++;
}
/* Count the total number of visuals to compute */
numNewVisuals = 0;
for (i = 0; i < numVisuals; i++) {
- numNewVisuals +=
- (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor)
- ? numRGBconfigs : numCIconfigs;
+ int count;
+
+ count = ((pVisual[i].class == TrueColor ||
+ pVisual[i].class == DirectColor)
+ ? numRGBconfigs : numCIconfigs);
+ if (count == 0)
+ count = 1; /* preserve the existing visual */
+
+ numNewVisuals += count;
}
/* Reset variables for use with the next screen/driver's visual configs */
@@ -719,127 +830,159 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
/* Alloc temp space for the list of orig VisualIDs for each new visual */
orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID));
if (!orig_vid) {
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
}
/* Alloc space for the list of glXVisuals */
- glXVisualPtr = (__GLXvisualConfig *)__glXMalloc(numNewVisuals *
- sizeof(__GLXvisualConfig));
- if (!glXVisualPtr) {
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
+ if (modes == NULL) {
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
}
/* Alloc space for the list of glXVisualPrivates */
glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
if (!glXVisualPriv) {
- __glXFree(glXVisualPtr);
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
}
/* Alloc space for the new list of the X server's visuals */
pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
if (!pVisualNew) {
- __glXFree(glXVisualPriv);
- __glXFree(glXVisualPtr);
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ __glXFree(glXVisualPriv);
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
}
/* Initialize the new visuals */
found_default = FALSE;
+ glAquaScreens[screenInfo.numScreens-1].modes = modes;
for (i = j = 0; i < numVisuals; i++) {
int is_rgb = (pVisual[i].class == TrueColor ||
- pVisual[i].class == DirectColor);
-
- for (k = 0; k < numNewConfigs; k++) {
- if (pNewVisualConfigs[k].rgba != is_rgb)
- continue;
-
- /* Initialize the new visual */
- pVisualNew[j] = pVisual[i];
- pVisualNew[j].vid = FakeClientID(0);
-
- /* Check for the default visual */
- if (!found_default && pVisual[i].vid == *defaultVisp) {
- *defaultVisp = pVisualNew[j].vid;
- found_default = TRUE;
- }
-
- /* Save the old VisualID */
- orig_vid[j] = pVisual[i].vid;
-
- /* Initialize the glXVisual */
- glXVisualPtr[j] = pNewVisualConfigs[k];
- glXVisualPtr[j].vid = pVisualNew[j].vid;
-
- /*
- * If the class is -1, then assume the X visual information
- * is identical to what GLX needs, and take them from the X
- * visual. NOTE: if class != -1, then all other fields MUST
- * be initialized.
- */
- if (glXVisualPtr[j].class == -1) {
- glXVisualPtr[j].class = pVisual[i].class;
- glXVisualPtr[j].redSize = count_bits(pVisual[i].redMask);
- glXVisualPtr[j].greenSize = count_bits(pVisual[i].greenMask);
- glXVisualPtr[j].blueSize = count_bits(pVisual[i].blueMask);
- glXVisualPtr[j].alphaSize = glXVisualPtr[j].alphaSize;
- glXVisualPtr[j].redMask = pVisual[i].redMask;
- glXVisualPtr[j].greenMask = pVisual[i].greenMask;
- glXVisualPtr[j].blueMask = pVisual[i].blueMask;
- glXVisualPtr[j].alphaMask = glXVisualPtr[j].alphaMask;
- glXVisualPtr[j].bufferSize = rootDepth;
- }
-
- /* Save the device-dependent private for this visual */
- glXVisualPriv[j] = pNewVisualPriv[k];
-
- j++;
- }
+ pVisual[i].class == DirectColor);
+
+ if (!is_rgb)
+ {
+ /* We don't support non-rgb visuals for GL. But we don't
+ want to remove them either, so just pass them through
+ with null glX configs */
+
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & NullConfig );
+ modes->visualID = pVisualNew[j].vid;
+
+ j++;
+
+ continue;
+ }
+
+ for (k = 0; k < numNewConfigs; k++) {
+ if (pNewVisualConfigs[k].rgba != is_rgb)
+ continue;
+
+ assert( modes != NULL );
+
+ /* Initialize the new visual */
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
+ modes->visualID = pVisualNew[j].vid;
+
+ /*
+ * If the class is -1, then assume the X visual information
+ * is identical to what GLX needs, and take them from the X
+ * visual. NOTE: if class != -1, then all other fields MUST
+ * be initialized.
+ */
+ if (modes->visualType == GLX_NONE) {
+ modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
+ modes->redBits = count_bits(pVisual[i].redMask);
+ modes->greenBits = count_bits(pVisual[i].greenMask);
+ modes->blueBits = count_bits(pVisual[i].blueMask);
+ modes->alphaBits = modes->alphaBits;
+ modes->redMask = pVisual[i].redMask;
+ modes->greenMask = pVisual[i].greenMask;
+ modes->blueMask = pVisual[i].blueMask;
+ modes->alphaMask = modes->alphaMask;
+ modes->rgbBits = (is_rgb)
+ ? (modes->redBits + modes->greenBits +
+ modes->blueBits + modes->alphaBits)
+ : rootDepth;
+ }
+
+ /* Save the device-dependent private for this visual */
+ glXVisualPriv[j] = pNewVisualPriv[k];
+
+ j++;
+ modes = modes->next;
+ }
}
assert(j <= numNewVisuals);
/* Save the GLX visuals in the screen structure */
glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
- glAquaScreens[screenInfo.numScreens-1].glx_vis = glXVisualPtr;
glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv;
/* Set up depth's VisualIDs */
for (i = 0; i < ndepth; i++) {
- int numVids = 0;
- VisualID *pVids = NULL;
- int k, n = 0;
-
- /* Count the new number of VisualIDs at this depth */
- for (j = 0; j < pdepth[i].numVids; j++)
- for (k = 0; k < numNewVisuals; k++)
- if (pdepth[i].vids[j] == orig_vid[k])
- numVids++;
-
- /* Allocate a new list of VisualIDs for this depth */
- pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
-
- /* Initialize the new list of VisualIDs for this depth */
- for (j = 0; j < pdepth[i].numVids; j++)
- for (k = 0; k < numNewVisuals; k++)
- if (pdepth[i].vids[j] == orig_vid[k])
- pVids[n++] = pVisualNew[k].vid;
-
- /* Update this depth's list of VisualIDs */
- __glXFree(pdepth[i].vids);
- pdepth[i].vids = pVids;
- pdepth[i].numVids = numVids;
+ int numVids = 0;
+ VisualID *pVids = NULL;
+ int k, n = 0;
+
+ /* Count the new number of VisualIDs at this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ numVids++;
+
+ /* Allocate a new list of VisualIDs for this depth */
+ pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
+
+ /* Initialize the new list of VisualIDs for this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ pVids[n++] = pVisualNew[k].vid;
+
+ /* Update this depth's list of VisualIDs */
+ __glXFree(pdepth[i].vids);
+ pdepth[i].vids = pVids;
+ pdepth[i].numVids = numVids;
}
/* Update the X server's visuals */
@@ -862,9 +1005,96 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
return TRUE;
}
-// Copied from Mesa
+/* based on code in i830_dri.c
+ This ends calling glAquaSetVisualConfigs to set the static
+ numconfigs, etc. */
+static void
+glAquaInitVisualConfigs(void)
+{
+ int lclNumConfigs = 0;
+ __GLXvisualConfig *lclVisualConfigs = NULL;
+ void **lclVisualPrivates = NULL;
+
+ int depth, aux, buffers, stencil, accum;
+ int i = 0;
+
+ GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs ");
+
+ /* count num configs:
+ 2 Z buffer (0, 24 bit)
+ 2 AUX buffer (0, 2)
+ 2 buffers (single, double)
+ 2 stencil (0, 8 bit)
+ 2 accum (0, 64 bit)
+ = 32 configs */
+
+ lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
+
+ /* alloc */
+ lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs);
+ lclVisualPrivates = xcalloc(sizeof(void *), lclNumConfigs);
+
+ /* fill in configs */
+ if (NULL != lclVisualConfigs) {
+ i = 0; /* current buffer */
+ for (depth = 0; depth < 2; depth++) {
+ for (aux = 0; aux < 2; aux++) {
+ for (buffers = 0; buffers < 2; buffers++) {
+ for (stencil = 0; stencil < 2; stencil++) {
+ for (accum = 0; accum < 2; accum++) {
+ lclVisualConfigs[i].vid = -1;
+ lclVisualConfigs[i].class = -1;
+ lclVisualConfigs[i].rgba = TRUE;
+ lclVisualConfigs[i].redSize = -1;
+ lclVisualConfigs[i].greenSize = -1;
+ lclVisualConfigs[i].blueSize = -1;
+ lclVisualConfigs[i].redMask = -1;
+ lclVisualConfigs[i].greenMask = -1;
+ lclVisualConfigs[i].blueMask = -1;
+ lclVisualConfigs[i].alphaMask = 0;
+ if (accum) {
+ lclVisualConfigs[i].accumRedSize = 16;
+ lclVisualConfigs[i].accumGreenSize = 16;
+ lclVisualConfigs[i].accumBlueSize = 16;
+ lclVisualConfigs[i].accumAlphaSize = 16;
+ }
+ else {
+ lclVisualConfigs[i].accumRedSize = 0;
+ lclVisualConfigs[i].accumGreenSize = 0;
+ lclVisualConfigs[i].accumBlueSize = 0;
+ lclVisualConfigs[i].accumAlphaSize = 0;
+ }
+ lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
+ lclVisualConfigs[i].stereo = FALSE;
+ lclVisualConfigs[i].bufferSize = -1;
+
+ lclVisualConfigs[i].depthSize = depth? 24 : 0;
+ lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
+ lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
+ lclVisualConfigs[i].level = 0;
+ lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
+ lclVisualConfigs[i].transparentPixel = 0;
+ lclVisualConfigs[i].transparentRed = 0;
+ lclVisualConfigs[i].transparentGreen = 0;
+ lclVisualConfigs[i].transparentBlue = 0;
+ lclVisualConfigs[i].transparentAlpha = 0;
+ lclVisualConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (i != lclNumConfigs)
+ GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs");
+
+ GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates);
+}
+
+
static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates)
+ void **privates)
{
GLAQUA_DEBUG_MSG("glAquaSetVisualConfigs\n");
@@ -873,19 +1103,21 @@ static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
visualPrivates = privates;
}
-// Copied from Mesa
static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB)
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB)
{
GLAQUA_DEBUG_MSG("glAquaInitVisuals\n");
+ if (numConfigs == 0) /* if no configs */
+ glAquaInitVisualConfigs(); /* ensure the visual configs are setup */
+
/*
* Setup the visuals supported by this particular screen.
*/
return init_visuals(nvisualp, visualp, defaultVisp,
- *ndepthp, *depthp, *rootDepthp);
+ *ndepthp, *depthp, *rootDepthp);
}
@@ -893,100 +1125,92 @@ static void fixup_visuals(int screen)
{
ScreenPtr pScreen = screenInfo.screens[screen];
glAquaScreenRec *pScr = &glAquaScreens[screen];
- __GLXvisualConfig *pGLXVis = pScr->glx_vis;
- VisualPtr pVis;
- int i, j;
+ int j;
+ __GLcontextModes *modes;
GLAQUA_DEBUG_MSG("fixup_visuals\n");
- for (i = 0; i < pScr->num_vis; i++, pGLXVis++) {
- pVis = pScreen->visuals;
-
- /* Find a visual that matches the GLX visual's class and size */
- for (j = 0; j < pScreen->numVisuals; j++, pVis++) {
- if (pVis->class == pGLXVis->class &&
- pVis->nplanes == pGLXVis->bufferSize) {
-
- /* Fixup the masks */
- pGLXVis->redMask = pVis->redMask;
- pGLXVis->greenMask = pVis->greenMask;
- pGLXVis->blueMask = pVis->blueMask;
-
- /* Recalc the sizes */
- pGLXVis->redSize = count_bits(pGLXVis->redMask);
- pGLXVis->greenSize = count_bits(pGLXVis->greenMask);
- pGLXVis->blueSize = count_bits(pGLXVis->blueMask);
- }
- }
+ for ( modes = pScr->modes ; modes != NULL ; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ /* Find a visual that matches the GLX visual's class and size */
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes) {
+
+ /* Fixup the masks */
+ modes->redMask = pVis[j].redMask;
+ modes->greenMask = pVis[j].greenMask;
+ modes->blueMask = pVis[j].blueMask;
+
+ /* Recalc the sizes */
+ modes->redBits = count_bits(modes->redMask);
+ modes->greenBits = count_bits(modes->greenMask);
+ modes->blueBits = count_bits(modes->blueMask);
+ }
+ }
}
}
static void init_screen_visuals(int screen)
{
ScreenPtr pScreen = screenInfo.screens[screen];
- __GLXvisualConfig *pGLXVis = glAquaScreens[screen].glx_vis;
- // XMesaVisual *pXMesaVisual;
- VisualPtr pVis;
+ __GLcontextModes *modes;
int *used;
int i, j;
GLAQUA_DEBUG_MSG("init_screen_visuals\n");
- /* Alloc space for the list of XMesa visuals */
- // pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis *
- // sizeof(XMesaVisual));
- // __glXMemset(pXMesaVisual, 0,
- // MESAScreens[screen].num_vis * sizeof(XMesaVisual));
-
+ /* FIXME: Change 'used' to be a array of bits (rather than of ints),
+ * FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less
+ * FIXME: than 64 or 128 the stack array can be used instead of calling
+ * FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to
+ * FIXME: array of bytes instead of ints!
+ */
used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
__glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
- for (i = 0; i < glAquaScreens[screen].num_vis; i++, pGLXVis++) {
- pVis = pScreen->visuals;
- for (j = 0; j < pScreen->numVisuals; j++, pVis++) {
-
- if (pVis->class == pGLXVis->class &&
- pVis->nplanes == pGLXVis->bufferSize &&
- !used[j]) {
-
- if (pVis->redMask == pGLXVis->redMask &&
- pVis->greenMask == pGLXVis->greenMask &&
- pVis->blueMask == pGLXVis->blueMask) {
-
- /* Create the XMesa visual */
- /*
- pXMesaVisual[i] =
- XMesaCreateVisual(pScreen,
- pVis,
- pGLXVis->rgba,
- (pGLXVis->alphaSize > 0),
- pGLXVis->doubleBuffer,
- pGLXVis->stereo,
- GL_TRUE, // ximage_flag
- pGLXVis->depthSize,
- pGLXVis->stencilSize,
- pGLXVis->accumRedSize,
- pGLXVis->accumGreenSize,
- pGLXVis->accumBlueSize,
- pGLXVis->accumAlphaSize,
- 0, // numSamples
- pGLXVis->level,
- pGLXVis->visualRating );
- */
- /* Set the VisualID */
- pGLXVis->vid = pVis->vid;
-
- /* Mark this visual used */
- used[j] = 1;
- break;
- }
- }
- }
+ i = 0;
+ for ( modes = glAquaScreens[screen].modes
+ ; modes != NULL
+ ; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes &&
+ pVis[j].redMask == modes->redMask &&
+ pVis[j].greenMask == modes->greenMask &&
+ pVis[j].blueMask == modes->blueMask &&
+ !used[j]) {
+
+ /* Set the VisualID */
+ modes->visualID = pVis[j].vid;
+
+ /* Mark this visual used */
+ used[j] = 1;
+ break;
+ }
+ }
+ if ( j == pScreen->numVisuals ) {
+ ErrorF("No matching visual for __GLcontextMode with "
+ "visual class = %d (%d), nplanes = %u\n",
+ vis_class,
+ (int)modes->visualType,
+ (unsigned int)(modes->rgbBits - modes->alphaBits) );
+ }
+ else if ( modes->visualID == -1 ) {
+ FatalError( "Matching visual found, but visualID still -1!\n" );
+ }
+
+ i++;
}
__glXFree(used);
-
- // glAquaScreens[screen].xm_vis = pXMesaVisual;
}
static Bool glAquaScreenProbe(int screen)
@@ -999,10 +1223,10 @@ static Bool glAquaScreenProbe(int screen)
/*
* Set up the current screen's visuals.
*/
- __glDDXScreenInfo.pGlxVisual = glAquaScreens[screen].glx_vis;
+ __glDDXScreenInfo.modes = glAquaScreens[screen].modes;
__glDDXScreenInfo.pVisualPriv = glAquaScreens[screen].priv;
__glDDXScreenInfo.numVisuals =
- __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis;
+ __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis;
/*
* Set the current screen's createContext routine. This could be
@@ -1022,7 +1246,9 @@ static Bool glAquaScreenProbe(int screen)
*/
init_screen_visuals(screen);
- // Wrap RealizeWindow and UnrealizeWindow on this screen
+ /*
+ * Wrap RealizeWindow and UnrealizeWindow on this screen
+ */
pScreen = screenInfo.screens[screen];
screenPriv = &glAquaScreens[screen];
screenPriv->RealizeWindow = pScreen->RealizeWindow;
@@ -1035,28 +1261,28 @@ static Bool glAquaScreenProbe(int screen)
static GLboolean glAquaResizeBuffers(__GLdrawableBuffer *buffer,
- GLint x, GLint y,
- GLuint width, GLuint height,
- __GLdrawablePrivate *glPriv,
- GLuint bufferMask)
+ GLint x, GLint y,
+ GLuint width, GLuint height,
+ __GLdrawablePrivate *glPriv,
+ GLuint bufferMask)
{
GLAquaDrawableRec *aquaPriv = (GLAquaDrawableRec *)glPriv->private;
+ __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
__GLXcontext *gx;
__GLcontext *gc;
- __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
GLAQUA_DEBUG_MSG("glAquaResizeBuffers to (%d %d %d %d)\n", x, y, width, height);
// update all contexts that point at this drawable for drawing (hack?)
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
+ for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) {
gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv, x, y, width, height);
+ attach(gc, glPriv);
}
// update all contexts that point at this drawable for reading (hack?)
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
+ for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv, x, y, width, height);
+ attach(gc, glPriv);
}
return aquaPriv->resize(buffer, x, y, width, height, glPriv, bufferMask);
@@ -1122,24 +1348,24 @@ GLint __glEvalComputeK(GLenum target)
case GL_MAP2_VERTEX_4:
case GL_MAP2_COLOR_4:
case GL_MAP2_TEXTURE_COORD_4:
- return 4;
+ return 4;
case GL_MAP1_VERTEX_3:
case GL_MAP1_TEXTURE_COORD_3:
case GL_MAP1_NORMAL:
case GL_MAP2_VERTEX_3:
case GL_MAP2_TEXTURE_COORD_3:
case GL_MAP2_NORMAL:
- return 3;
+ return 3;
case GL_MAP1_TEXTURE_COORD_2:
case GL_MAP2_TEXTURE_COORD_2:
- return 2;
+ return 2;
case GL_MAP1_TEXTURE_COORD_1:
case GL_MAP2_TEXTURE_COORD_1:
case GL_MAP1_INDEX:
case GL_MAP2_INDEX:
- return 1;
+ return 1;
default:
- return 0;
+ return 0;
}
}
@@ -1148,8 +1374,8 @@ GLuint __glFloorLog2(GLuint val)
int c = 0;
while (val > 1) {
- c++;
- val >>= 1;
+ c++;
+ val >>= 1;
}
return c;
}
diff --git a/GL/apple/indirect.c b/GL/apple/indirect.c
index c4d235a47..f885e526e 100644
--- a/GL/apple/indirect.c
+++ b/GL/apple/indirect.c
@@ -5,8 +5,9 @@
/*
* Copyright (c) 2002 Greg Parker. All Rights Reserved.
* Copyright (c) 2002 Apple Computer, Inc.
+ * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
*
- * Portions of this file are copied from xf86glx.c,
+ * Portions of this file are copied from Mesa's xf86glx.c,
* which contains the following copyright:
*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -29,10 +30,6 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
*/
/* $XFree86: xc/programs/Xserver/GL/apple/indirect.c,v 1.2 2003/09/16 00:36:11 torrey Exp $ */
@@ -61,6 +58,8 @@
#include "x-hash.h"
#include "x-list.h"
+#include "glcontextmodes.h"
+
// ggs: needed to call back to glx with visual configs
extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
@@ -89,14 +88,14 @@ GLboolean glIsTextureEXT(GLuint h) {
// some prototypes
static Bool glAquaScreenProbe(int screen);
static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB);
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB);
static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates);
+ void **privates);
static __GLinterface *glAquaCreateContext(__GLimports *imports,
- __GLcontextModes *mode,
- __GLinterface *shareGC);
+ __GLcontextModes *mode,
+ __GLinterface *shareGC);
static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv);
static void glAquaResetExtension(void);
@@ -106,14 +105,14 @@ static void glAquaResetExtension(void);
* __glXScreenInit to initialize each of the active screens
* (__glXActiveScreens[]). Several of the fields must be initialized by
* the screenProbe routine before they are copied to the active screens
- * struct. In particular, the contextCreate, pGlxVisual, numVisuals,
+ * struct. In particular, the contextCreate, modes, numVisuals,
* and numUsableVisuals fields must be initialized.
*/
-__GLXscreenInfo __glDDXScreenInfo = {
+static __GLXscreenInfo __glDDXScreenInfo = {
glAquaScreenProbe, /* Must be generic and handle all screens */
glAquaCreateContext, /* Substitute screen's createContext routine */
glAquaCreateBuffer, /* Substitute screen's createBuffer routine */
- NULL, /* Set up pGlxVisual in probe */
+ NULL, /* Set up modes in probe */
NULL, /* Set up pVisualPriv in probe */
0, /* Set up numVisuals in probe */
0, /* Set up numUsableVisuals in probe */
@@ -123,13 +122,21 @@ __GLXscreenInfo __glDDXScreenInfo = {
NULL /* WrappedPositionWindow is overwritten */
};
-__GLXextensionInfo __glDDXExtensionInfo = {
+void *__glXglDDXScreenInfo(void) {
+ return &__glDDXScreenInfo;
+}
+
+static __GLXextensionInfo __glDDXExtensionInfo = {
GL_CORE_APPLE,
glAquaResetExtension,
glAquaInitVisuals,
glAquaSetVisualConfigs
};
+void *__glXglDDXExtensionInfo(void) {
+ return &__glDDXExtensionInfo;
+}
+
// prototypes
static GLboolean glAquaDestroyContext(__GLcontext *gc);
@@ -137,7 +144,7 @@ static GLboolean glAquaLoseCurrent(__GLcontext *gc);
static GLboolean glAquaMakeCurrent(__GLcontext *gc);
static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare);
static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
- GLuint mask);
+ GLuint mask);
static GLboolean glAquaForceCurrent(__GLcontext *gc);
/* Drawing surface notification callbacks */
@@ -169,7 +176,7 @@ static __GLexports glAquaExports = {
typedef struct {
int num_vis;
- __GLXvisualConfig *glx_vis;
+ __GLcontextModes *modes;
void **priv;
// wrapped screen functions
@@ -186,15 +193,15 @@ typedef struct {
} GLAquaDrawableRec;
struct __GLcontextRec {
- struct __GLinterfaceRec interface; // required to be first
+ struct __GLinterfaceRec interface; // required to be first
- CGLContextObj ctx;
- CGLPixelFormatObj pixelFormat;
+ CGLContextObj ctx;
+ CGLPixelFormatObj pixelFormat;
- /* set when attached */
- xp_surface_id sid;
+ /* set when attached */
+ xp_surface_id sid;
- unsigned isAttached :1;
+ unsigned isAttached :1;
};
/* maps from surface id -> list of __GLcontext */
@@ -210,18 +217,18 @@ static GLboolean glAquaDestroyContext(__GLcontext *gc)
if (gc != NULL)
{
- if (gc->sid != 0 && surface_hash != NULL)
- {
- lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
- lst = x_list_remove(lst, gc);
- x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
- }
+ if (gc->sid != 0 && surface_hash != NULL)
+ {
+ lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
+ lst = x_list_remove(lst, gc);
+ x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
+ }
if (gc->ctx != NULL)
- CGLDestroyContext(gc->ctx);
+ CGLDestroyContext(gc->ctx);
if (gc->pixelFormat != NULL)
- CGLDestroyPixelFormat(gc->pixelFormat);
+ CGLDestroyPixelFormat(gc->pixelFormat);
free(gc);
}
@@ -237,7 +244,7 @@ static GLboolean glAquaLoseCurrent(__GLcontext *gc)
gl_err = CGLSetCurrentContext(NULL);
if (gl_err != 0)
- ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
+ ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
__glXLastContext = NULL; // Mesa does this; why?
@@ -256,24 +263,24 @@ static void surface_notify(void *_arg, void *data)
switch (arg->kind)
{
case AppleDRISurfaceNotifyDestroyed:
- if (surface_hash != NULL)
- x_hash_table_remove(surface_hash, (void *) arg->id);
+ if (surface_hash != NULL)
+ x_hash_table_remove(surface_hash, (void *) arg->id);
- aquaPriv->pDraw = NULL;
- aquaPriv->sid = 0;
- break;
+ aquaPriv->pDraw = NULL;
+ aquaPriv->sid = 0;
+ break;
case AppleDRISurfaceNotifyChanged:
- if (surface_hash != NULL)
- {
- lst = x_hash_table_lookup(surface_hash, (void *) arg->id, NULL);
- for (; lst != NULL; lst = lst->next)
- {
- gc = lst->data;
- xp_update_gl_context(gc->ctx);
- }
- }
- break;
+ if (surface_hash != NULL)
+ {
+ lst = x_hash_table_lookup(surface_hash, (void *) arg->id, NULL);
+ for (; lst != NULL; lst = lst->next)
+ {
+ gc = lst->data;
+ xp_update_gl_context(gc->ctx);
+ }
+ }
+ break;
}
}
@@ -283,18 +290,18 @@ static void unattach(__GLcontext *gc)
if (gc->isAttached)
{
- GLAQUA_DEBUG_MSG("unattaching\n");
-
- if (surface_hash != NULL)
- {
- lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
- lst = x_list_remove(lst, gc);
- x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
- }
-
- CGLClearDrawable(gc->ctx);
- gc->isAttached = FALSE;
- gc->sid = 0;
+ GLAQUA_DEBUG_MSG("unattaching\n");
+
+ if (surface_hash != NULL)
+ {
+ lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
+ lst = x_list_remove(lst, gc);
+ x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
+ }
+
+ CGLClearDrawable(gc->ctx);
+ gc->isAttached = FALSE;
+ gc->sid = 0;
}
}
@@ -307,52 +314,52 @@ static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv)
if (glxPriv->type == DRAWABLE_WINDOW)
{
WindowPtr pWin = (WindowPtr) glxPriv->pDraw;
- GLAquaDrawableRec *aquaPriv = (GLAquaDrawableRec *)glPriv->private;
- x_list *lst;
+ GLAquaDrawableRec *aquaPriv = (GLAquaDrawableRec *)glPriv->private;
+ x_list *lst;
- if (aquaPriv->sid == 0)
- {
- if (!quartzProcs->CreateSurface(pWin->drawable.pScreen,
+ if (aquaPriv->sid == 0)
+ {
+ if (!quartzProcs->CreateSurface(pWin->drawable.pScreen,
pWin->drawable.id, &pWin->drawable,
0, &aquaPriv->sid, NULL,
surface_notify, aquaPriv))
- {
- return;
- }
- aquaPriv->pDraw = &pWin->drawable;
- }
-
- if (!gc->isAttached || gc->sid != aquaPriv->sid)
- {
- if (xp_attach_gl_context(gc->ctx, aquaPriv->sid) != Success)
- {
- quartzProcs->DestroySurface(pWin->drawable.pScreen,
- pWin->drawable.id, &pWin->drawable,
- surface_notify, aquaPriv);
-
- if (surface_hash != NULL)
- x_hash_table_remove(surface_hash, (void *) aquaPriv->sid);
-
- aquaPriv->sid = 0;
- return;
- }
-
- gc->isAttached = TRUE;
- gc->sid = aquaPriv->sid;
-
- if (surface_hash == NULL)
- surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
-
- lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
- if (x_list_find(lst, gc) == NULL)
- {
- lst = x_list_prepend(lst, gc);
- x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
- }
-
- GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", pWin->drawable.id,
+ {
+ return;
+ }
+ aquaPriv->pDraw = &pWin->drawable;
+ }
+
+ if (!gc->isAttached || gc->sid != aquaPriv->sid)
+ {
+ if (xp_attach_gl_context(gc->ctx, aquaPriv->sid) != Success)
+ {
+ quartzProcs->DestroySurface(pWin->drawable.pScreen,
+ pWin->drawable.id, &pWin->drawable,
+ surface_notify, aquaPriv);
+
+ if (surface_hash != NULL)
+ x_hash_table_remove(surface_hash, (void *) aquaPriv->sid);
+
+ aquaPriv->sid = 0;
+ return;
+ }
+
+ gc->isAttached = TRUE;
+ gc->sid = aquaPriv->sid;
+
+ if (surface_hash == NULL)
+ surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
+
+ lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
+ if (x_list_find(lst, gc) == NULL)
+ {
+ lst = x_list_prepend(lst, gc);
+ x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
+ }
+
+ GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", pWin->drawable.id,
aquaPriv->sid);
- }
+ }
} else {
GLAQUA_DEBUG_MSG("attach: attach to non-window unimplemented\n");
CGLClearDrawable(gc->ctx);
@@ -371,7 +378,7 @@ static GLboolean glAquaMakeCurrent(__GLcontext *gc)
gl_err = CGLSetCurrentContext(gc->ctx);
if (gl_err != 0)
- ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
+ ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
return gl_err == 0;
}
@@ -392,7 +399,7 @@ static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
gl_err = CGLCopyContext(src->ctx, dst->ctx, mask);
if (gl_err != 0)
- ErrorF("CGLCopyContext error: %s\n", CGLErrorString(gl_err));
+ ErrorF("CGLCopyContext error: %s\n", CGLErrorString(gl_err));
return gl_err == 0;
}
@@ -405,7 +412,7 @@ static GLboolean glAquaForceCurrent(__GLcontext *gc)
gl_err = CGLSetCurrentContext(gc->ctx);
if (gl_err != 0)
- ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
+ ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
return gl_err == 0;
}
@@ -456,7 +463,7 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode)
GLAQUA_DEBUG_MSG("makeFormat\n");
if (!mode->rgbMode)
- return NULL;
+ return NULL;
i = 0;
@@ -471,14 +478,14 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode)
}
if (mode->colorIndexMode) {
- /* ignored */
+ /* ignored */
}
if (mode->rgbMode) {
attr[i++] = kCGLPFAColorSize;
attr[i++] = mode->redBits + mode->greenBits + mode->blueBits;
attr[i++] = kCGLPFAAlphaSize;
- attr[i++] = 1; /* FIXME: ignoring mode->alphaBits which is always 0 */
+ attr[i++] = 1; /* FIXME: ignoring mode->alphaBits which is always 0 */
}
if (mode->haveAccumBuffer) {
@@ -509,7 +516,7 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode)
result = NULL;
gl_err = CGLChoosePixelFormat(attr, &result, &n_formats);
if (gl_err != 0)
- ErrorF("CGLChoosePixelFormat error: %s\n", CGLErrorString(gl_err));
+ ErrorF("CGLChoosePixelFormat error: %s\n", CGLErrorString(gl_err));
GLAQUA_DEBUG_MSG("makeFormat done (0x%x)\n", result);
@@ -517,8 +524,8 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode)
}
static __GLinterface *glAquaCreateContext(__GLimports *imports,
- __GLcontextModes *mode,
- __GLinterface *shareGC)
+ __GLcontextModes *mode,
+ __GLinterface *shareGC)
{
__GLcontext *result;
__GLcontext *sharectx = (__GLcontext *)shareGC;
@@ -540,11 +547,11 @@ static __GLinterface *glAquaCreateContext(__GLimports *imports,
result->ctx = NULL;
gl_err = CGLCreateContext(result->pixelFormat,
- sharectx ? sharectx->ctx : NULL,
- &result->ctx);
+ sharectx ? sharectx->ctx : NULL,
+ &result->ctx);
if (gl_err != 0) {
- ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err));
+ ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err));
CGLDestroyPixelFormat(result->pixelFormat);
free(result);
return NULL;
@@ -638,19 +645,22 @@ glAquaUnrealizeWindow(WindowPtr pWin)
return result;
}
-/*
- * In the case the driver has no GLX visuals we'll use these.
- * [0] = RGB, double buffered
- * [1] = RGB, double buffered, stencil, accum
- */
+
// Originally copied from Mesa
static int numConfigs = 0;
static __GLXvisualConfig *visualConfigs = NULL;
static void **visualPrivates = NULL;
-#define NUM_FALLBACK_CONFIGS 2
+/*
+ * In the case the driver defines no GLX visuals we'll use these.
+ * Note that for TrueColor and DirectColor visuals, bufferSize is the
+ * sum of redSize, greenSize, blueSize and alphaSize, which may be larger
+ * than the nplanes/rootDepth of the server's X11 visuals
+ */
+#define NUM_FALLBACK_CONFIGS 5
static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
+ /* [0] = RGB, double buffered, Z */
{
-1, /* vid */
-1, /* class */
@@ -665,11 +675,12 @@ static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
0, /* stencilSize */
0, /* auxBuffers */
0, /* level */
- GLX_NONE_EXT, /* visualRating */
- 0, /* transparentPixel */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
0 /* transparentIndex */
},
+ /* [1] = RGB, double buffered, Z, stencil, accum */
{
-1, /* vid */
-1, /* class */
@@ -684,11 +695,71 @@ static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
8, /* stencilSize */
0, /* auxBuffers */
0, /* level */
- GLX_NONE_EXT, /* visualRating */
- 0, /* transparentPixel */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
0 /* transparentIndex */
- }
+ },
+ /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ False, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [4] = CI, double buffered, Z */
+ {
+ -1, /* vid */
+ -1, /* class */
+ False, /* rgba? (false = color index) */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
};
static __GLXvisualConfig NullConfig = {
@@ -721,11 +792,11 @@ static inline int count_bits(uint32_t x)
return x & 63;
}
-// Mostly copied from Mesa's xf86glx.c
+
static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
- VisualID *defaultVisp,
- int ndepth, DepthPtr pdepth,
- int rootDepth)
+ VisualID *defaultVisp,
+ int ndepth, DepthPtr pdepth,
+ int rootDepth)
{
int numRGBconfigs;
int numCIconfigs;
@@ -735,7 +806,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
VisualPtr pVisual = *visualp;
VisualPtr pVisualNew = NULL;
VisualID *orig_vid = NULL;
- __GLXvisualConfig *glXVisualPtr = NULL;
+ __GLcontextModes *modes;
__GLXvisualConfig *pNewVisualConfigs = NULL;
void **glXVisualPriv;
void **pNewVisualPriv;
@@ -753,14 +824,14 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
pNewVisualConfigs = (__GLXvisualConfig *)
__glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
if (!pNewVisualConfigs) {
- return FALSE;
+ return FALSE;
}
/* Alloc space for the list of new GLX visual privates */
pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
if (!pNewVisualPriv) {
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
}
/*
@@ -768,9 +839,9 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
** visual configs.
*/
if (numConfigs == 0) {
- memcpy(pNewVisualConfigs, FallbackConfigs,
+ memcpy(pNewVisualConfigs, FallbackConfigs,
NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
- memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
+ memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
}
else {
/* copy driver's visual config info */
@@ -784,22 +855,22 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
numRGBconfigs = 0;
numCIconfigs = 0;
for (i = 0; i < numNewConfigs; i++) {
- if (pNewVisualConfigs[i].rgba)
- numRGBconfigs++;
- else
- numCIconfigs++;
+ if (pNewVisualConfigs[i].rgba)
+ numRGBconfigs++;
+ else
+ numCIconfigs++;
}
/* Count the total number of visuals to compute */
numNewVisuals = 0;
for (i = 0; i < numVisuals; i++) {
- int count;
+ int count;
- count = ((pVisual[i].class == TrueColor
- || pVisual[i].class == DirectColor)
- ? numRGBconfigs : numCIconfigs);
- if (count == 0)
- count = 1; /* preserve the existing visual */
+ count = ((pVisual[i].class == TrueColor
+ || pVisual[i].class == DirectColor)
+ ? numRGBconfigs : numCIconfigs);
+ if (count == 0)
+ count = 1; /* preserve the existing visual */
numNewVisuals += count;
}
@@ -811,154 +882,159 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
/* Alloc temp space for the list of orig VisualIDs for each new visual */
orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID));
if (!orig_vid) {
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
}
/* Alloc space for the list of glXVisuals */
- glXVisualPtr = (__GLXvisualConfig *)__glXMalloc(numNewVisuals *
- sizeof(__GLXvisualConfig));
- if (!glXVisualPtr) {
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
+ if (modes == NULL) {
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
}
/* Alloc space for the list of glXVisualPrivates */
glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
if (!glXVisualPriv) {
- __glXFree(glXVisualPtr);
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
}
/* Alloc space for the new list of the X server's visuals */
pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
if (!pVisualNew) {
- __glXFree(glXVisualPriv);
- __glXFree(glXVisualPtr);
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ __glXFree(glXVisualPriv);
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
}
/* Initialize the new visuals */
found_default = FALSE;
+ glAquaScreens[screenInfo.numScreens-1].modes = modes;
for (i = j = 0; i < numVisuals; i++) {
int is_rgb = (pVisual[i].class == TrueColor ||
- pVisual[i].class == DirectColor);
-
- if (!is_rgb)
- {
- /* We don't support non-rgb visuals for GL. But we don't
- want to remove them either, so just pass them through
- with null glX configs */
-
- pVisualNew[j] = pVisual[i];
- pVisualNew[j].vid = FakeClientID(0);
-
- /* Check for the default visual */
- if (!found_default && pVisual[i].vid == *defaultVisp) {
- *defaultVisp = pVisualNew[j].vid;
- found_default = TRUE;
- }
-
- /* Save the old VisualID */
- orig_vid[j] = pVisual[i].vid;
-
- /* Initialize the glXVisual */
- glXVisualPtr[j] = NullConfig;
- glXVisualPriv[j] = NULL;
-
- j++;
-
- continue;
- }
-
- for (k = 0; k < numNewConfigs; k++) {
- if (pNewVisualConfigs[k].rgba != is_rgb)
- continue;
-
- /* Initialize the new visual */
- pVisualNew[j] = pVisual[i];
- pVisualNew[j].vid = FakeClientID(0);
-
- /* Check for the default visual */
- if (!found_default && pVisual[i].vid == *defaultVisp) {
- *defaultVisp = pVisualNew[j].vid;
- found_default = TRUE;
- }
-
- /* Save the old VisualID */
- orig_vid[j] = pVisual[i].vid;
-
- /* Initialize the glXVisual */
- glXVisualPtr[j] = pNewVisualConfigs[k];
- glXVisualPtr[j].vid = pVisualNew[j].vid;
-
- /*
- * If the class is -1, then assume the X visual information
- * is identical to what GLX needs, and take them from the X
- * visual. NOTE: if class != -1, then all other fields MUST
- * be initialized.
- */
- if (glXVisualPtr[j].class == -1) {
- glXVisualPtr[j].class = pVisual[i].class;
- glXVisualPtr[j].redSize = count_bits(pVisual[i].redMask);
- glXVisualPtr[j].greenSize = count_bits(pVisual[i].greenMask);
- glXVisualPtr[j].blueSize = count_bits(pVisual[i].blueMask);
- glXVisualPtr[j].alphaSize = glXVisualPtr[j].alphaSize;
- glXVisualPtr[j].redMask = pVisual[i].redMask;
- glXVisualPtr[j].greenMask = pVisual[i].greenMask;
- glXVisualPtr[j].blueMask = pVisual[i].blueMask;
- glXVisualPtr[j].alphaMask = glXVisualPtr[j].alphaMask;
- glXVisualPtr[j].bufferSize = rootDepth;
- }
-
- /* Save the device-dependent private for this visual */
- glXVisualPriv[j] = pNewVisualPriv[k];
-
- j++;
- }
+ pVisual[i].class == DirectColor);
+
+ if (!is_rgb)
+ {
+ /* We don't support non-rgb visuals for GL. But we don't
+ want to remove them either, so just pass them through
+ with null glX configs */
+
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & NullConfig );
+ modes->visualID = pVisualNew[j].vid;
+
+ j++;
+
+ continue;
+ }
+
+ for (k = 0; k < numNewConfigs; k++) {
+ if (pNewVisualConfigs[k].rgba != is_rgb)
+ continue;
+
+ assert( modes != NULL );
+
+ /* Initialize the new visual */
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
+ modes->visualID = pVisualNew[j].vid;
+
+ /*
+ * If the class is -1, then assume the X visual information
+ * is identical to what GLX needs, and take them from the X
+ * visual. NOTE: if class != -1, then all other fields MUST
+ * be initialized.
+ */
+ if (modes->visualType == GLX_NONE) {
+ modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
+ modes->redBits = count_bits(pVisual[i].redMask);
+ modes->greenBits = count_bits(pVisual[i].greenMask);
+ modes->blueBits = count_bits(pVisual[i].blueMask);
+ modes->alphaBits = modes->alphaBits;
+ modes->redMask = pVisual[i].redMask;
+ modes->greenMask = pVisual[i].greenMask;
+ modes->blueMask = pVisual[i].blueMask;
+ modes->alphaMask = modes->alphaMask;
+ modes->rgbBits = (is_rgb)
+ ? (modes->redBits + modes->greenBits +
+ modes->blueBits + modes->alphaBits)
+ : rootDepth;
+ }
+
+ /* Save the device-dependent private for this visual */
+ glXVisualPriv[j] = pNewVisualPriv[k];
+
+ j++;
+ modes = modes->next;
+ }
}
assert(j <= numNewVisuals);
/* Save the GLX visuals in the screen structure */
glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
- glAquaScreens[screenInfo.numScreens-1].glx_vis = glXVisualPtr;
glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv;
/* Set up depth's VisualIDs */
for (i = 0; i < ndepth; i++) {
- int numVids = 0;
- VisualID *pVids = NULL;
- int k, n = 0;
-
- /* Count the new number of VisualIDs at this depth */
- for (j = 0; j < pdepth[i].numVids; j++)
- for (k = 0; k < numNewVisuals; k++)
- if (pdepth[i].vids[j] == orig_vid[k])
- numVids++;
-
- /* Allocate a new list of VisualIDs for this depth */
- pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
-
- /* Initialize the new list of VisualIDs for this depth */
- for (j = 0; j < pdepth[i].numVids; j++)
- for (k = 0; k < numNewVisuals; k++)
- if (pdepth[i].vids[j] == orig_vid[k])
- pVids[n++] = pVisualNew[k].vid;
-
- /* Update this depth's list of VisualIDs */
- __glXFree(pdepth[i].vids);
- pdepth[i].vids = pVids;
- pdepth[i].numVids = numVids;
+ int numVids = 0;
+ VisualID *pVids = NULL;
+ int k, n = 0;
+
+ /* Count the new number of VisualIDs at this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ numVids++;
+
+ /* Allocate a new list of VisualIDs for this depth */
+ pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
+
+ /* Initialize the new list of VisualIDs for this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ pVids[n++] = pVisualNew[k].vid;
+
+ /* Update this depth's list of VisualIDs */
+ __glXFree(pdepth[i].vids);
+ pdepth[i].vids = pVids;
+ pdepth[i].numVids = numVids;
}
/* Update the X server's visuals */
@@ -995,14 +1071,14 @@ glAquaInitVisualConfigs(void)
int i = 0;
GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs ");
-
+
/* count num configs:
- 2 Z buffer (0, 24 bit)
- 2 AUX buffer (0, 2)
- 2 buffers (single, double)
- 2 stencil (0, 8 bit)
- 2 accum (0, 64 bit)
- = 32 configs */
+ 2 Z buffer (0, 24 bit)
+ 2 AUX buffer (0, 2)
+ 2 buffers (single, double)
+ 2 stencil (0, 8 bit)
+ 2 accum (0, 64 bit)
+ = 32 configs */
lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
@@ -1012,66 +1088,65 @@ glAquaInitVisualConfigs(void)
/* fill in configs */
if (NULL != lclVisualConfigs) {
- i = 0; /* current buffer */
- for (depth = 0; depth < 2; depth++) {
- for (aux = 0; aux < 2; aux++) {
- for (buffers = 0; buffers < 2; buffers++) {
- for (stencil = 0; stencil < 2; stencil++) {
- for (accum = 0; accum < 2; accum++) {
- lclVisualConfigs[i].vid = -1;
- lclVisualConfigs[i].class = -1;
- lclVisualConfigs[i].rgba = TRUE;
- lclVisualConfigs[i].redSize = -1;
- lclVisualConfigs[i].greenSize = -1;
- lclVisualConfigs[i].blueSize = -1;
- lclVisualConfigs[i].redMask = -1;
- lclVisualConfigs[i].greenMask = -1;
- lclVisualConfigs[i].blueMask = -1;
- lclVisualConfigs[i].alphaMask = 0;
- if (accum) {
- lclVisualConfigs[i].accumRedSize = 16;
- lclVisualConfigs[i].accumGreenSize = 16;
- lclVisualConfigs[i].accumBlueSize = 16;
- lclVisualConfigs[i].accumAlphaSize = 16;
- }
- else {
- lclVisualConfigs[i].accumRedSize = 0;
- lclVisualConfigs[i].accumGreenSize = 0;
- lclVisualConfigs[i].accumBlueSize = 0;
- lclVisualConfigs[i].accumAlphaSize = 0;
- }
- lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
- lclVisualConfigs[i].stereo = FALSE;
- lclVisualConfigs[i].bufferSize = -1;
-
- lclVisualConfigs[i].depthSize = depth? 24 : 0;
- lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
- lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
- lclVisualConfigs[i].level = 0;
- lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
- lclVisualConfigs[i].transparentPixel = 0;
- lclVisualConfigs[i].transparentRed = 0;
- lclVisualConfigs[i].transparentGreen = 0;
- lclVisualConfigs[i].transparentBlue = 0;
- lclVisualConfigs[i].transparentAlpha = 0;
- lclVisualConfigs[i].transparentIndex = 0;
- i++;
- }
- }
- }
- }
- }
+ i = 0; /* current buffer */
+ for (depth = 0; depth < 2; depth++) {
+ for (aux = 0; aux < 2; aux++) {
+ for (buffers = 0; buffers < 2; buffers++) {
+ for (stencil = 0; stencil < 2; stencil++) {
+ for (accum = 0; accum < 2; accum++) {
+ lclVisualConfigs[i].vid = -1;
+ lclVisualConfigs[i].class = -1;
+ lclVisualConfigs[i].rgba = TRUE;
+ lclVisualConfigs[i].redSize = -1;
+ lclVisualConfigs[i].greenSize = -1;
+ lclVisualConfigs[i].blueSize = -1;
+ lclVisualConfigs[i].redMask = -1;
+ lclVisualConfigs[i].greenMask = -1;
+ lclVisualConfigs[i].blueMask = -1;
+ lclVisualConfigs[i].alphaMask = 0;
+ if (accum) {
+ lclVisualConfigs[i].accumRedSize = 16;
+ lclVisualConfigs[i].accumGreenSize = 16;
+ lclVisualConfigs[i].accumBlueSize = 16;
+ lclVisualConfigs[i].accumAlphaSize = 16;
+ }
+ else {
+ lclVisualConfigs[i].accumRedSize = 0;
+ lclVisualConfigs[i].accumGreenSize = 0;
+ lclVisualConfigs[i].accumBlueSize = 0;
+ lclVisualConfigs[i].accumAlphaSize = 0;
+ }
+ lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
+ lclVisualConfigs[i].stereo = FALSE;
+ lclVisualConfigs[i].bufferSize = -1;
+
+ lclVisualConfigs[i].depthSize = depth? 24 : 0;
+ lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
+ lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
+ lclVisualConfigs[i].level = 0;
+ lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
+ lclVisualConfigs[i].transparentPixel = 0;
+ lclVisualConfigs[i].transparentRed = 0;
+ lclVisualConfigs[i].transparentGreen = 0;
+ lclVisualConfigs[i].transparentBlue = 0;
+ lclVisualConfigs[i].transparentAlpha = 0;
+ lclVisualConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ }
+ }
+ }
}
if (i != lclNumConfigs)
- GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs");
+ GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs");
GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates);
}
-// Copied from Mesa
static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates)
+ void **privates)
{
GLAQUA_DEBUG_MSG("glAquaSetVisualConfigs\n");
@@ -1080,122 +1155,114 @@ static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
visualPrivates = privates;
}
-// Copied from Mesa
static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB)
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB)
{
GLAQUA_DEBUG_MSG("glAquaInitVisuals\n");
if (0 == numConfigs) /* if no configs */
- glAquaInitVisualConfigs(); /* ensure the visula configs are setup */
+ glAquaInitVisualConfigs(); /* ensure the visula configs are setup */
/*
* Setup the visuals supported by this particular screen.
*/
return init_visuals(nvisualp, visualp, defaultVisp,
- *ndepthp, *depthp, *rootDepthp);
+ *ndepthp, *depthp, *rootDepthp);
}
+
static void fixup_visuals(int screen)
{
ScreenPtr pScreen = screenInfo.screens[screen];
glAquaScreenRec *pScr = &glAquaScreens[screen];
- __GLXvisualConfig *pGLXVis = pScr->glx_vis;
- VisualPtr pVis;
- int i, j;
+ int j;
+ __GLcontextModes *modes;
GLAQUA_DEBUG_MSG("fixup_visuals\n");
- for (i = 0; i < pScr->num_vis; i++, pGLXVis++) {
- pVis = pScreen->visuals;
-
- /* Find a visual that matches the GLX visual's class and size */
- for (j = 0; j < pScreen->numVisuals; j++, pVis++) {
- if (pVis->class == pGLXVis->class &&
- pVis->nplanes == pGLXVis->bufferSize) {
-
- /* Fixup the masks */
- pGLXVis->redMask = pVis->redMask;
- pGLXVis->greenMask = pVis->greenMask;
- pGLXVis->blueMask = pVis->blueMask;
-
- /* Recalc the sizes */
- pGLXVis->redSize = count_bits(pGLXVis->redMask);
- pGLXVis->greenSize = count_bits(pGLXVis->greenMask);
- pGLXVis->blueSize = count_bits(pGLXVis->blueMask);
- }
- }
+ for ( modes = pScr->modes ; modes != NULL ; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ /* Find a visual that matches the GLX visual's class and size */
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes) {
+
+ /* Fixup the masks */
+ modes->redMask = pVis[j].redMask;
+ modes->greenMask = pVis[j].greenMask;
+ modes->blueMask = pVis[j].blueMask;
+
+ /* Recalc the sizes */
+ modes->redBits = count_bits(modes->redMask);
+ modes->greenBits = count_bits(modes->greenMask);
+ modes->blueBits = count_bits(modes->blueMask);
+ }
+ }
}
}
static void init_screen_visuals(int screen)
{
ScreenPtr pScreen = screenInfo.screens[screen];
- __GLXvisualConfig *pGLXVis = glAquaScreens[screen].glx_vis;
- // XMesaVisual *pXMesaVisual;
- VisualPtr pVis;
+ __GLcontextModes *modes;
int *used;
int i, j;
GLAQUA_DEBUG_MSG("init_screen_visuals\n");
- /* Alloc space for the list of XMesa visuals */
- // pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis *
- // sizeof(XMesaVisual));
- // __glXMemset(pXMesaVisual, 0,
- // MESAScreens[screen].num_vis * sizeof(XMesaVisual));
-
+ /* FIXME: Change 'used' to be a array of bits (rather than of ints),
+ * FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less
+ * FIXME: than 64 or 128 the stack array can be used instead of calling
+ * FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to
+ * FIXME: array of bytes instead of ints!
+ */
used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
__glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
- for (i = 0; i < glAquaScreens[screen].num_vis; i++, pGLXVis++) {
- pVis = pScreen->visuals;
- for (j = 0; j < pScreen->numVisuals; j++, pVis++) {
-
- if (pVis->class == pGLXVis->class &&
- pVis->nplanes == pGLXVis->bufferSize &&
- !used[j]) {
-
- if (pVis->redMask == pGLXVis->redMask &&
- pVis->greenMask == pGLXVis->greenMask &&
- pVis->blueMask == pGLXVis->blueMask) {
-
- /* Create the XMesa visual */
- /*
- pXMesaVisual[i] =
- XMesaCreateVisual(pScreen,
- pVis,
- pGLXVis->rgba,
- (pGLXVis->alphaSize > 0),
- pGLXVis->doubleBuffer,
- pGLXVis->stereo,
- GL_TRUE, // ximage_flag
- pGLXVis->depthSize,
- pGLXVis->stencilSize,
- pGLXVis->accumRedSize,
- pGLXVis->accumGreenSize,
- pGLXVis->accumBlueSize,
- pGLXVis->accumAlphaSize,
- 0, // numSamples
- pGLXVis->level,
- pGLXVis->visualRating );
- */
- /* Set the VisualID */
- pGLXVis->vid = pVis->vid;
-
- /* Mark this visual used */
- used[j] = 1;
- break;
- }
- }
- }
+ i = 0;
+ for ( modes = glAquaScreens[screen].modes
+ ; modes != NULL
+ ; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes &&
+ pVis[j].redMask == modes->redMask &&
+ pVis[j].greenMask == modes->greenMask &&
+ pVis[j].blueMask == modes->blueMask &&
+ !used[j]) {
+
+ /* Set the VisualID */
+ modes->visualID = pVis[j].vid;
+
+ /* Mark this visual used */
+ used[j] = 1;
+ break;
+ }
+ }
+ if ( j == pScreen->numVisuals ) {
+ ErrorF("No matching visual for __GLcontextMode with "
+ "visual class = %d (%d), nplanes = %u\n",
+ vis_class,
+ (int)modes->visualType,
+ (unsigned int)(modes->rgbBits - modes->alphaBits) );
+ }
+ else if ( modes->visualID == -1 ) {
+ FatalError( "Matching visual found, but visualID still -1!\n" );
+ }
+
+ i++;
}
__glXFree(used);
-
- // glAquaScreens[screen].xm_vis = pXMesaVisual;
}
static Bool glAquaScreenProbe(int screen)
@@ -1208,10 +1275,10 @@ static Bool glAquaScreenProbe(int screen)
/*
* Set up the current screen's visuals.
*/
- __glDDXScreenInfo.pGlxVisual = glAquaScreens[screen].glx_vis;
+ __glDDXScreenInfo.modes = glAquaScreens[screen].modes;
__glDDXScreenInfo.pVisualPriv = glAquaScreens[screen].priv;
__glDDXScreenInfo.numVisuals =
- __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis;
+ __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis;
/*
* Set the current screen's createContext routine. This could be
@@ -1231,7 +1298,9 @@ static Bool glAquaScreenProbe(int screen)
*/
init_screen_visuals(screen);
- // Wrap RealizeWindow and UnrealizeWindow on this screen
+ /*
+ * Wrap RealizeWindow and UnrealizeWindow on this screen
+ */
pScreen = screenInfo.screens[screen];
screenPriv = &glAquaScreens[screen];
screenPriv->RealizeWindow = pScreen->RealizeWindow;
@@ -1253,9 +1322,9 @@ static GLboolean glAquaSwapBuffers(__GLXdrawablePrivate *glxPriv)
if (gc != NULL && gc->ctx != NULL)
{
- gl_err = CGLFlushDrawable(gc->ctx);
- if (gl_err != 0)
- ErrorF("CGLFlushDrawable error: %s\n", CGLErrorString(gl_err));
+ gl_err = CGLFlushDrawable(gc->ctx);
+ if (gl_err != 0)
+ ErrorF("CGLFlushDrawable error: %s\n", CGLErrorString(gl_err));
}
return GL_TRUE;
@@ -1308,24 +1377,24 @@ GLint __glEvalComputeK(GLenum target)
case GL_MAP2_VERTEX_4:
case GL_MAP2_COLOR_4:
case GL_MAP2_TEXTURE_COORD_4:
- return 4;
+ return 4;
case GL_MAP1_VERTEX_3:
case GL_MAP1_TEXTURE_COORD_3:
case GL_MAP1_NORMAL:
case GL_MAP2_VERTEX_3:
case GL_MAP2_TEXTURE_COORD_3:
case GL_MAP2_NORMAL:
- return 3;
+ return 3;
case GL_MAP1_TEXTURE_COORD_2:
case GL_MAP2_TEXTURE_COORD_2:
- return 2;
+ return 2;
case GL_MAP1_TEXTURE_COORD_1:
case GL_MAP2_TEXTURE_COORD_1:
case GL_MAP1_INDEX:
case GL_MAP2_INDEX:
- return 1;
+ return 1;
default:
- return 0;
+ return 0;
}
}
@@ -1334,8 +1403,8 @@ GLuint __glFloorLog2(GLuint val)
int c = 0;
while (val > 1) {
- c++;
- val >>= 1;
+ c++;
+ val >>= 1;
}
return c;
}
diff --git a/GL/glx/g_disptab.c b/GL/glx/g_disptab.c
index 12d1abe56..8c8dc2ccc 100644
--- a/GL/glx/g_disptab.c
+++ b/GL/glx/g_disptab.c
@@ -54,18 +54,18 @@ __GLXdispatchSingleProcPtr __glXSingleTable[__GLX_SINGLE_TABLE_SIZE] = {
__glXQueryExtensionsString,
__glXQueryServerString,
__glXClientInfo,
- __glXNoSuchSingleOpcode, /* glXGetFBConfigs */
- __glXNoSuchSingleOpcode, /* glXCreatePixmap */
- __glXNoSuchSingleOpcode, /* glXDestroyPixmap */
- __glXNoSuchSingleOpcode, /* glXCreateNewContext */
+ __glXGetFBConfigs,
+ __glXCreatePixmap,
+ __glXDestroyGLXPixmap, /* glXDestroyPixmap */
+ __glXCreateNewContext,
__glXNoSuchSingleOpcode, /* glXQueryContext */
__glXMakeContextCurrent,
- __glXNoSuchSingleOpcode,
- __glXNoSuchSingleOpcode,
- __glXNoSuchSingleOpcode,
- __glXNoSuchSingleOpcode,
- __glXNoSuchSingleOpcode,
- __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode, /* glXCreatePbuffer */
+ __glXNoSuchSingleOpcode, /* glXDestroyPbuffer */
+ __glXNoSuchSingleOpcode, /* glXGetDrawableAttributes */
+ __glXNoSuchSingleOpcode, /* glXChangeDrawableAttributes */
+ __glXNoSuchSingleOpcode, /* glXCreateWindow */
+ __glXNoSuchSingleOpcode, /* glXDestroyWindow */
__glXNoSuchSingleOpcode,
__glXNoSuchSingleOpcode,
__glXNoSuchSingleOpcode,
@@ -455,18 +455,18 @@ __GLXdispatchSingleProcPtr __glXSwapSingleTable[__GLX_SINGLE_TABLE_SIZE] = {
__glXSwapQueryExtensionsString,
__glXSwapQueryServerString,
__glXSwapClientInfo,
- __glXNoSuchSingleOpcode, /* glXGetFBConfigs */
- __glXNoSuchSingleOpcode, /* glXCreatePixmap */
- __glXNoSuchSingleOpcode, /* glXDestroyPixmap */
- __glXNoSuchSingleOpcode, /* glXCreateNewContext */
+ __glXSwapGetFBConfigs,
+ __glXSwapCreatePixmap,
+ __glXSwapDestroyGLXPixmap, /* glXDestroyPixmap */
+ __glXSwapCreateNewContext,
__glXNoSuchSingleOpcode, /* glXQueryContext */
__glXSwapMakeContextCurrent,
- __glXNoSuchSingleOpcode,
- __glXNoSuchSingleOpcode,
- __glXNoSuchSingleOpcode,
- __glXNoSuchSingleOpcode,
- __glXNoSuchSingleOpcode,
- __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode, /* glXCreatePbuffer */
+ __glXNoSuchSingleOpcode, /* glXDestroyPbuffer */
+ __glXNoSuchSingleOpcode, /* glXGetDrawableAttributes */
+ __glXNoSuchSingleOpcode, /* glXChangeDrawableAttributes */
+ __glXNoSuchSingleOpcode, /* glXCreateWindow */
+ __glXNoSuchSingleOpcode, /* glXDestroyWindow */
__glXNoSuchSingleOpcode,
__glXNoSuchSingleOpcode,
__glXNoSuchSingleOpcode,
diff --git a/GL/glx/g_disptab.h b/GL/glx/g_disptab.h
index 25c233ac7..566650bf7 100644
--- a/GL/glx/g_disptab.h
+++ b/GL/glx/g_disptab.h
@@ -52,6 +52,9 @@ extern int __glXQueryExtensionsString(__GLXclientState*, GLbyte*);
extern int __glXQueryServerString(__GLXclientState*, GLbyte*);
extern int __glXClientInfo(__GLXclientState*, GLbyte*);
extern int __glXMakeContextCurrent(__GLXclientState*, GLbyte*);
+extern int __glXGetFBConfigs(__GLXclientState*, GLbyte*);
+extern int __glXCreateNewContext(__GLXclientState*, GLbyte*);
+extern int __glXCreatePixmap(__GLXclientState*, GLbyte*);
extern int __glXDisp_NewList(__GLXclientState*, GLbyte*);
extern int __glXDisp_EndList(__GLXclientState*, GLbyte*);
@@ -349,6 +352,9 @@ extern int __glXSwapQueryExtensionsString(__GLXclientState*, GLbyte*);
extern int __glXSwapQueryServerString(__GLXclientState*, GLbyte*);
extern int __glXSwapClientInfo(__GLXclientState*, GLbyte*);
extern int __glXSwapMakeContextCurrent(__GLXclientState*, GLbyte*);
+extern int __glXSwapGetFBConfigs(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreateNewContext(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreatePixmap(__GLXclientState*, GLbyte*);
extern int __glXDispSwap_NewList(__GLXclientState*, GLbyte*);
extern int __glXDispSwap_EndList(__GLXclientState*, GLbyte*);
diff --git a/GL/glx/g_render.c b/GL/glx/g_render.c
index a599423cc..f014e3be5 100644
--- a/GL/glx/g_render.c
+++ b/GL/glx/g_render.c
@@ -2273,7 +2273,6 @@ void __glXDisp_WindowPos3fARB(GLbyte *pc)
*(GLfloat *)(pc + 8)
);
}
-
#endif /* !MISSING_GL_EXTS */
void __glXDisp_SampleCoverageARB(GLbyte *pc)
diff --git a/GL/glx/g_renderswap.c b/GL/glx/g_renderswap.c
index 2a8d0c02f..5c2ed9f58 100644
--- a/GL/glx/g_renderswap.c
+++ b/GL/glx/g_renderswap.c
@@ -3368,7 +3368,6 @@ void __glXDispSwap_WindowPos3fARB(GLbyte *pc)
*(GLfloat *)(pc + 8)
);
}
-
#endif /* !MISSING_GL_EXTS */
void __glXDispSwap_SampleCoverageARB(GLbyte *pc)
diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c
index df4154991..9908e8a2d 100644
--- a/GL/glx/glxcmds.c
+++ b/GL/glx/glxcmds.c
@@ -47,6 +47,7 @@
#include "glxutil.h"
#include "glxext.h"
#include "GL/glx_ansic.h"
+#include "glcontextmodes.h"
/************************************************************************/
@@ -68,29 +69,32 @@ static __GLimports imports = {
NULL
};
-static int DoMakeCurrent( __GLXclientState *cl, GLXDrawable drawId,
- GLXDrawable readId, GLXContextID contextId, GLXContextTag tag );
+static int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc);
/************************************************************************/
-/*
-** Create a GL context with the given properties.
-*/
-int __glXCreateContext(__GLXclientState *cl, GLbyte *pc)
+/**
+ * Create a GL context with the given properties. This routine is used
+ * to implement \c glXCreateContext, \c glXCreateNewContext, and
+ * \c glXCreateContextWithConfigSGIX. This works becuase of the hack way
+ * that GLXFBConfigs are implemented. Basically, the FBConfigID is the
+ * same as the VisualID.
+ */
+
+int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
+ GLXContextID shareList, VisualID visual,
+ GLuint screen, GLboolean isDirect)
{
ClientPtr client = cl->client;
- xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
VisualPtr pVisual;
ScreenPtr pScreen;
__GLXcontext *glxc, *shareglxc;
- __GLXvisualConfig *pGlxVisual;
+ __GLcontextModes *modes;
__GLXscreenInfo *pGlxScreen;
__GLinterface *shareGC;
- GLXContextID gcId = req->context;
- GLXContextID shareList = req->shareList;
- VisualID visual = req->visual;
- GLuint screen = req->screen;
- GLboolean isDirect = req->isDirect;
GLint i;
/*
@@ -123,13 +127,9 @@ int __glXCreateContext(__GLXclientState *cl, GLbyte *pc)
** subset of Visuals that are supported by this implementation of the
** OpenGL.
*/
- pGlxVisual = pGlxScreen->pGlxVisual;
- for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
- if (pGlxVisual->vid == visual) {
- break;
- }
- }
- if (i == pGlxScreen->numVisuals) {
+
+ modes = _gl_context_modes_find_visual( pGlxScreen->modes, visual );
+ if (modes == NULL) {
/*
** Visual not support on this screen by this OpenGL implementation.
*/
@@ -192,22 +192,15 @@ int __glXCreateContext(__GLXclientState *cl, GLbyte *pc)
glxc->pScreen = pScreen;
glxc->pGlxScreen = pGlxScreen;
glxc->pVisual = pVisual;
- glxc->pGlxVisual = pGlxVisual;
+ glxc->modes = modes;
if (!isDirect) {
- __GLcontextModes *modes;
- /*
- ** first build __GLcontextModes from __GLXvisualConfig
- */
- modes = (__GLcontextModes *) __glXMalloc(sizeof(__GLcontextModes));
- glxc->modes = modes;
- __glXFormatGLModes(modes, pGlxVisual);
/*
** Allocate a GL context
*/
imports.other = (void *)glxc;
- glxc->gc = (*pGlxScreen->createContext)(&imports, modes, shareGC);
+ glxc->gc = (*pGlxScreen->createContext)(&imports, glxc->modes, shareGC);
if (!glxc->gc) {
__glXFree(glxc);
client->errorValue = gcId;
@@ -245,6 +238,31 @@ int __glXCreateContext(__GLXclientState *cl, GLbyte *pc)
return Success;
}
+
+int __glXCreateContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
+ return DoCreateContext( cl, req->context, req->shareList, req->visual,
+ req->screen, req->isDirect );
+}
+
+
+int __glXCreateNewContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
+ return DoCreateContext( cl, req->context, req->shareList, req->fbconfig,
+ req->screen, req->isDirect );
+}
+
+
+int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextWithConfigSGIXReq *req =
+ (xGLXCreateContextWithConfigSGIXReq *) pc;
+ return DoCreateContext( cl, req->context, req->shareList, req->fbconfig,
+ req->screen, req->isDirect );
+}
+
/*
** Destroy a GL context as an X resource.
*/
@@ -370,24 +388,24 @@ int __glXMakeCurrent(__GLXclientState *cl, GLbyte *pc)
{
xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
- return DoMakeCurrent( cl, req->drawable, req->drawable,
- req->context, req->oldContextTag );
+ return DoMakeCurrent( cl, req->drawable, req->drawable,
+ req->context, req->oldContextTag );
}
int __glXMakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
{
xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
- return DoMakeCurrent( cl, req->drawable, req->readdrawable,
- req->context, req->oldContextTag );
+ return DoMakeCurrent( cl, req->drawable, req->readdrawable,
+ req->context, req->oldContextTag );
}
int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
{
xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
- return DoMakeCurrent( cl, req->drawable, req->readable,
- req->context, req->oldContextTag );
+ return DoMakeCurrent( cl, req->drawable, req->readable,
+ req->context, req->oldContextTag );
}
@@ -449,7 +467,7 @@ static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId,
** Check if pixmap and context are similar.
*/
if (drawPixmap->pScreen != glxc->pScreen ||
- drawPixmap->pGlxVisual != glxc->pGlxVisual) {
+ drawPixmap->modes->visualID != glxc->modes->visualID) {
client->errorValue = drawId;
return BadMatch;
}
@@ -471,9 +489,9 @@ static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId,
}
-static int DoMakeCurrent( __GLXclientState *cl,
- GLXDrawable drawId, GLXDrawable readId,
- GLXContextID contextId, GLXContextTag tag )
+int DoMakeCurrent( __GLXclientState *cl,
+ GLXDrawable drawId, GLXDrawable readId,
+ GLXContextID contextId, GLXContextTag tag )
{
ClientPtr client = cl->client;
DrawablePtr pDraw;
@@ -639,7 +657,8 @@ static int DoMakeCurrent( __GLXclientState *cl,
if (prevglxc) {
if (prevglxc->drawPixmap) {
- if (prevglxc->drawPixmap != prevglxc->readPixmap) {
+ if (prevglxc->readPixmap &&
+ prevglxc->drawPixmap != prevglxc->readPixmap) {
/*
** The previous drawable was a glx pixmap, release it.
*/
@@ -881,18 +900,19 @@ int __glXCopyContext(__GLXclientState *cl, GLbyte *pc)
return Success;
}
-int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
+
+int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen,
+ GLboolean do_swap)
{
ClientPtr client = cl->client;
- xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
xGLXGetVisualConfigsReply reply;
__GLXscreenInfo *pGlxScreen;
- __GLXvisualConfig *pGlxVisual;
+ __GLcontextModes *modes;
CARD32 buf[__GLX_TOTAL_CONFIG];
- unsigned int screen;
- int i, p;
+ int p;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
- screen = req->screen;
if (screen >= screenInfo.numScreens) {
/* The client library must send a valid screen number. */
client->errorValue = screen;
@@ -907,77 +927,206 @@ int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
+ if ( do_swap ) {
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numVisuals);
+ __GLX_SWAP_INT(&reply.numProps);
+ }
+
WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *)&reply);
- for (i=0; i < pGlxScreen->numVisuals; i++) {
- pGlxVisual = &pGlxScreen->pGlxVisual[i];
- if (pGlxVisual->vid == 0) {
+ for ( modes = pGlxScreen->modes ; modes != NULL ; modes = modes->next ) {
+ if (modes->visualID == 0) {
/* not a usable visual */
continue;
}
p = 0;
- buf[p++] = pGlxVisual->vid;
- buf[p++] = pGlxVisual->class;
- buf[p++] = pGlxVisual->rgba;
-
- buf[p++] = pGlxVisual->redSize;
- buf[p++] = pGlxVisual->greenSize;
- buf[p++] = pGlxVisual->blueSize;
- buf[p++] = pGlxVisual->alphaSize;
- buf[p++] = pGlxVisual->accumRedSize;
- buf[p++] = pGlxVisual->accumGreenSize;
- buf[p++] = pGlxVisual->accumBlueSize;
- buf[p++] = pGlxVisual->accumAlphaSize;
-
- buf[p++] = pGlxVisual->doubleBuffer;
- buf[p++] = pGlxVisual->stereo;
-
- buf[p++] = pGlxVisual->bufferSize;
- buf[p++] = pGlxVisual->depthSize;
- buf[p++] = pGlxVisual->stencilSize;
- buf[p++] = pGlxVisual->auxBuffers;
- buf[p++] = pGlxVisual->level;
+ buf[p++] = modes->visualID;
+ buf[p++] = _gl_convert_to_x_visual_type( modes->visualType );
+ buf[p++] = modes->rgbMode;
+
+ buf[p++] = modes->redBits;
+ buf[p++] = modes->greenBits;
+ buf[p++] = modes->blueBits;
+ buf[p++] = modes->alphaBits;
+ buf[p++] = modes->accumRedBits;
+ buf[p++] = modes->accumGreenBits;
+ buf[p++] = modes->accumBlueBits;
+ buf[p++] = modes->accumAlphaBits;
+
+ buf[p++] = modes->doubleBufferMode;
+ buf[p++] = modes->stereoMode;
+
+ buf[p++] = modes->rgbBits;
+ buf[p++] = modes->depthBits;
+ buf[p++] = modes->stencilBits;
+ buf[p++] = modes->numAuxBuffers;
+ buf[p++] = modes->level;
/*
** Add token/value pairs for extensions.
*/
buf[p++] = GLX_VISUAL_CAVEAT_EXT;
- buf[p++] = pGlxVisual->visualRating;
- buf[p++] = GLX_TRANSPARENT_TYPE_EXT;
- buf[p++] = pGlxVisual->transparentPixel;
- buf[p++] = GLX_TRANSPARENT_RED_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentRed;
- buf[p++] = GLX_TRANSPARENT_GREEN_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentGreen;
- buf[p++] = GLX_TRANSPARENT_BLUE_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentBlue;
- buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentAlpha;
- buf[p++] = GLX_TRANSPARENT_INDEX_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentIndex;
-
+ buf[p++] = modes->visualRating;
+ buf[p++] = GLX_TRANSPARENT_TYPE;
+ buf[p++] = modes->transparentPixel;
+ buf[p++] = GLX_TRANSPARENT_RED_VALUE;
+ buf[p++] = modes->transparentRed;
+ buf[p++] = GLX_TRANSPARENT_GREEN_VALUE;
+ buf[p++] = modes->transparentGreen;
+ buf[p++] = GLX_TRANSPARENT_BLUE_VALUE;
+ buf[p++] = modes->transparentBlue;
+ buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE;
+ buf[p++] = modes->transparentAlpha;
+ buf[p++] = GLX_TRANSPARENT_INDEX_VALUE;
+ buf[p++] = modes->transparentIndex;
+
+ if ( do_swap ) {
+ __GLX_SWAP_INT_ARRAY(buf, __GLX_TOTAL_CONFIG);
+ }
WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG,
(char *)buf);
}
return Success;
}
+int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
+ return DoGetVisualConfigs( cl, req->screen, GL_FALSE );
+}
+
+
+
+#define __GLX_TOTAL_FBCONFIG_ATTRIBS (28)
+
+/**
+ * Send the set of GLXFBConfigs to the client. There is not currently
+ * and interface into the driver on the server-side to get GLXFBConfigs,
+ * so we "invent" some based on the \c __GLXvisualConfig structures that
+ * the driver does supply.
+ *
+ * The reply format for both \c glXGetFBConfigs and \c glXGetFBConfigsSGIX
+ * is the same, so this routine pulls double duty.
+ */
+
+int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, GLboolean do_swap)
+{
+ ClientPtr client = cl->client;
+ xGLXGetFBConfigsReply reply;
+ __GLXscreenInfo *pGlxScreen;
+ CARD32 buf[__GLX_TOTAL_FBCONFIG_ATTRIBS * 2];
+ int p;
+ __GLcontextModes *modes;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+
+ if (screen >= screenInfo.numScreens) {
+ /* The client library must send a valid screen number. */
+ client->errorValue = screen;
+ return BadValue;
+ }
+ pGlxScreen = &__glXActiveScreens[screen];
+
+ reply.numFBConfigs = pGlxScreen->numUsableVisuals;
+ reply.numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS;
+ reply.length = (reply.numAttribs * reply.numFBConfigs);
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if ( do_swap ) {
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numFBConfigs);
+ __GLX_SWAP_INT(&reply.numAttribs);
+ }
+
+ WriteToClient(client, sz_xGLXGetFBConfigsReply, (char *)&reply);
+
+ for ( modes = pGlxScreen->modes ; modes != NULL ; modes = modes->next ) {
+ if (modes->visualID == 0) {
+ /* not a usable visual */
+ continue;
+ }
+ p = 0;
+
+#define WRITE_PAIR(tag,value) \
+ do { buf[p++] = tag ; buf[p++] = value ; } while( 0 )
+
+ WRITE_PAIR( GLX_VISUAL_ID, modes->visualID );
+ WRITE_PAIR( GLX_FBCONFIG_ID, modes->visualID );
+ WRITE_PAIR( GLX_X_RENDERABLE, GL_TRUE );
+
+ WRITE_PAIR( GLX_RGBA, modes->rgbMode );
+ WRITE_PAIR( GLX_DOUBLEBUFFER, modes->doubleBufferMode );
+ WRITE_PAIR( GLX_STEREO, modes->stereoMode );
+
+ WRITE_PAIR( GLX_BUFFER_SIZE, modes->rgbBits );
+ WRITE_PAIR( GLX_LEVEL, modes->level );
+ WRITE_PAIR( GLX_AUX_BUFFERS, modes->numAuxBuffers );
+ WRITE_PAIR( GLX_RED_SIZE, modes->redBits );
+ WRITE_PAIR( GLX_GREEN_SIZE, modes->greenBits );
+ WRITE_PAIR( GLX_BLUE_SIZE, modes->blueBits );
+ WRITE_PAIR( GLX_ALPHA_SIZE, modes->alphaBits );
+ WRITE_PAIR( GLX_ACCUM_RED_SIZE, modes->accumRedBits );
+ WRITE_PAIR( GLX_ACCUM_GREEN_SIZE, modes->accumGreenBits );
+ WRITE_PAIR( GLX_ACCUM_BLUE_SIZE, modes->accumBlueBits );
+ WRITE_PAIR( GLX_ACCUM_ALPHA_SIZE, modes->accumAlphaBits );
+ WRITE_PAIR( GLX_DEPTH_SIZE, modes->depthBits );
+ WRITE_PAIR( GLX_STENCIL_SIZE, modes->stencilBits );
+
+ WRITE_PAIR( GLX_X_VISUAL_TYPE, modes->visualType );
+
+ /*
+ ** Add token/value pairs for extensions.
+ */
+ WRITE_PAIR( GLX_CONFIG_CAVEAT, modes->visualRating );
+ WRITE_PAIR( GLX_TRANSPARENT_TYPE, modes->transparentPixel );
+ WRITE_PAIR( GLX_TRANSPARENT_RED_VALUE, modes->transparentRed );
+ WRITE_PAIR( GLX_TRANSPARENT_GREEN_VALUE, modes->transparentGreen );
+ WRITE_PAIR( GLX_TRANSPARENT_BLUE_VALUE, modes->transparentBlue );
+ WRITE_PAIR( GLX_TRANSPARENT_ALPHA_VALUE, modes->transparentAlpha );
+ WRITE_PAIR( GLX_TRANSPARENT_INDEX_VALUE, modes->transparentIndex );
+ WRITE_PAIR( GLX_SWAP_METHOD_OML, modes->swapMethod );
+
+ if ( do_swap ) {
+ __GLX_SWAP_INT_ARRAY(buf, __GLX_TOTAL_FBCONFIG_ATTRIBS * 2);
+ }
+ WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_FBCONFIG_ATTRIBS * 2,
+ (char *)buf);
+ }
+ return Success;
+}
+
+
+int __glXGetFBConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
+ return DoGetFBConfigs( cl, req->screen, GL_FALSE );
+}
+
+
+int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc;
+ return DoGetFBConfigs( cl, req->screen, GL_FALSE );
+}
+
+
/*
** Create a GLX Pixmap from an X Pixmap.
*/
-int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual,
+ GLuint screenNum, XID pixmapId, XID glxpixmapId)
{
ClientPtr client = cl->client;
- xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
- VisualID visual = req->visual;
- GLuint screenNum = req->screen;
- XID pixmapId = req->pixmap;
- XID glxpixmapId = req->glxpixmap;
DrawablePtr pDraw;
ScreenPtr pScreen;
VisualPtr pVisual;
__GLXpixmap *pGlxPixmap;
__GLXscreenInfo *pGlxScreen;
- __GLXvisualConfig *pGlxVisual;
+ __GLcontextModes *modes;
int i;
pDraw = (DrawablePtr) LookupDrawable(pixmapId, client);
@@ -1018,13 +1167,8 @@ int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
** Get configuration of the visual.
*/
pGlxScreen = &__glXActiveScreens[screenNum];
- pGlxVisual = pGlxScreen->pGlxVisual;
- for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
- if (pGlxVisual->vid == visual) {
- break;
- }
- }
- if (i == pGlxScreen->numVisuals) {
+ modes = _gl_context_modes_find_visual( pGlxScreen->modes, visual );
+ if (modes == NULL) {
/*
** Visual not support on this screen by this OpenGL implementation.
*/
@@ -1041,11 +1185,12 @@ int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
}
pGlxPixmap->pDraw = pDraw;
pGlxPixmap->pGlxScreen = pGlxScreen;
- pGlxPixmap->pGlxVisual = pGlxVisual;
pGlxPixmap->pScreen = pScreen;
pGlxPixmap->idExists = True;
pGlxPixmap->refcnt = 0;
+ pGlxPixmap->modes = modes;
+
/*
** Bump the ref count on the X pixmap so it won't disappear.
*/
@@ -1054,6 +1199,34 @@ int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
return Success;
}
+int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
+ return DoCreateGLXPixmap( cl, req->visual, req->screen,
+ req->pixmap, req->glxpixmap );
+}
+
+int __glXCreatePixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
+ return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
+ req->pixmap, req->glxpixmap );
+}
+
+int __glXCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateGLXPixmapWithConfigSGIXReq *req =
+ (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
+ return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
+ req->pixmap, req->glxpixmap );
+}
+
+
+/**
+ * Destroy a GLX pixmap. This function is used for both
+ * \c glXDestroyGLXPixmap and \c glXDestroyPixmap.
+ */
+
int __glXDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
{
ClientPtr client = cl->client;
@@ -1592,6 +1765,12 @@ int __glXVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
return __glXQueryContextInfoEXT(cl, pc);
case X_GLXvop_MakeCurrentReadSGI:
return __glXMakeCurrentReadSGI(cl, pc);
+ case X_GLXvop_GetFBConfigsSGIX:
+ return __glXGetFBConfigsSGIX(cl, pc);
+ case X_GLXvop_CreateContextWithConfigSGIX:
+ return __glXCreateContextWithConfigSGIX(cl, pc);
+ case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
+ return __glXCreateGLXPixmapWithConfigSGIX(cl, pc);
default:
break;
}
diff --git a/GL/glx/glxcmdsswap.c b/GL/glx/glxcmdsswap.c
index 8c0f1f091..450b8bb9b 100644
--- a/GL/glx/glxcmdsswap.c
+++ b/GL/glx/glxcmdsswap.c
@@ -47,6 +47,11 @@
#include "glxext.h"
#include "GL/glx_ansic.h"
+static int __glXSwapGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXSwapCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXSwapCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc);
+
/************************************************************************/
/*
@@ -67,7 +72,41 @@ int __glXSwapCreateContext(__GLXclientState *cl, GLbyte *pc)
__GLX_SWAP_INT(&req->screen);
__GLX_SWAP_INT(&req->shareList);
- return __glXCreateContext(cl, pc);
+ return DoCreateContext( cl, req->context, req->shareList, req->visual,
+ req->screen, req->isDirect );
+}
+
+int __glXSwapCreateNewContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->renderType);
+ __GLX_SWAP_INT(&req->shareList);
+
+ return DoCreateContext( cl, req->context, req->shareList, req->fbconfig,
+ req->screen, req->isDirect );
+}
+
+int __glXSwapCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextWithConfigSGIXReq *req =
+ (xGLXCreateContextWithConfigSGIXReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->renderType);
+ __GLX_SWAP_INT(&req->shareList);
+
+ return DoCreateContext( cl, req->context, req->shareList, req->fbconfig,
+ req->screen, req->isDirect );
}
int __glXSwapDestroyContext(__GLXclientState *cl, GLbyte *pc)
@@ -91,7 +130,8 @@ int __glXSwapMakeCurrent(__GLXclientState *cl, GLbyte *pc)
__GLX_SWAP_INT(&req->context);
__GLX_SWAP_INT(&req->oldContextTag);
- return __glXMakeCurrent(cl, pc);
+ return DoMakeCurrent( cl, req->drawable, req->drawable,
+ req->context, req->oldContextTag );
}
int __glXSwapMakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
@@ -105,7 +145,8 @@ int __glXSwapMakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
__GLX_SWAP_INT(&req->context);
__GLX_SWAP_INT(&req->oldContextTag);
- return __glXMakeContextCurrent(cl, pc);
+ return DoMakeCurrent( cl, req->drawable, req->readdrawable,
+ req->context, req->oldContextTag );
}
int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
@@ -119,7 +160,8 @@ int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
__GLX_SWAP_INT(&req->context);
__GLX_SWAP_INT(&req->oldContextTag);
- return __glXMakeCurrentReadSGI(cl, pc);
+ return DoMakeCurrent( cl, req->drawable, req->readable,
+ req->context, req->oldContextTag );
}
int __glXSwapIsDirect(__GLXclientState *cl, GLbyte *pc)
@@ -182,90 +224,29 @@ int __glXSwapCopyContext(__GLXclientState *cl, GLbyte *pc)
int __glXSwapGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
{
- ClientPtr client = cl->client;
xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
- xGLXGetVisualConfigsReply reply;
- __GLXscreenInfo *pGlxScreen;
- __GLXvisualConfig *pGlxVisual;
- CARD32 buf[__GLX_TOTAL_CONFIG];
- unsigned int screen;
- int i, p;
__GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(&req->screen);
- screen = req->screen;
- if (screen > screenInfo.numScreens) {
- /* The client library must send a valid screen number. */
- client->errorValue = screen;
- return BadValue;
- }
- pGlxScreen = &__glXActiveScreens[screen];
-
- reply.numVisuals = pGlxScreen->numUsableVisuals;
- reply.numProps = __GLX_TOTAL_CONFIG;
- reply.length = (pGlxScreen->numUsableVisuals * __GLX_SIZE_CARD32 *
- __GLX_TOTAL_CONFIG) >> 2;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
-
- __GLX_SWAP_SHORT(&reply.sequenceNumber);
- __GLX_SWAP_INT(&reply.length);
- __GLX_SWAP_INT(&reply.numVisuals);
- __GLX_SWAP_INT(&reply.numProps);
- WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *)&reply);
-
- for (i=0; i < pGlxScreen->numVisuals; i++) {
- pGlxVisual = &pGlxScreen->pGlxVisual[i];
- if (pGlxVisual->vid == 0) {
- /* not a usable visual */
- continue;
- }
- p = 0;
- buf[p++] = pGlxVisual->vid;
- buf[p++] = pGlxVisual->class;
- buf[p++] = pGlxVisual->rgba;
-
- buf[p++] = pGlxVisual->redSize;
- buf[p++] = pGlxVisual->greenSize;
- buf[p++] = pGlxVisual->blueSize;
- buf[p++] = pGlxVisual->alphaSize;
- buf[p++] = pGlxVisual->accumRedSize;
- buf[p++] = pGlxVisual->accumGreenSize;
- buf[p++] = pGlxVisual->accumBlueSize;
- buf[p++] = pGlxVisual->accumAlphaSize;
-
- buf[p++] = pGlxVisual->doubleBuffer;
- buf[p++] = pGlxVisual->stereo;
-
- buf[p++] = pGlxVisual->bufferSize;
- buf[p++] = pGlxVisual->depthSize;
- buf[p++] = pGlxVisual->stencilSize;
- buf[p++] = pGlxVisual->auxBuffers;
- buf[p++] = pGlxVisual->level;
- /*
- ** Add token/value pairs for extensions.
- */
- buf[p++] = GLX_VISUAL_CAVEAT_EXT;
- buf[p++] = pGlxVisual->visualRating;
- buf[p++] = GLX_TRANSPARENT_TYPE_EXT;
- buf[p++] = pGlxVisual->transparentPixel;
- buf[p++] = GLX_TRANSPARENT_RED_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentRed;
- buf[p++] = GLX_TRANSPARENT_GREEN_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentGreen;
- buf[p++] = GLX_TRANSPARENT_BLUE_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentBlue;
- buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentAlpha;
- buf[p++] = GLX_TRANSPARENT_INDEX_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentIndex;
-
- __GLX_SWAP_INT_ARRAY(buf, __GLX_TOTAL_CONFIG);
- WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG,
- (char *)buf);
- }
- return Success;
+ return DoGetVisualConfigs( cl, req->screen, GL_TRUE );
+}
+
+int __glXSwapGetFBConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&req->screen);
+ return DoGetFBConfigs( cl, req->screen, GL_TRUE );
+}
+
+int __glXSwapGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&req->screen);
+ return DoGetFBConfigs( cl, req->screen, GL_TRUE );
}
int __glXSwapCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
@@ -279,7 +260,39 @@ int __glXSwapCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
__GLX_SWAP_INT(&req->pixmap);
__GLX_SWAP_INT(&req->glxpixmap);
- return __glXCreateGLXPixmap(cl, pc);
+ return DoCreateGLXPixmap( cl, req->visual, req->screen,
+ req->pixmap, req->glxpixmap );
+}
+
+int __glXSwapCreatePixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->pixmap);
+ __GLX_SWAP_INT(&req->glxpixmap);
+
+ return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
+ req->pixmap, req->glxpixmap );
+}
+
+int __glXSwapCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateGLXPixmapWithConfigSGIXReq *req =
+ (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->pixmap);
+ __GLX_SWAP_INT(&req->glxpixmap);
+
+ return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
+ req->pixmap, req->glxpixmap );
}
int __glXSwapDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
@@ -806,6 +819,7 @@ int __glXSwapVendorPrivate(__GLXclientState *cl, GLbyte *pc)
}
#endif
+
if ((vendorcode >= __GLX_MIN_VENDPRIV_OPCODE_EXT) &&
(vendorcode <= __GLX_MAX_VENDPRIV_OPCODE_EXT)) {
(*__glXSwapVendorPrivTable_EXT[vendorcode-__GLX_MIN_VENDPRIV_OPCODE_EXT])(cl, (GLbyte*)req);
@@ -833,6 +847,12 @@ int __glXSwapVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
return __glXSwapQueryContextInfoEXT(cl, pc);
case X_GLXvop_MakeCurrentReadSGI:
return __glXSwapMakeCurrentReadSGI(cl, pc);
+ case X_GLXvop_GetFBConfigsSGIX:
+ return __glXSwapGetFBConfigsSGIX(cl, pc);
+ case X_GLXvop_CreateContextWithConfigSGIX:
+ return __glXSwapCreateContextWithConfigSGIX(cl, pc);
+ case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
+ return __glXSwapCreateGLXPixmapWithConfigSGIX(cl, pc);
default:
break;
}
diff --git a/GL/glx/glxcontext.h b/GL/glx/glxcontext.h
index 5eb72177e..9a16851f0 100644
--- a/GL/glx/glxcontext.h
+++ b/GL/glx/glxcontext.h
@@ -80,7 +80,6 @@ struct __GLXcontextRec {
** This context is created with respect to this visual.
*/
VisualRec *pVisual;
- __GLXvisualConfig *pGlxVisual;
/*
** The XID of this context.
diff --git a/GL/glx/glxdrawable.h b/GL/glx/glxdrawable.h
index 972a6045f..1d7f44352 100644
--- a/GL/glx/glxdrawable.h
+++ b/GL/glx/glxdrawable.h
@@ -40,7 +40,7 @@
typedef struct {
DrawablePtr pDraw;
- __GLXvisualConfig *pGlxVisual;
+ __GLcontextModes *modes;
__GLXscreenInfo *pGlxScreen;
ScreenPtr pScreen;
Bool idExists;
@@ -69,11 +69,12 @@ struct __GLXdrawablePrivateRec {
/*
** Configuration of the visual to which this drawable was created.
*/
- __GLXvisualConfig *pGlxVisual;
+ __GLcontextModes *modes;
/*
** cached drawable size and origin
*/
+
GLint xorigin, yorigin;
GLint width, height;
diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c
index 796663e9b..87c9e1448 100644
--- a/GL/glx/glxext.c
+++ b/GL/glx/glxext.c
@@ -30,12 +30,11 @@
#include "micmap.h"
-extern __GLXextensionInfo __glDDXExtensionInfo;
void GlxWrapInitVisuals(miInitVisualsProcPtr *);
void GlxSetVisualConfigs(int nconfigs,
__GLXvisualConfig *configs, void **privates);
-__GLXextensionInfo *__glXExt = &__glDDXExtensionInfo;
+static __GLXextensionInfo *__glXExt /* = &__glDDXExtensionInfo */;
/*
** Forward declarations.
@@ -314,6 +313,8 @@ GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc)
{
saveInitVisualsProc = *initVisProc;
*initVisProc = GlxInitVisuals;
+ /* HACK: this shouldn't be done here but it's the earliest time */
+ __glXExt = __glXglDDXExtensionInfo(); /* from GLcore */
}
/************************************************************************/
diff --git a/GL/glx/glxext.h b/GL/glx/glxext.h
index 210fbb88c..c6cd219c7 100644
--- a/GL/glx/glxext.h
+++ b/GL/glx/glxext.h
@@ -73,8 +73,16 @@ extern void __glXResetLargeCommandStatus(__GLXclientState*);
extern int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc);
extern int __glXSwapQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc);
-extern int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc);
-extern int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc);
+extern int DoMakeCurrent( __GLXclientState *cl, GLXDrawable drawId,
+ GLXDrawable readId, GLXContextID contextId, GLXContextTag tag );
+extern int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen,
+ GLboolean do_swap);
+extern int DoGetFBConfigs(__GLXclientState *cl, unsigned screen,
+ GLboolean do_swap);
+extern int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
+ GLXContextID shareList, VisualID visual, GLuint screen, GLboolean isDirect);
+extern int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual,
+ GLuint screenNum, XID pixmapId, XID glxpixmapId);
extern void GlxExtensionInit(void);
diff --git a/GL/glx/glxscreens.c b/GL/glx/glxscreens.c
index f78b4a284..6ddbfcbd0 100644
--- a/GL/glx/glxscreens.c
+++ b/GL/glx/glxscreens.c
@@ -133,104 +133,34 @@ static char GLXServerExtensions[] =
"GLX_EXT_visual_info "
"GLX_EXT_visual_rating "
"GLX_EXT_import_context "
+ "GLX_OML_swap_method "
"GLX_SGI_make_current_read "
#ifndef __DARWIN__
"GLX_SGIS_multisample "
#endif
+ "GLX_SGIX_fbconfig "
;
/*
-** This comes from the GL library that the server will link with. Right
-** now, that is the DDX Sample OpenGL.
-*/
-extern __GLXscreenInfo __glDDXScreenInfo;
-
-__GLXscreenInfo *__glXScreens[] = {
- &__glDDXScreenInfo,
+ * __glDDXScreenInfo comes from GLcore, so we can't resolve this symbol at
+ * module open time. Leave a placeholder, and fill this in when we first
+ * need it (in __glXScreenInit). XXX Why make this an array?
+ */
+static __GLXscreenInfo *__glXScreens[] = {
+ NULL /* &__glDDXScreenInfo */ ,
};
-GLint __glXNumStaticScreens = (sizeof __glXScreens / sizeof __glXScreens[0]);
+static GLint __glXNumStaticScreens =
+ (sizeof __glXScreens / sizeof __glXScreens[0]);
__GLXscreenInfo *__glXActiveScreens;
GLint __glXNumActiveScreens;
RESTYPE __glXDrawableRes;
-#if 0
-static int
-CountBits(unsigned long mask)
-{
- int count = 0;
-
- while(mask) {
- count += (mask&1);
- mask >>= 1;
- }
-
- return count;
+__GLXscreenInfo *__glXgetActiveScreen(int num) {
+ return &__glXActiveScreens[num];
}
-#endif
-
-#if 0
-/*
-** A typical implementation would not probably not run through the screen's
-** visuals to find ones that match the visual configs supplied by the DDX
-** Sample OpenGL as we do here; we have done this to make this code easy to
-** drop into an existing X server.
-*/
-static int matchVisuals(__GLXvisualConfig *pGlxVisual, int numVisuals,
- int screen)
-{
- int i, j;
- __GLXvisualConfig *pvis = pGlxVisual;
- ScreenPtr pScreen = screenInfo.screens[screen];
- VisualPtr pVisual;
- int numMatchingVisuals = 0;
- int *used;
-
- used = (int *)__glXMalloc(pScreen->numVisuals*sizeof(int));
- __glXMemset(used, 0, pScreen->numVisuals*sizeof(int));
-
- for (i=0; i < numVisuals; i++, pvis++) {
- /*
- ** Look through all the server's visuals to see which match.
- */
- pvis->vid = 0;
- pVisual = pScreen->visuals;
- for (j=0; j < pScreen->numVisuals; j++, pVisual++) {
- if (pvis->class == pVisual->class &&
- pvis->bufferSize == pVisual->nplanes &&
- !used[j]) {
- int rBits, gBits, bBits, aBits;
-
- /* count bits per rgb */
- rBits = CountBits(pVisual->redMask);
- gBits = CountBits(pVisual->greenMask);
- bBits = CountBits(pVisual->blueMask);
- aBits = 0;
- if ((pvis->redSize == rBits) &&
- (pvis->greenSize == gBits) &&
- (pvis->blueSize == bBits) &&
- (pvis->alphaSize == aBits)) {
- /*
- ** We'll consider this a match.
- */
- pvis->vid = pVisual->vid;
- pvis->redMask = pVisual->redMask;
- pvis->greenMask = pVisual->greenMask;
- pvis->blueMask = pVisual->blueMask;
- pvis->alphaMask = 0;
- numMatchingVisuals++;
- used[j] = 1;
- break;
- }
- }
- }
- }
- __glXFree(used);
- return numMatchingVisuals;
-}
-#endif
/*
** Destroy routine that gets called when a drawable is freed. A drawable
@@ -346,6 +276,8 @@ void __glXScreenInit(GLint numscreens)
{
GLint i,j;
+ __glXScreens[0] = __glXglDDXScreenInfo(); /* from GLcore */
+
/*
** This alloc has to work or else the server might as well core dump.
*/
@@ -360,14 +292,7 @@ void __glXScreenInit(GLint numscreens)
if ((*__glXScreens[j]->screenProbe)(i)) {
__glXActiveScreens[i] = *__glXScreens[j];
-#if 0
- /* we don't use this since matchVisuals doesn't allow alpha */
- __glXActiveScreens[i].numUsableVisuals =
- matchVisuals(__glXActiveScreens[i].pGlxVisual,
- __glXActiveScreens[i].numVisuals, i);
-#else
__glXActiveScreens[i].numUsableVisuals = __glXActiveScreens[i].numVisuals;
-#endif
__glXActiveScreens[i].GLextensions = __glXStrdup(GLServerExtensions);
__glXActiveScreens[i].GLXvendor = __glXStrdup(GLXServerVendorName);
__glXActiveScreens[i].GLXversion = __glXStrdup(GLXServerVersion);
diff --git a/GL/glx/glxscreens.h b/GL/glx/glxscreens.h
index 42dc66e08..c4d237bbc 100644
--- a/GL/glx/glxscreens.h
+++ b/GL/glx/glxscreens.h
@@ -70,7 +70,11 @@ typedef struct {
*/
void (*createBuffer)(__GLXdrawablePrivate *glxPriv);
- __GLXvisualConfig *pGlxVisual;
+ /**
+ * Linked list of valid context modes for this screen.
+ */
+ __GLcontextModes *modes;
+
void **pVisualPriv;
GLint numVisuals;
GLint numUsableVisuals;
diff --git a/GL/glx/glxserver.h b/GL/glx/glxserver.h
index be9e40f5a..66d681d2d 100644
--- a/GL/glx/glxserver.h
+++ b/GL/glx/glxserver.h
@@ -92,6 +92,7 @@ typedef struct __GLXclientStateRec __GLXclientState;
extern __GLXscreenInfo *__glXActiveScreens;
extern GLint __glXNumActiveScreens;
+extern __GLXscreenInfo *__glXgetActiveScreen(int num);
/************************************************************************/
diff --git a/GL/glx/glxutil.c b/GL/glx/glxutil.c
index 7aafd0065..4512aa5e9 100644
--- a/GL/glx/glxutil.c
+++ b/GL/glx/glxutil.c
@@ -44,6 +44,9 @@
#include "glxutil.h"
#include "glxbuf.h"
#include "GL/glx_ansic.h"
+#include "GL/internal/glcore.h"
+#include "GL/glxint.h"
+#include "glcontextmodes.h"
/************************************************************************/
@@ -214,53 +217,6 @@ __glXResizeDrawable(__GLdrawablePrivate *glPriv)
}
-/************************************************************************/
-
-void
-__glXFormatGLModes(__GLcontextModes *modes, __GLXvisualConfig *config)
-{
- __glXMemset(modes, 0, sizeof(__GLcontextModes));
-
- modes->rgbMode = (config->rgba != 0);
- modes->colorIndexMode = !(modes->rgbMode);
- modes->doubleBufferMode = (config->doubleBuffer != 0);
- modes->stereoMode = (config->stereo != 0);
-
- modes->haveAccumBuffer = ((config->accumRedSize +
- config->accumGreenSize +
- config->accumBlueSize +
- config->accumAlphaSize) > 0);
- modes->haveDepthBuffer = (config->depthSize > 0);
- modes->haveStencilBuffer = (config->stencilSize > 0);
-
- modes->redBits = config->redSize;
- modes->greenBits = config->greenSize;
- modes->blueBits = config->blueSize;
- modes->alphaBits = config->alphaSize;
- modes->redMask = config->redMask;
- modes->greenMask = config->greenMask;
- modes->blueMask = config->blueMask;
- modes->alphaMask = config->alphaMask;
-#if 0
- modes->rgbBits = modes->redBits + modes->greenBits +
- modes->blueBits + modes->alphaBits;
-#endif
- assert( !modes->rgbMode || ((config->bufferSize & 0x7) == 0) );
- modes->rgbBits = config->bufferSize;
- modes->indexBits = config->bufferSize;
-
- modes->accumRedBits = config->accumRedSize;
- modes->accumGreenBits = config->accumGreenSize;
- modes->accumBlueBits = config->accumBlueSize;
- modes->accumAlphaBits = config->accumAlphaSize;
- modes->depthBits = config->depthSize;
- modes->stencilBits = config->stencilSize;
-
- modes->numAuxBuffers = 0; /* XXX: should be picked up from the visual */
-
- modes->level = config->level;
-}
-
/*****************************************************************************/
/* accessing the drawable private */
@@ -382,21 +338,13 @@ __glXCreateDrawablePrivate(DrawablePtr pDraw, XID drawId,
pGlxScreen = &__glXActiveScreens[pDraw->pScreen->myNum];
- /* allocate the buffers */
if (glxPriv->type == DRAWABLE_WINDOW) {
- int i;
VisualID vid = wVisual((WindowPtr)pDraw);
- __GLXvisualConfig *pGlxVisual = pGlxScreen->pGlxVisual;
- for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
- if (pGlxVisual->vid == vid) {
- glxPriv->pGlxVisual = pGlxVisual;
- break;
- }
- }
+ glxPriv->modes = _gl_context_modes_find_visual( pGlxScreen->modes, vid );
__glXFBInitDrawable(glxPriv, modes);
} else {
- glxPriv->pGlxVisual = glxPriv->pGlxPixmap->pGlxVisual;
+ glxPriv->modes = glxPriv->pGlxPixmap->modes;
__glXPixInitDrawable(glxPriv, modes);
}
diff --git a/GL/glx/glxutil.h b/GL/glx/glxutil.h
index 67bfb06f9..dbf7084b5 100644
--- a/GL/glx/glxutil.h
+++ b/GL/glx/glxutil.h
@@ -55,7 +55,6 @@ extern void __glXGetDrawableSize(__GLdrawablePrivate *glPriv,
GLuint *width, GLuint *height);
extern GLboolean __glXResizeDrawable(__GLdrawablePrivate *glPriv);
extern GLboolean __glXResizeDrawableBuffers(__GLXdrawablePrivate *glxPriv);
-extern void __glXFormatGLModes(__GLcontextModes *modes, __GLXvisualConfig *config);
/* drawable management */
extern void __glXRefDrawablePrivate(__GLXdrawablePrivate *glxPriv);
@@ -73,6 +72,9 @@ extern void __glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv);
/* context helper routines */
extern __GLXcontext *__glXLookupContextByTag(__GLXclientState*, GLXContextTag);
+/* init helper routines */
+extern void *__glXglDDXScreenInfo(void);
+extern void *__glXglDDXExtensionInfo(void);
#endif /* _glxcmds_h_ */
diff --git a/GL/glx/render2.c b/GL/glx/render2.c
index d4c523fea..2629a7025 100644
--- a/GL/glx/render2.c
+++ b/GL/glx/render2.c
@@ -234,16 +234,14 @@ void __glXDisp_DrawArrays(GLbyte *pc)
glEnableClientState(GL_EDGE_FLAG_ARRAY);
glEdgeFlagPointer(stride, (const GLboolean *)pc);
break;
-#ifndef MISSING_GL_EXTS
case GL_SECONDARY_COLOR_ARRAY:
glEnableClientState(GL_SECONDARY_COLOR_ARRAY);
glSecondaryColorPointer(numVals, datatype, stride, pc);
break;
- case GL_FOG_COORDINATE_ARRAY:
- glEnableClientState(GL_FOG_COORDINATE_ARRAY);
+ case GL_FOG_COORD_ARRAY:
+ glEnableClientState(GL_FOG_COORD_ARRAY);
glFogCoordPointer(datatype, stride, pc);
break;
-#endif
default:
break;
}
@@ -261,7 +259,7 @@ void __glXDisp_DrawArrays(GLbyte *pc)
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_EDGE_FLAG_ARRAY);
glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
- glDisableClientState(GL_FOG_COORDINATE_ARRAY);
+ glDisableClientState(GL_FOG_COORD_ARRAY);
}
void __glXDisp_DrawArraysEXT(GLbyte *pc)
diff --git a/GL/glx/rensize.c b/GL/glx/rensize.c
index aa784b5fc..5d7c7b367 100644
--- a/GL/glx/rensize.c
+++ b/GL/glx/rensize.c
@@ -558,7 +558,7 @@ int __glXDrawArraysSize( GLbyte *pc, Bool swap )
return -1;
}
break;
- case GL_FOG_COORDINATE_ARRAY:
+ case GL_FOG_COORD_ARRAY:
case GL_INDEX_ARRAY:
if (numVals != 1) {
/* bad size */
diff --git a/GL/glx/singlesize.c b/GL/glx/singlesize.c
index 448fa1aef..3baf03517 100644
--- a/GL/glx/singlesize.c
+++ b/GL/glx/singlesize.c
@@ -81,7 +81,7 @@ GLint __glGetTexEnvfv_size(GLenum pname)
case GL_ALPHA_SCALE:
/* GL_ARB_point_sprite / GL_NV_point_sprite */
- case GL_COORD_REPLACE_NV:
+ case GL_COORD_REPLACE_ARB:
/* GL_NV_texture_env_combine4 */
case GL_SOURCE3_RGB_NV:
@@ -179,6 +179,9 @@ GLint __glGetTexParameterfv_size(GLenum pname)
/* GL_EXT_texture_filter_anisotropic */
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+
+ /* GL_NV_texture_expand_normal */
+ case GL_TEXTURE_UNSIGNED_REMAP_MODE_NV:
return 1;
default:
@@ -898,11 +901,11 @@ GLint __glGet_size(GLenum sq)
case GL_BLEND_SRC_ALPHA:
/* GL_EXT_fog_coord / GL 1.4 */
- case GL_CURRENT_FOG_COORDINATE:
- case GL_FOG_COORDINATE_ARRAY_TYPE:
- case GL_FOG_COORDINATE_ARRAY_STRIDE:
- case GL_FOG_COORDINATE_ARRAY:
- case GL_FOG_COORDINATE_SOURCE:
+ case GL_CURRENT_FOG_COORD:
+ case GL_FOG_COORD_ARRAY_TYPE:
+ case GL_FOG_COORD_ARRAY_STRIDE:
+ case GL_FOG_COORD_ARRAY:
+ case GL_FOG_COORD_SRC:
/* GL_EXT_secondary_color / GL 1.4 */
case GL_COLOR_SUM:
@@ -915,7 +918,7 @@ GLint __glGet_size(GLenum sq)
case GL_MAX_TEXTURE_LOD_BIAS:
/* GL_ARB_point_sprite */
- case GL_POINT_SPRITE_NV:
+ case GL_POINT_SPRITE_ARB:
/* GL_ARB_vertex_blend */
case GL_MAX_VERTEX_UNITS_ARB:
@@ -942,6 +945,9 @@ GLint __glGet_size(GLenum sq)
/* GL_EXT_clip_volume_hint */
case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
+ /* GL_EXT_depth_bounds_test */
+ case GL_DEPTH_BOUNDS_TEST_EXT:
+
/* GL_EXT_stencil_two_size */
case GL_STENCIL_TEST_TWO_SIDE_EXT:
case GL_ACTIVE_STENCIL_FACE_EXT:
@@ -958,9 +964,38 @@ GLint __glGet_size(GLenum sq)
/* case GL_MODELVIEW0_STACK_DEPTH_EXT: */ /* alias */
case GL_MODELVIEW1_STACK_DEPTH_EXT:
+ /* GL_EXT_blend_equation_separate */
+ /* case GL_BLEND_EQUATION_RGB_EXT: */ /* alias */
+ case GL_BLEND_EQUATION_ALPHA_EXT:
+
/* GL_ATI_vertex_streams */
case GL_MAX_VERTEX_STREAMS_ATI:
+ /* GL_ATI_draw_buffers */
+ case GL_MAX_DRAW_BUFFERS_ATI:
+ case GL_DRAW_BUFFER0_ATI:
+ case GL_DRAW_BUFFER1_ATI:
+ case GL_DRAW_BUFFER2_ATI:
+ case GL_DRAW_BUFFER3_ATI:
+ case GL_DRAW_BUFFER4_ATI:
+ case GL_DRAW_BUFFER5_ATI:
+ case GL_DRAW_BUFFER6_ATI:
+ case GL_DRAW_BUFFER7_ATI:
+ case GL_DRAW_BUFFER8_ATI:
+ case GL_DRAW_BUFFER9_ATI:
+ case GL_DRAW_BUFFER10_ATI:
+ case GL_DRAW_BUFFER11_ATI:
+ case GL_DRAW_BUFFER12_ATI:
+ case GL_DRAW_BUFFER13_ATI:
+ case GL_DRAW_BUFFER14_ATI:
+ case GL_DRAW_BUFFER15_ATI:
+
+ /* GL_ATI_separate_stencil */
+ case GL_STENCIL_BACK_FUNC_ATI:
+ case GL_STENCIL_BACK_FAIL_ATI:
+ case GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI:
+ case GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI:
+
/* GL_NV_depth_clamp */
case GL_DEPTH_CLAMP_NV:
@@ -978,6 +1013,10 @@ GLint __glGet_size(GLenum sq)
/* case GL_POINT_SPRITE_NV: */ /* alias */
case GL_POINT_SPRITE_R_MODE_NV:
+ /* GL_NV_primitive_restart */
+ case GL_PRIMITIVE_RESTART_NV:
+ case GL_PRIMITIVE_RESTART_INDEX_NV:
+
/* GL_NV_register_combiners */
case GL_REGISTER_COMBINERS_NV:
case GL_NUM_GENERAL_COMBINERS_NV:
@@ -993,6 +1032,10 @@ GLint __glGet_size(GLenum sq)
case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV:
return 1;
+ /* GL_EXT_depth_bounds_test */
+ case GL_DEPTH_BOUNDS_EXT:
+ return 2;
+
/* GL_EXT_secondary_color / GL 1.4 */
case GL_CURRENT_SECONDARY_COLOR:
diff --git a/GL/windows/ChangeLog b/GL/windows/ChangeLog
index 2b049ee73..9732e8c86 100644
--- a/GL/windows/ChangeLog
+++ b/GL/windows/ChangeLog
@@ -1,3 +1,11 @@
+2004-08-13 Alexander Gottwald <ago@freedesktop.org>
+
+ * Imakefile: Added $(MESASRCDIR)/src/mesa/glapi to INCLUDES.
+ Removed $(SERVERSRC)/mi from INCLUDES.
+ Rearranged INCLUDES for better readability.
+ * glwindows.h: Removed mipointrst.h and miscstruct.h from #include
+ since they are not used anymore.
+
2004-05-27 Alexander Gottwald <ago@freedesktop.org>
* glwindows.h: write current function and line in debug output
diff --git a/GL/windows/glwindows.h b/GL/windows/glwindows.h
index 1bfdcb715..aa984099c 100644
--- a/GL/windows/glwindows.h
+++ b/GL/windows/glwindows.h
@@ -4,8 +4,6 @@
#include <glxserver.h>
#include <glxext.h>
-#include <mipointrst.h>
-#include <miscstruct.h>
#include <windowstr.h>
#include <resource.h>
#include <GL/glxint.h>
@@ -35,7 +33,7 @@ extern glWinDebugSettingsRec glWinDebugSettings;
typedef struct {
int num_vis;
- __GLXvisualConfig *glx_vis;
+ __GLcontextModes *modes;
void **priv;
/* wrapped screen functions */
diff --git a/GL/windows/indirect.c b/GL/windows/indirect.c
index 80aec7ee9..11dc0c092 100755
--- a/GL/windows/indirect.c
+++ b/GL/windows/indirect.c
@@ -43,6 +43,7 @@
#include "glwindows.h"
+#include <glcontextmodes.h>
#include "../../hw/xwin/winpriv.h"
@@ -171,7 +172,7 @@ static void glWinResetExtension(void);
* struct. In particular, the contextCreate, pGlxVisual, numVisuals,
* and numUsableVisuals fields must be initialized.
*/
-__GLXscreenInfo __glDDXScreenInfo = {
+static __GLXscreenInfo __glDDXScreenInfo = {
glWinScreenProbe, /* Must be generic and handle all screens */
glWinCreateContext, /* Substitute screen's createContext routine */
glWinCreateBuffer, /* Substitute screen's createBuffer routine */
@@ -185,13 +186,21 @@ __GLXscreenInfo __glDDXScreenInfo = {
NULL /* WrappedPositionWindow is overwritten */
};
-__GLXextensionInfo __glDDXExtensionInfo = {
+void *__glXglDDXScreenInfo(void) {
+ return &__glDDXScreenInfo;
+}
+
+static __GLXextensionInfo __glDDXExtensionInfo = {
GL_CORE_WINDOWS,
glWinResetExtension,
glWinInitVisuals,
glWinSetVisualConfigs
};
+void *__glXglDDXExtensionInfo(void) {
+ return &__glDDXExtensionInfo;
+}
+
/* prototypes */
static GLboolean glWinDestroyContext(__GLcontext *gc);
@@ -863,27 +872,6 @@ static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
}
};
-static __GLXvisualConfig NullConfig = {
- -1, /* vid */
- -1, /* class */
- False, /* rgba */
- -1, -1, -1, 0, /* rgba sizes */
- -1, -1, -1, 0, /* rgba masks */
- 0, 0, 0, 0, /* rgba accum sizes */
- False, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 0, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE_EXT, /* visualRating */
- 0, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
-};
-
-
static inline int count_bits(uint32_t x)
{
x = x - ((x >> 1) & 0x55555555);
@@ -908,7 +896,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
VisualPtr pVisual = *visualp;
VisualPtr pVisualNew = NULL;
VisualID *orig_vid = NULL;
- __GLXvisualConfig *glXVisualPtr = NULL;
+ __GLcontextModes *modes = NULL;
__GLXvisualConfig *pNewVisualConfigs = NULL;
void **glXVisualPriv;
void **pNewVisualPriv;
@@ -990,9 +978,8 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
}
/* Alloc space for the list of glXVisuals */
- glXVisualPtr = (__GLXvisualConfig *)__glXMalloc(numNewVisuals *
- sizeof(__GLXvisualConfig));
- if (!glXVisualPtr) {
+ modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
+ if (modes == NULL) {
__glXFree(orig_vid);
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
@@ -1002,7 +989,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
/* Alloc space for the list of glXVisualPrivates */
glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
if (!glXVisualPriv) {
- __glXFree(glXVisualPtr);
+ _gl_context_modes_destroy( modes );
__glXFree(orig_vid);
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
@@ -1013,7 +1000,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
if (!pVisualNew) {
__glXFree(glXVisualPriv);
- __glXFree(glXVisualPtr);
+ _gl_context_modes_destroy( modes );
__glXFree(orig_vid);
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
@@ -1022,10 +1009,12 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
/* Initialize the new visuals */
found_default = FALSE;
+ glWinScreens[screenInfo.numScreens-1].modes = modes;
for (i = j = 0; i < numVisuals; i++) {
int is_rgb = (pVisual[i].class == TrueColor ||
pVisual[i].class == DirectColor);
+#if 0
if (!is_rgb)
{
/* We don't support non-rgb visuals for GL. But we don't
@@ -1052,11 +1041,14 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
continue;
}
+#endif
for (k = 0; k < numNewConfigs; k++) {
if (pNewVisualConfigs[k].rgba != is_rgb)
continue;
+ assert( modes != NULL );
+
/* Initialize the new visual */
pVisualNew[j] = pVisual[i];
pVisualNew[j].vid = FakeClientID(0);
@@ -1071,8 +1063,8 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
orig_vid[j] = pVisual[i].vid;
/* Initialize the glXVisual */
- glXVisualPtr[j] = pNewVisualConfigs[k];
- glXVisualPtr[j].vid = pVisualNew[j].vid;
+ _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
+ modes->visualID = pVisualNew[j].vid;
/*
* If the class is -1, then assume the X visual information
@@ -1080,23 +1072,27 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
* visual. NOTE: if class != -1, then all other fields MUST
* be initialized.
*/
- if (glXVisualPtr[j].class == -1) {
- glXVisualPtr[j].class = pVisual[i].class;
- glXVisualPtr[j].redSize = count_bits(pVisual[i].redMask);
- glXVisualPtr[j].greenSize = count_bits(pVisual[i].greenMask);
- glXVisualPtr[j].blueSize = count_bits(pVisual[i].blueMask);
- glXVisualPtr[j].alphaSize = glXVisualPtr[j].alphaSize;
- glXVisualPtr[j].redMask = pVisual[i].redMask;
- glXVisualPtr[j].greenMask = pVisual[i].greenMask;
- glXVisualPtr[j].blueMask = pVisual[i].blueMask;
- glXVisualPtr[j].alphaMask = glXVisualPtr[j].alphaMask;
- glXVisualPtr[j].bufferSize = rootDepth;
+ if (modes->visualType == GLX_NONE) {
+ modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
+ modes->redBits = count_bits(pVisual[i].redMask);
+ modes->greenBits = count_bits(pVisual[i].greenMask);
+ modes->blueBits = count_bits(pVisual[i].blueMask);
+ modes->alphaBits = modes->alphaBits;
+ modes->redMask = pVisual[i].redMask;
+ modes->greenMask = pVisual[i].greenMask;
+ modes->blueMask = pVisual[i].blueMask;
+ modes->alphaMask = modes->alphaMask;
+ modes->rgbBits = (is_rgb)
+ ? (modes->redBits + modes->greenBits +
+ modes->blueBits + modes->alphaBits)
+ : rootDepth;
}
/* Save the device-dependent private for this visual */
glXVisualPriv[j] = pNewVisualPriv[k];
j++;
+ modes = modes->next;
}
}
@@ -1104,7 +1100,6 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
/* Save the GLX visuals in the screen structure */
glWinScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
- glWinScreens[screenInfo.numScreens-1].glx_vis = glXVisualPtr;
glWinScreens[screenInfo.numScreens-1].priv = glXVisualPriv;
/* Set up depth's VisualIDs */
@@ -1159,29 +1154,30 @@ static void fixup_visuals(int screen)
{
ScreenPtr pScreen = screenInfo.screens[screen];
glWinScreenRec *pScr = &glWinScreens[screen];
- __GLXvisualConfig *pGLXVis = pScr->glx_vis;
- VisualPtr pVis;
- int i, j;
+ __GLcontextModes *modes;
+ int j;
GLWIN_DEBUG_MSG("fixup_visuals\n");
- for (i = 0; i < pScr->num_vis; i++, pGLXVis++) {
- pVis = pScreen->visuals;
+ for (modes = pScr->modes; modes != NULL; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ VisualPtr pVis = pScreen->visuals;
/* Find a visual that matches the GLX visual's class and size */
- for (j = 0; j < pScreen->numVisuals; j++, pVis++) {
- if (pVis->class == pGLXVis->class &&
- pVis->nplanes == pGLXVis->bufferSize) {
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes) {
/* Fixup the masks */
- pGLXVis->redMask = pVis->redMask;
- pGLXVis->greenMask = pVis->greenMask;
- pGLXVis->blueMask = pVis->blueMask;
+ modes->redMask = pVis[j].redMask;
+ modes->greenMask = pVis[j].greenMask;
+ modes->blueMask = pVis[j].blueMask;
/* Recalc the sizes */
- pGLXVis->redSize = count_bits(pGLXVis->redMask);
- pGLXVis->greenSize = count_bits(pGLXVis->greenMask);
- pGLXVis->blueSize = count_bits(pGLXVis->blueMask);
+ modes->redBits = count_bits(modes->redMask);
+ modes->greenBits = count_bits(modes->greenMask);
+ modes->blueBits = count_bits(modes->blueMask);
}
}
}
@@ -1190,67 +1186,75 @@ static void fixup_visuals(int screen)
static void init_screen_visuals(int screen)
{
ScreenPtr pScreen = screenInfo.screens[screen];
- __GLXvisualConfig *pGLXVis = glWinScreens[screen].glx_vis;
- /* XMesaVisual *pXMesaVisual; */
- VisualPtr pVis;
+ __GLcontextModes *modes;
int *used;
int i, j;
GLWIN_DEBUG_MSG("init_screen_visuals\n");
- /* Alloc space for the list of XMesa visuals */
-#if 0
- pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis *
- sizeof(XMesaVisual));
- __glXMemset(pXMesaVisual, 0,
- MESAScreens[screen].num_vis * sizeof(XMesaVisual));
-#endif
-
used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
__glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
- for (i = 0; i < glWinScreens[screen].num_vis; i++, pGLXVis++) {
- pVis = pScreen->visuals;
- for (j = 0; j < pScreen->numVisuals; j++, pVis++) {
-
- if (pVis->class == pGLXVis->class &&
- pVis->nplanes == pGLXVis->bufferSize &&
+ i = 0;
+ for ( modes = glWinScreens[screen].modes
+ ; modes != NULL
+ ; modes = modes->next) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ for (j = 0; j < pScreen->numVisuals; j++) {
+
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes &&
+ pVis[j].redMask == modes->redMask &&
+ pVis[j].greenMask == modes->greenMask &&
+ pVis[j].blueMask == modes->blueMask &&
!used[j]) {
- if (pVis->redMask == pGLXVis->redMask &&
- pVis->greenMask == pGLXVis->greenMask &&
- pVis->blueMask == pGLXVis->blueMask) {
-
- /* Create the XMesa visual */
#if 0
- pXMesaVisual[i] =
- XMesaCreateVisual(pScreen,
- pVis,
- pGLXVis->rgba,
- (pGLXVis->alphaSize > 0),
- pGLXVis->doubleBuffer,
- pGLXVis->stereo,
- GL_TRUE, /* ximage_flag */
- pGLXVis->depthSize,
- pGLXVis->stencilSize,
- pGLXVis->accumRedSize,
- pGLXVis->accumGreenSize,
- pGLXVis->accumBlueSize,
- pGLXVis->accumAlphaSize,
- 0, /* numSamples */
- pGLXVis->level,
- pGLXVis->visualRating );
+ /* Create the XMesa visual */
+ pXMesaVisual[i] =
+ XMesaCreateVisual(pScreen,
+ pVis,
+ modes->rgbMode,
+ (modes->alphaBits > 0),
+ modes->doubleBufferMode,
+ modes->stereoMode,
+ GL_TRUE, /* ximage_flag */
+ modes->depthBits,
+ modes->stencilBits,
+ modes->accumRedBits,
+ modes->accumGreenBits,
+ modes->accumBlueBits,
+ modes->accumAlphaBits,
+ modes->samples,
+ modes->level,
+ modes->visualRating);
#endif
+
+ /* Set the VisualID */
+ modes->visualID = pVis[j].vid;
- /* Set the VisualID */
- pGLXVis->vid = pVis->vid;
+ /* Mark this visual used */
+ used[j] = 1;
+ break;
+ }
+ }
- /* Mark this visual used */
- used[j] = 1;
- break;
- }
- }
+ if ( j == pScreen->numVisuals ) {
+ ErrorF("No matching visual for __GLcontextMode with "
+ "visual class = %d (%d), nplanes = %u\n",
+ vis_class,
+ modes->visualType,
+ (modes->rgbBits - modes->alphaBits) );
+ }
+ else if ( modes->visualID == -1 ) {
+ FatalError( "Matching visual found, but visualID still -1!\n" );
}
+
+ i++;
+
}
__glXFree(used);
@@ -1268,7 +1272,7 @@ static Bool glWinScreenProbe(int screen)
/*
* Set up the current screen's visuals.
*/
- __glDDXScreenInfo.pGlxVisual = glWinScreens[screen].glx_vis;
+ __glDDXScreenInfo.modes = glWinScreens[screen].modes;
__glDDXScreenInfo.pVisualPriv = glWinScreens[screen].priv;
__glDDXScreenInfo.numVisuals =
__glDDXScreenInfo.numUsableVisuals = glWinScreens[screen].num_vis;
diff --git a/XTrap/xtrapdi.c b/XTrap/xtrapdi.c
index 4fe54e1da..bcd5b8a6e 100644
--- a/XTrap/xtrapdi.c
+++ b/XTrap/xtrapdi.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/XTrap/xtrapdi.c,v 1.1.4.3.2.3 2004/03/04 20:15:59 kaleb Exp $ */
+/* $XdotOrg: xc/programs/Xserver/XTrap/xtrapdi.c,v 1.2 2004/04/23 18:44:40 eich Exp $ */
/* $XFree86: xc/programs/Xserver/XTrap/xtrapdi.c,v 1.6tsi Exp $ */
/*****************************************************************************
Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index d9e36d47e..90afc2b3d 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -53,6 +53,12 @@ Equipment Corporation.
#include "modinit.h"
+#ifdef GLXPROXY
+extern VisualPtr glxMatchVisual(ScreenPtr pScreen,
+ VisualPtr pVisual,
+ ScreenPtr pMatchScreen);
+#endif
+
#if 0
static unsigned char PanoramiXReqCode = 0;
#endif
@@ -416,6 +422,56 @@ XineramaRegisterConnectionBlockCallback(void (*func)(void))
return TRUE;
}
+static void XineramaInitData(ScreenPtr pScreen)
+{
+ int i, w, h;
+
+ REGION_NULL(pScreen, &PanoramiXScreenRegion)
+ for (i = 0; i < PanoramiXNumScreens; i++) {
+ BoxRec TheBox;
+
+ pScreen = screenInfo.screens[i];
+
+ panoramiXdataPtr[i].x = dixScreenOrigins[i].x;
+ panoramiXdataPtr[i].y = dixScreenOrigins[i].y;
+ panoramiXdataPtr[i].width = pScreen->width;
+ panoramiXdataPtr[i].height = pScreen->height;
+
+ TheBox.x1 = panoramiXdataPtr[i].x;
+ TheBox.x2 = TheBox.x1 + panoramiXdataPtr[i].width;
+ TheBox.y1 = panoramiXdataPtr[i].y;
+ TheBox.y2 = TheBox.y1 + panoramiXdataPtr[i].height;
+
+ REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1);
+ REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion,
+ &XineramaScreenRegions[i]);
+ }
+
+ PanoramiXPixWidth = panoramiXdataPtr[0].x + panoramiXdataPtr[0].width;
+ PanoramiXPixHeight = panoramiXdataPtr[0].y + panoramiXdataPtr[0].height;
+
+ for (i = 1; i < PanoramiXNumScreens; i++) {
+ w = panoramiXdataPtr[i].x + panoramiXdataPtr[i].width;
+ h = panoramiXdataPtr[i].y + panoramiXdataPtr[i].height;
+
+ if (PanoramiXPixWidth < w)
+ PanoramiXPixWidth = w;
+ if (PanoramiXPixHeight < h)
+ PanoramiXPixHeight = h;
+ }
+}
+
+void XineramaReinitData(ScreenPtr pScreen)
+{
+ int i;
+
+ REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
+ for (i = 0; i < PanoramiXNumScreens; i++)
+ REGION_UNINIT(pScreen, &XineramaScreenRegions[i]);
+
+ XineramaInitData(pScreen);
+}
+
/*
* PanoramiXExtensionInit():
* Called from InitExtensions in main().
@@ -430,8 +486,7 @@ void PanoramiXExtensionInit(int argc, char *argv[])
ExtensionEntry *extEntry;
ScreenPtr pScreen = screenInfo.screens[0];
PanoramiXScreenPtr pScreenPriv;
- int w, h;
-
+
if (noPanoramiXExtension)
return;
@@ -509,41 +564,7 @@ void PanoramiXExtensionInit(int argc, char *argv[])
return;
}
-
- REGION_NULL(pScreen, &PanoramiXScreenRegion);
- for (i = 0; i < PanoramiXNumScreens; i++) {
- BoxRec TheBox;
-
- pScreen = screenInfo.screens[i];
-
- panoramiXdataPtr[i].x = dixScreenOrigins[i].x;
- panoramiXdataPtr[i].y = dixScreenOrigins[i].y;
- panoramiXdataPtr[i].width = pScreen->width;
- panoramiXdataPtr[i].height = pScreen->height;
-
- TheBox.x1 = panoramiXdataPtr[i].x;
- TheBox.x2 = TheBox.x1 + panoramiXdataPtr[i].width;
- TheBox.y1 = panoramiXdataPtr[i].y;
- TheBox.y2 = TheBox.y1 + panoramiXdataPtr[i].height;
-
- REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1);
- REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion,
- &XineramaScreenRegions[i]);
- }
-
-
- PanoramiXPixWidth = panoramiXdataPtr[0].x + panoramiXdataPtr[0].width;
- PanoramiXPixHeight = panoramiXdataPtr[0].y + panoramiXdataPtr[0].height;
-
- for (i = 1; i < PanoramiXNumScreens; i++) {
- w = panoramiXdataPtr[i].x + panoramiXdataPtr[i].width;
- h = panoramiXdataPtr[i].y + panoramiXdataPtr[i].height;
-
- if(PanoramiXPixWidth < w)
- PanoramiXPixWidth = w;
- if(PanoramiXPixHeight < h)
- PanoramiXPixHeight = h;
- }
+ XineramaInitData(pScreen);
/*
* Put our processes into the ProcVector
@@ -789,6 +810,18 @@ void PanoramiXConsolidate(void)
/* check if the visual exists on all screens */
for (j = 1; j < PanoramiXNumScreens; j++) {
pScreen2 = screenInfo.screens[j];
+
+#ifdef GLXPROXY
+ pVisual2 = glxMatchVisual(pScreen, pVisual, pScreen2);
+ if (pVisual2) {
+ PanoramiXVisualTable[(pVisual->vid * MAXSCREENS) + j] =
+ pVisual2->vid;
+ continue;
+ } else if (glxMatchVisual(pScreen, pVisual, pScreen)) {
+ PanoramiXVisualTable[(pVisual->vid * MAXSCREENS) + j] = 0;
+ break;
+ }
+#endif
pVisual2 = pScreen2->visuals;
for (k = 0; k < pScreen2->numVisuals; k++, pVisual2++) {
diff --git a/Xext/panoramiX.h b/Xext/panoramiX.h
index 65b77948f..ff97e8897 100644
--- a/Xext/panoramiX.h
+++ b/Xext/panoramiX.h
@@ -1,5 +1,5 @@
/* $TOG: panoramiX.h /main/4 1998/03/17 06:51:02 kaleb $ */
-/* $XdotOrg: xc/programs/Xserver/Xext/panoramiX.h,v 1.1.4.1.4.2 2004/03/08 00:36:56 alanc Exp $ */
+/* $XdotOrg: xc/programs/Xserver/Xext/panoramiX.h,v 1.2 2004/04/23 18:44:41 eich Exp $ */
/*****************************************************************
Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
diff --git a/Xext/panoramiXsrv.h b/Xext/panoramiXsrv.h
index 1d187bc27..92800062e 100644
--- a/Xext/panoramiXsrv.h
+++ b/Xext/panoramiXsrv.h
@@ -20,6 +20,8 @@ extern WindowPtr PanoramiXChangeWindow(int, WindowPtr);
extern Bool XineramaRegisterConnectionBlockCallback(void (*func)(void));
extern int XineramaDeleteResource(pointer, XID);
+extern void XineramaReinitData(ScreenPtr);
+
extern RegionRec XineramaScreenRegions[MAXSCREENS];
extern unsigned long XRC_DRAWABLE;
diff --git a/Xext/saver.c b/Xext/saver.c
index 84eb7f294..33173d3ce 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/Xext/saver.c,v 1.1.4.3.2.2 2004/03/04 17:47:20 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/Xext/saver.c,v 1.2 2004/04/23 18:44:41 eich Exp $ */
/*
* $XConsortium: saver.c,v 1.12 94/04/17 20:59:36 dpw Exp $
*
diff --git a/Xext/security.c b/Xext/security.c
index a5b8e6604..488296f51 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/Xext/security.c,v 1.1.4.3.4.1 2004/03/04 17:47:20 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/Xext/security.c,v 1.2 2004/04/23 18:44:41 eich Exp $ */
/* $Xorg: security.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */
/*
diff --git a/Xext/shape.c b/Xext/shape.c
index eccfabac8..7842a402b 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/Xext/shape.c,v 1.1.4.4.2.3 2004/03/04 20:16:01 kaleb Exp $ */
+/* $XdotOrg: xc/programs/Xserver/Xext/shape.c,v 1.4 2004/07/29 23:43:39 kem Exp $ */
/* $XFree86: xc/programs/Xserver/Xext/shape.c,v 3.18 2003/10/28 23:08:43 tsi Exp $ */
/************************************************************
@@ -61,10 +61,6 @@ static int ShapeFreeEvents(
pointer /* data */,
XID /* id */
);
-static void SendShapeNotify(
- WindowPtr /* pWin */,
- int /* which */
- );
static void ShapeResetProc(
ExtensionEntry * /* extEntry */
);
@@ -85,12 +81,9 @@ RegionOperate (
CreateDftPtr /* create */
);
-#define CREATE_PROC(func) RegionPtr func(WindowPtr /* pWin */)
-
-static CREATE_PROC(CreateBoundingShape);
-static CREATE_PROC(CreateClipShape);
-
-#undef CREATE_PROC
+/* SendShapeNotify, CreateBoundingShape and CreateClipShape are used
+ * externally by the Xfixes extension and are now defined in window.h
+ */
static DISPATCH_PROC(ProcShapeCombine);
static DISPATCH_PROC(ProcShapeDispatch);
@@ -261,7 +254,7 @@ RegionOperate (client, pWin, kind, destRgnp, srcRgn, op, xoff, yoff, create)
return Success;
}
-static RegionPtr
+RegionPtr
CreateBoundingShape (pWin)
WindowPtr pWin;
{
@@ -274,7 +267,7 @@ CreateBoundingShape (pWin)
return REGION_CREATE(pWin->drawable.pScreen, &extents, 1);
}
-static RegionPtr
+RegionPtr
CreateClipShape (pWin)
WindowPtr pWin;
{
@@ -880,7 +873,7 @@ ProcShapeSelectInput (client)
* deliver the event
*/
-static void
+void
SendShapeNotify (pWin, which)
WindowPtr pWin;
int which;
diff --git a/Xext/shm.c b/Xext/shm.c
index fb8a66694..29eab06f5 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -1,4 +1,3 @@
-/* $XdotOrg: xc/programs/Xserver/Xext/shm.c,v 1.1.4.5.2.3 2004/03/04 20:16:01 kaleb Exp $ */
/* $XFree86: xc/programs/Xserver/Xext/shm.c,v 3.41 2003/12/17 23:28:56 alanh Exp $ */
/************************************************************
diff --git a/Xext/xres.c b/Xext/xres.c
index dd429649d..8558f4731 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -2,7 +2,7 @@
Copyright (c) 2002 XFree86 Inc
*/
/* $XFree86: xc/programs/Xserver/Xext/xres.c,v 1.7tsi Exp $ */
-/* $XdotOrg: xc/programs/Xserver/Xext/xres.c,v 1.1.4.1.6.2 2004/03/08 23:40:19 alanc Exp $ */
+/* $XdotOrg: xc/programs/Xserver/Xext/xres.c,v 1.2 2004/04/23 18:44:42 eich Exp $ */
#define NEED_EVENTS
#define NEED_REPLIES
diff --git a/Xext/xtest.c b/Xext/xtest.c
index 09d135044..1ba8e3df5 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/Xext/xtest.c,v 1.1.4.4.2.2 2004/03/04 17:47:20 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/Xext/xtest.c,v 1.2 2004/04/23 18:44:42 eich Exp $ */
/* $Xorg: xtest.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
/*
diff --git a/Xext/xtest1di.c b/Xext/xtest1di.c
index 47e60f6b6..8248d6078 100644
--- a/Xext/xtest1di.c
+++ b/Xext/xtest1di.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/Xext/xtest1di.c,v 1.1.4.3.4.1 2004/03/04 17:47:20 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/Xext/xtest1di.c,v 1.2 2004/04/23 18:44:42 eich Exp $ */
/* $Xorg: xtest1di.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
/*
* File: xtest1di.c
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index 8e6ea19b1..f10d157e6 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/Xext/xvdisp.c,v 1.1.4.3.2.2 2004/03/04 17:47:20 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/Xext/xvdisp.c,v 1.2 2004/04/23 18:44:42 eich Exp $ */
/***********************************************************
Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index 188eb77be..3de18019d 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/Xext/xvmain.c,v 1.1.4.3.2.2 2004/03/04 17:47:20 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/Xext/xvmain.c,v 1.2 2004/04/23 18:44:42 eich Exp $ */
/***********************************************************
Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
diff --git a/XpConfig/C/print/Xprinters b/XpConfig/C/print/Xprinters
index 9290636fb..a32c02dc2 100644
--- a/XpConfig/C/print/Xprinters
+++ b/XpConfig/C/print/Xprinters
@@ -29,6 +29,13 @@
#Augment_Printer_List %none%
########################################################################
+# Preconfigured entry for the PSspooldir model
+# (which sends jobs to /tmp/Xprintjobs instead to a physical printer)
+########################################################################
+#Printer xp_pdf_spooldir_tmp_Xprintjobs
+Printer xp_ps_spooldir_tmp_Xprintjobs
+
+########################################################################
# Add individual printers to the list of printers managed by the
# server. These are aliases, determined by driver name.
########################################################################
@@ -40,4 +47,3 @@
# Printer xppclpr
# Printer xppclmonopr
# Printer xprasterpr
-
diff --git a/XpConfig/C/print/attributes/document b/XpConfig/C/print/attributes/document
index e0be64553..b1651bd94 100644
--- a/XpConfig/C/print/attributes/document
+++ b/XpConfig/C/print/attributes/document
@@ -20,10 +20,21 @@
*content-orientation: portrait
*copy-count: 1
*default-medium: iso-a4
-*default-printer-resolution: 300
-*document-format: {Postscript 2}
-*plex: duplex
+*default-printer-resolution: 600
+# "PSspooldir" jobs should always be 300 DPI
+# (to be compatible to DPS-based PostScript viewers such as sdtimage)
+PSspooldir.default-printer-resolution: 300
+
+# "PS2PDFspooldir-GS" jobs should always be 600 DPI
+PS2PDFspooldir-GS.default-printer-resolution: 600
+
+# Some resolution defaults to make applications happy which are too lazy
+# to pick an own default in absence of "default-printer-resolution"
+HPLJ4050-PS.default-printer-resolution: 600
+SPSPARC2.default-printer-resolution: 300
+CANONBJ10E-GS.default-printer-resolution: 360
+CANONC3200-PS.default-printer-resolution: 600
# EXAMPLES
#
diff --git a/XpConfig/C/print/attributes/printer b/XpConfig/C/print/attributes/printer
index a49afa5f0..41e13b44b 100644
--- a/XpConfig/C/print/attributes/printer
+++ b/XpConfig/C/print/attributes/printer
@@ -16,8 +16,24 @@
# Set this attribute for all printers.
# Example: "*.document-formats-ready: {pcl 5}"
+# Remove this line and replace them with per printer settings
+# if you want to use more than one DDX!!
+*xp-model-identifier: PSdefault
-*xp-ddx-identifier: XP-POSTSCRIPT
+
+# Sample entry for the "PSspooldir" model
+# Just add a printer called "xp_ps_spooldir_tmp_Xprintjobs" to "Xprinters"
+# and you will get an extra printer which files the PostScript jobs
+# in the "/tmp/Xprintjobs/" directory.
+xp_ps_spooldir_tmp_Xprintjobs.xp-model-identifier: PSspooldir
+
+# Sample entry for the "PS2PDFspooldir-GS" model
+# Just add a printer called "xp_pdf_spooldir_tmp_Xprintjobs" to "Xprinters"
+# and you will get an extra printer which convertes the PostScript jobs
+# to PDF using "ps2pdf" and files them into the "/tmp/Xprintjobs/" directory.
+# NOTE: Future versions of Xprint will use the PDF DDX instead directly
+# instead of relying on GhostScript/ps2pdf...
+xp_pdf_spooldir_tmp_Xprintjobs.xp-model-identifier: PS2PDFspooldir-GS
# IMPORTANT EXAMPLES
diff --git a/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias b/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias
index 1499aa845..e69de29bb 100644
--- a/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias
+++ b/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias
@@ -1 +0,0 @@
-! So the file isn't empty
diff --git a/XpConfig/C/print/models/HPDJ1600C/model-config b/XpConfig/C/print/models/HPDJ1600C/model-config
index f3bd8af3a..5d45d4495 100644
--- a/XpConfig/C/print/models/HPDJ1600C/model-config
+++ b/XpConfig/C/print/models/HPDJ1600C/model-config
@@ -1,28 +1,16 @@
-# $Xorg: model-config,v 1.3 2000/08/17 19:48:04 cpqbld Exp $
+# $Xprint.org: HPDJ1600C model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $
# This is the configuration file for the HP DeskJet 1600C printer.
#
# The CDEnext SI supports two 1600C drivers XP-PCL-MONO and
# XP-PCL-COLOR, which work with this configuration file.
#
-# Attribute IDs must be qualified using either the printer-model
-# identifier or an asterisk ('*'). For example, if "HPDJ1600C" is the
-# printer-model, then to initialize the 'plexes-supported' attribute
-# to 'simplex', use: "HPDJ1600C.plexes-supported: simplex". For the
-# asterisk, use: "*.plexes-supported: simplex". If the same attribute
-# is specified using each method, the printer-model qualified entry
-# takes precedence.
-
-HPDJ1600C.printer-model: "Hewlett-Packard DeskJet 1600C"
-HPDJ1600C.printer-resolutions-supported: 300
-HPDJ1600C.content-orientations-supported: portrait landscape
-HPDJ1600C.document-formats-supported: {PCL 5} {PostScript 2}
-HPDJ1600C.plexes-supported: simplex duplex
-HPDJ1600C.xp-ddx-identifier: XP-PCL-COLOR
-HPDJ1600C.xp-embedded-formats-supported: { PCL 5 } { PostScript 2 }
-HPDJ1600C.xp-setup-proviso: setup-optional
+*content-orientations-supported: portrait landscape
+*descriptor: Hewlett-Packard DeskJet 1600C
+*document-formats-supported: {PCL 5} {PostScript 2}
+*input-trays-supported:
# 1/4" unprintable margins
-HPDJ1600C.medium-source-sizes-supported:\
+*medium-source-sizes-supported:\
{ '' \
{na-letter FALSE {6.35 209.55 6.35 273.05}}\
{executive FALSE {6.35 177.75 6.35 260.35}}\
@@ -41,4 +29,12 @@ HPDJ1600C.medium-source-sizes-supported:\
{hp-japanese-postcard FALSE {6 94 6 142 }}\
{hp-japanese-doublepostcard FALSE {6 142 6 194 }}\
}
-
+*plexes-supported: simplex duplex
+*printer-model: "Hewlett-Packard DeskJet 1600C"
+*printer-resolutions-supported: 300
+*xp-ddx-identifier: XP-PCL-COLOR
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: { PCL 5 } { PostScript 2 }
+*xp-raw-formats-supported: { PCL 5 }
+*xp-setup-proviso: setup-optional
+# EOF.
diff --git a/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias b/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias
index 1499aa845..e69de29bb 100644
--- a/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias
+++ b/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias
@@ -1 +0,0 @@
-! So the file isn't empty
diff --git a/XpConfig/C/print/models/HPLJ4family/model-config b/XpConfig/C/print/models/HPLJ4family/model-config
index f69e25718..1ac997ebe 100644
--- a/XpConfig/C/print/models/HPLJ4family/model-config
+++ b/XpConfig/C/print/models/HPLJ4family/model-config
@@ -1,28 +1,15 @@
-# $Xorg: model-config,v 1.3 2000/08/17 19:48:04 cpqbld Exp $
+# $Xprint.org: HPLJ4family model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $
# This is the configuration file for the HP LaserJet 4 Printers.
#
# Though not a deliverable for the CDEnext SI, the XP-PCL-MONO
# driver should be able to support the LaserJet 4 printers.
#
-# Attribute IDs must be qualified using either the printer-model
-# identifier or an asterisk ('*'). For example, if "HPLJ4family" is the
-# printer-model, then to initialize the 'plexes-supported' attribute
-# to 'simplex', use: "HPLJ4family.plexes-supported: simplex". For the
-# asterisk, use: "*.plexes-supported: simplex". If the same attribute
-# is specified using each method, the printer-model qualified entry
-# takes precedence.
-
-HPLJ4family.printer-model: "Hewlett-Packard LaserJet 4 Series"
-HPLJ4family.printer-resolutions-supported: 300 600
-HPLJ4family.content-orientations-supported: portrait landscape
-HPLJ4family.document-formats-supported: {PCL 5} {PostScript 2}
-HPLJ4family.plexes-supported: simplex duplex
-HPLJ4family.xp-ddx-identifier: XP-PCL-MONO
-HPLJ4family.xp-embedded-formats-supported: { PCL 5 } { PostScript 2 }
-HPLJ4family.xp-setup-proviso: setup-optional
-
+*content-orientations-supported: portrait landscape
+*descriptor: Hewlett-Packard LaserJet 4 Series
+*document-formats-supported: {PCL 5} {PostScript 2}
+*input-trays-supported:
# 1/4" unprintable margins
-HPLJ4family.medium-source-sizes-supported:\
+*medium-source-sizes-supported:\
{ '' \
{na-letter FALSE {6.35 209.55 6.35 273.05}}\
{executive FALSE {6.35 177.75 6.35 260.35}}\
@@ -41,4 +28,12 @@ HPLJ4family.medium-source-sizes-supported:\
{hp-japanese-postcard FALSE {6 94 6 142 }}\
{hp-japanese-doublepostcard FALSE {6 142 6 194 }}\
}
-
+*plexes-supported: simplex duplex
+*printer-model: "Hewlett-Packard LaserJet 4 Series"
+*printer-resolutions-supported: 300 600
+*xp-ddx-identifier: XP-PCL-MONO
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: { PCL 5 } { PostScript 2 }
+*xp-raw-formats-supported: { PCL 5 }
+*xp-setup-proviso: setup-optional
+# EOF.
diff --git a/XpConfig/C/print/models/SPSPARC2/model-config b/XpConfig/C/print/models/SPSPARC2/model-config
index 959e9ff7b..9f29b9992 100644
--- a/XpConfig/C/print/models/SPSPARC2/model-config
+++ b/XpConfig/C/print/models/SPSPARC2/model-config
@@ -1,13 +1,18 @@
-# $Xorg: model-config,v 1.3 2000/08/17 19:48:04 cpqbld Exp $
-SPSPARC2.printer-model: "SunPics SPARCprinter II"
-SPSPARC2.printer-resolutions-supported: 300
-SPSPARC2.content-orientations-supported: portrait landscape
-SPSPARC2.document-formats-supported: {PostScript 2}
-SPSPARC2.plexes-supported: simplex
-SPSPARC2.xp-ddx-identifier: XP-POSTSCRIPT
-SPSPARC2.xp-embedded-formats-supported: { PostScript 2 }
-*xp-setup-proviso: setup-optional
-SPSPARC2.medium-source-sizes-supported: \
+# $Xprint.org: SPSPARC2 model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $
+*content-orientations-supported: portrait landscape
+*descriptor: SunPics SPARCprinter II
+*document-formats-supported: {POSTSCRIPT 2}
+*input-trays-supported:
+*medium-source-sizes-supported: \
{ '' {na-letter FALSE {6.35 209.55 6.35 273.05}} \
{na-legal FALSE {6.35 209.55 6.35 349.25}} \
{iso-a4 FALSE {6.35 203.65 6.35 290.65}}}
+*plexes-supported: simplex
+*printer-model: "SunPics SPARCprinter II"
+*printer-resolutions-supported: 300
+*xp-ddx-identifier: XP-POSTSCRIPT
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: {POSTSCRIPT 2}
+*xp-raw-formats-supported: {POSTSCRIPT 2}
+*xp-setup-proviso: setup-optional
+# EOF.
diff --git a/Xprint/AttrValid.c b/Xprint/AttrValid.c
index a3046c159..86bfd14e5 100644
--- a/Xprint/AttrValid.c
+++ b/Xprint/AttrValid.c
@@ -30,8 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/AttrValid.c,v 1.4 2001/01/17 22:36:27 dawes Exp $ */
-
#include <scrnintstr.h>
#include "attributes.h"
@@ -46,7 +44,7 @@ static XpOidMediumDiscreteSizeList DefaultMediumSizeList = {
&DefaultMediumSize, 1
};
static XpOidMediumSourceSize DefaultMediumSourceSize = {
- xpoid_unspecified, XpOidMediumSS_DISCRETE, { &DefaultMediumSizeList }
+ xpoid_unspecified, XpOidMediumSS_DISCRETE, &DefaultMediumSizeList
};
static XpOidMediumSS DefaultMediumSS = {
&DefaultMediumSourceSize, 1
@@ -298,7 +296,7 @@ XpPutMediumSSAttr(XpContextPtr pContext,
}
const XpOidMediumSS*
-XpGetDefaultMediumSS(void)
+XpGetDefaultMediumSS()
{
return &DefaultMediumSS;
}
diff --git a/Xprint/AttrValid.h b/Xprint/AttrValid.h
index 8e431c285..8e27ae01a 100644
--- a/Xprint/AttrValid.h
+++ b/Xprint/AttrValid.h
@@ -30,7 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/AttrValid.h,v 1.6 2001/10/31 22:50:27 tsi Exp $ */
#ifndef _Xp_AttrValid_h
#define _Xp_AttrValid_h
@@ -85,7 +84,7 @@ typedef struct
#define XpPutStringAttr(pContext, pool, oid, value) \
XpPutOneAttribute(pContext, pool, XpOidString(oid), value)
-#ifdef _XP_PRINT_SERVER_ /* needed for XpContextPtr in Printstr.h */
+#ifdef _XP_PRINT_SERVER_ /* needed for XpContextPtr in Printstr.h */
/*
* XpOid-valued attribute access
@@ -179,7 +178,7 @@ void XpPutMediumSSAttr(XpContextPtr pContext,
XPAttributes pool,
XpOid oid,
const XpOidMediumSS* msss);
-const XpOidMediumSS* XpGetDefaultMediumSS(void);
+const XpOidMediumSS* XpGetDefaultMediumSS();
/*
* XpOidTrayMediumList-valued attribute access
@@ -193,15 +192,12 @@ void XpPutTrayMediumListAttr(XpContextPtr pContext,
XPAttributes pool,
XpOid oid,
const XpOidTrayMediumList* tm);
-BOOL XpOidTrayMediumListHasTray(const XpOidTrayMediumList* list, XpOid tray);
-
/*
* Attribute pool validation
*/
void XpValidateAttributePool(XpContextPtr pContext,
XPAttributes pool,
const XpValidatePoolsRec* vpr);
-void XpValidateNotificationProfile(XpContextPtr pContext);
void XpValidatePrinterPool(XpContextPtr pContext,
const XpValidatePoolsRec* vpr);
void XpValidateJobPool(XpContextPtr pContext,
@@ -210,9 +206,6 @@ void XpValidateDocumentPool(XpContextPtr pContext,
const XpValidatePoolsRec* vpr);
void XpValidatePagePool(XpContextPtr pContext,
const XpValidatePoolsRec* vpr);
-void XpValidatePrinterMediaAttrs(XpContextPtr pContext,
- const XpOidList* valid_trays,
- const XpOidList* valid_sizes);
#endif /* _XP_PRINT_SERVER_ */
diff --git a/Xprint/DiPrint.h b/Xprint/DiPrint.h
index d6364af26..0b781f2fc 100644
--- a/Xprint/DiPrint.h
+++ b/Xprint/DiPrint.h
@@ -30,8 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/DiPrint.h,v 1.3 1999/12/16 02:26:24 robin Exp $ */
-
/*
* The XpDiListEntry struct is the type of each element of the array
* handed back to the extension code to handle a GetPrinterList request.
diff --git a/Xprint/Init.c b/Xprint/Init.c
index 0deafda7c..cd16847ee 100644
--- a/Xprint/Init.c
+++ b/Xprint/Init.c
@@ -2,11 +2,12 @@
/*
(c) Copyright 1996 Hewlett-Packard Company
(c) Copyright 1996 International Business Machines Corp.
-(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996-2004 Sun Microsystems, Inc.
(c) Copyright 1996 Novell, Inc.
(c) Copyright 1996 Digital Equipment Corp.
(c) Copyright 1996 Fujitsu Limited
(c) Copyright 1996 Hitachi, Ltd.
+(c) Copyright 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -50,7 +51,6 @@ copyright holders.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/Init.c,v 1.14tsi Exp $ */
#include <unistd.h>
#include <stdlib.h>
@@ -91,6 +91,7 @@ typedef char *XPointer;
#include "attributes.h"
#include "os.h"
+#include "spooler.h"
static void GenericScreenInit(
int index,
@@ -116,57 +117,6 @@ static Bool InitPrintDrivers(
#define MODELDIRNAME "/models"
#define FONTDIRNAME "/fonts"
-/*
- * The string LIST_QUEUES is fed to a shell to generate an ordered
- * list of available printers on the system. These string definitions
- * are taken from the file PrintSubSys.C within the code for the
- * dtprintinfo program.
- */
-#ifdef AIXV4
-const char *LIST_QUEUES = "lsallq | grep -v '^bsh$' | sort";
-#else
-#ifdef hpux
-const char *LIST_QUEUES = "LANG=C lpstat -v | "
- "awk '"
- " $2 == \"for\" "
- " { "
- " x = match($3, /:/); "
- " print substr($3, 1, x-1)"
- " }' | sort";
-#else
-#ifdef __osf__
- const char *LIST_QUEUES = "LANG=C lpstat -v | "
- "nawk '"
- " $2 == \"for\" "
- " { print $4 }' "
- " | sort";
-#else
-#ifdef __uxp__
-const char *LIST_QUEUES = "LANG=C lpstat -v | "
- "nawk '"
- " $4 == \"for\" "
- " { "
- " x = match($5, /:/); "
- " print substr($5, 1, x-1)"
- " }' | sort";
-#else
-#if defined(CSRG_BASED) || defined(linux) || defined(ISC) || defined(__GNUC__)
-const char *LIST_QUEUES = "LANG=C lpc status | grep -v '^\t' | "
- "sed -e /:/s/// | sort";
-#else
-const char *LIST_QUEUES = "LANG=C lpstat -v | "
- "nawk '"
- " $2 == \"for\" "
- " { "
- " x = match($3, /:/); "
- " print substr($3, 1, x-1)"
- " }' | sort";
-#endif
-#endif
-#endif
-#endif
-#endif
-
#ifdef XPRASTERDDX
static
@@ -183,9 +133,9 @@ PixmapFormatRec RasterPixmapFormats[] = {
static
PixmapFormatRec ColorPclPixmapFormats[] = {
- { 1, 1, BITMAP_SCANLINE_PAD },
- { 8, 8, BITMAP_SCANLINE_PAD },
- { 24,32, BITMAP_SCANLINE_PAD }
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 24, 32, BITMAP_SCANLINE_PAD }
};
#define NUMCPCLFORMATS (sizeof ColorPclPixmapFormats)/(sizeof ColorPclPixmapFormats[0])
@@ -211,9 +161,9 @@ PixmapFormatRec MonoPclPixmapFormats[] = {
static
PixmapFormatRec PSPixmapFormats[] = {
- { 1, 1, BITMAP_SCANLINE_PAD },
- { 8, 8, BITMAP_SCANLINE_PAD },
- { 24,32, BITMAP_SCANLINE_PAD }
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 24, 32, BITMAP_SCANLINE_PAD }
};
#define NUMPSFORMATS (sizeof PSPixmapFormats)/(sizeof PSPixmapFormats[0])
@@ -296,6 +246,7 @@ typedef struct _printerDbEntry {
char *qualifier;
int screenNum;
char *driverName;
+ char *desc;
} PrinterDbEntry, *PrinterDbPtr;
static PrinterDbPtr printerDb = (PrinterDbPtr)NULL;
@@ -325,10 +276,82 @@ typedef struct _driverMapping {
int screenNum;
} DriverMapEntry, *DriverMapPtr;
+static const char configFilePath[] =
+"/etc/dt/config/print:/usr/dt/config/print";
+
+static const char printServerConfigDir[] = "XPSERVERCONFIGDIR";
+
+static int printScreenPrivIndex,
+ printWindowPrivIndex,
+ printGCPrivIndex;
+static unsigned long printGeneration = 0;
static char *configFileName = (char *)NULL;
static Bool freeDefaultFontPath = FALSE;
static char *origFontPath = (char *)NULL;
+static Bool xprintInitGlobalsCalled = FALSE;
+/*
+ * This function is responsible for doing initalisation of any global
+ * variables at an very early point of server startup (even before
+ * |ProcessCommandLine()|.
+ */
+void XprintInitGlobals(void)
+{
+ extern char dispatchExceptionAtReset; /* defined in Xserver/dix/dispatch.c */
+
+ xprintInitGlobalsCalled = TRUE;
+
+#ifdef SMART_SCHEDULE
+ /* Somehow the XF86 "smart scheduler" completely kills the Xprint DDX
+ * (see http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=467
+ * ("Xfree86's "smart scheduler" breaks Xprt") */
+ SmartScheduleDisable = TRUE;
+#endif /* SMART_SCHEDULE */
+
+ /* Disable internal screensaver for Xprint (workaround for
+ * http://pdx.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=567 ("Xorg
+ * Xprt starts to consume 100% CPU when being idle for some time")) */
+ defaultScreenSaverTime = 0;
+
+ /* Ensure that the maximum request size for the BIGREQUESTS extension
+ * is at least 8MB (see
+ * http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=622 - "RFE:
+ * Xprt's default BIGREQUESTS extension buffer size should be 8MB")
+ */
+ maxBigRequestSize = (8*1048576)-1;
+
+ /* Xprt should not reset by default when the last client exists
+ * (default for Xprt is |0|, video Xservers use |DE_RESET|) */
+ dispatchExceptionAtReset = 0;
+}
+
+/*
+ * XprintUseMsg() prints usage for the Xprint-specific options
+ */
+void XprintUseMsg()
+{
+ XpSpoolerTypePtr curr = xpstm;
+
+ /* Option '-XpFile' */
+ ErrorF("-XpFile file specifies an alternate `Xprinters' file, rather\n");
+ ErrorF(" than the default one (e.g.\n");
+ ErrorF(" `${XPCONFIGDIR}/${LANG}/print/Xprinters') or\n");
+ ErrorF(" `${XPCONFIGDIR}/C/print/Xprinters'.\n");
+
+ /* Option '-XpSpoolerType' */
+ ErrorF("-XpSpoolerType string specifies a spooler type.\n");
+ ErrorF(" Supported values are:\n");
+
+ while( curr->name != NULL )
+ {
+ ErrorF(" - '%s'\n", curr->name);
+ curr++;
+ }
+ ErrorF(" (multiple values can be specified, seperated by ':',\n");
+ ErrorF(" the first active spooler will be chosen).\n");
+ ErrorF(" default is '%s'.\n", XPDEFAULTSPOOLERNAMELIST);
+}
+
/*
* XprintOptions checks argv[i] to see if it is our command line
* option specifying a configuration file name. It returns the index
@@ -340,6 +363,7 @@ XprintOptions(
char **argv,
int i)
{
+ extern void ddxUseMsg();
if(strcmp(argv[i], "-XpFile") == 0)
{
if ((i + 1) >= argc) {
@@ -349,8 +373,19 @@ XprintOptions(
configFileName = argv[i + 1];
return i + 2;
}
+ else if(strcmp(argv[i], "-XpSpoolerType") == 0)
+ {
+ if ((i + 1) >= argc) {
+ ddxUseMsg ();
+ return i + 2;
+ }
+ XpSetSpoolerTypeNameList(argv[i + 1]);
+ return i + 2;
+ }
else
+ {
return i;
+ }
}
/************************************************************
@@ -417,19 +452,21 @@ FreePrinterDb(void)
{
PrinterDbPtr pCurEntry, pNextEntry;
- for(pCurEntry = printerDb, pNextEntry = 0;
+ for(pCurEntry = printerDb, pNextEntry = (PrinterDbPtr)NULL;
pCurEntry != (PrinterDbPtr)NULL; pCurEntry = pNextEntry)
{
pNextEntry = pCurEntry->next;
if(pCurEntry->name != (char *)NULL)
xfree(pCurEntry->name);
+ if(pCurEntry->desc != (char *)NULL)
+ xfree(pCurEntry->desc);
/*
* We don't free the driver name, because it's expected to simply
* be a pointer into the xrm database.
*/
xfree(pCurEntry);
}
- printerDb = 0;
+ printerDb = (PrinterDbPtr)NULL;
}
/*
@@ -439,12 +476,13 @@ FreePrinterDb(void)
* XXX AddPrinterDbName needs to check for (and not add) duplicate names.
*/
static Bool
-AddPrinterDbName(char *name)
+AddPrinterDbName(char *name, char *desc)
{
PrinterDbPtr pEntry = (PrinterDbPtr)xalloc(sizeof(PrinterDbEntry));
if(pEntry == (PrinterDbPtr)NULL) return FALSE;
- pEntry->name = strdup(name);
+ pEntry->name = (name != NULL) ? strdup(name) : NULL;
+ pEntry->desc = (desc != NULL) ? strdup(desc) : NULL;
pEntry->qualifier = (char *)NULL;
if(printerDb == (PrinterDbPtr)NULL)
@@ -460,20 +498,45 @@ AddPrinterDbName(char *name)
return TRUE;
}
-static void
+static int
AugmentPrinterDb(const char *command)
{
FILE *fp;
char name[256];
+ int num_printers = 0; /* Number of printers we found */
+ size_t namelen;
+ char *desc = NULL;
fp = popen(command, "r");
/* XXX is a 256 character limit overly restrictive for printer names? */
- while(fgets(name, 256, fp) != (char *)NULL && strlen(name))
+ while(fgets(name, 256, fp) != (char *)NULL && (namelen=strlen(name)))
{
- name[strlen(name) - 1] = (char)'\0'; /* strip the \n */
- AddPrinterDbName(name);
+ char *option = name;
+
+ name[namelen-1] = (char)'\0'; /* strip the \n */
+
+#define XP_DESCRIPTOR "xp-printerattr.descriptor="
+#define XP_DESCRIPTOR_LEN (sizeof(XP_DESCRIPTOR)-1)
+ while (option = strchr(option, '\t')) {
+ option++; /* Skip the '\t' */
+ if (!strncmp(option, XP_DESCRIPTOR, XP_DESCRIPTOR_LEN)) {
+ *(option-1) = '\0'; /* Kill the '\t' (only if we found a valid option) */
+ option += XP_DESCRIPTOR_LEN;
+ if (*option != '\0') {
+ desc = option;
+ }
+ }
+ else
+ {
+ /* Unknown option */
+ ErrorF("AugmentPrinterDb: Unknown option '%s'\n", option);
+ }
+ }
+ AddPrinterDbName(name, desc);
+ num_printers++;
}
pclose(fp);
+ return num_printers;
}
/*
@@ -592,7 +655,7 @@ StoreDriverNames(void)
"xp-ddx-identifier");
if(pEntry->driverName == (char *)NULL ||
strlen(pEntry->driverName) == 0 ||
- GetInitFunc(pEntry->driverName) == 0)
+ GetInitFunc(pEntry->driverName) == (Bool(*)())NULL)
{
if (pEntry->driverName && (strlen(pEntry->driverName) != 0)) {
ErrorF("Xp Extension: Can't load driver %s\n",
@@ -609,6 +672,29 @@ StoreDriverNames(void)
}
}
+/*
+ * StoreDescriptors - queries the attribute store for the descriptor.
+ * if the descriptor is not in the attribute database, then the descriptor
+ * from the printerDb is store in the attribute store for the printer.
+ */
+static void
+StoreDescriptors()
+{
+ PrinterDbPtr pEntry;
+
+ for(pEntry = printerDb; pEntry != (PrinterDbPtr)NULL;
+ pEntry = pEntry->next)
+ {
+ if (pEntry->desc != NULL)
+ {
+ XpAddPrinterAttribute(pEntry->name,
+ (pEntry->qualifier != (char *)NULL)?
+ pEntry->qualifier : pEntry->name,
+ "*descriptor", pEntry->desc);
+ }
+ }
+}
+
static char *
MbStrchr(
char *str,
@@ -650,7 +736,7 @@ GetConfigFileName(void)
/*
* Check for a LANG-specific file.
*/
- if ((dirName = XpGetConfigDir(TRUE)) != 0)
+ if(dirName = XpGetConfigDir(TRUE))
{
filePath = (char *)xalloc(strlen(dirName) +
strlen(XPRINTERSFILENAME) + 2);
@@ -669,7 +755,7 @@ GetConfigFileName(void)
xfree(filePath);
}
- if ((dirName = XpGetConfigDir(FALSE)) != 0)
+ if(dirName = XpGetConfigDir(FALSE))
{
filePath = (char *)xalloc(strlen(dirName) +
strlen(XPRINTERSFILENAME) + 2);
@@ -701,6 +787,7 @@ GetConfigFileName(void)
static PrinterDbPtr
BuildPrinterDb(void)
{
+ char *printerList, *augmentCmd = (char *)NULL;
Bool defaultAugment = TRUE, freeConfigFileName;
if(configFileName && access(configFileName, R_OK) != 0)
@@ -727,9 +814,9 @@ BuildPrinterDb(void)
{
while((tok = strtok((char *)NULL, " \t")) != (char *)NULL)
{
- if ((ptr = MbStrchr(tok, '\012')) != 0)
+ if(ptr = MbStrchr(tok, '\012'))
*ptr = (char)'\0';
- AddPrinterDbName(tok);
+ AddPrinterDbName(tok, NULL);
}
}
else if(strcmp(tok, "Map") == 0)
@@ -768,7 +855,43 @@ BuildPrinterDb(void)
if(defaultAugment == TRUE)
{
- AugmentPrinterDb(LIST_QUEUES);
+ XpSpoolerTypePtr curr_spooler_type; /* spooler we are currently probing for queues */
+ int num_printers_found; /* number of printers found by |AugmentPrinterDb()| */
+ char *tok_lasts; /* strtok_r() position token */
+ char *spnamelist; /* list of spooler names, seperated by ":" */
+ char *spname; /* spooler name */
+
+ spnamelist = strdup(XpGetSpoolerTypeNameList()); /* strtok_r() modifies string so dup' it first */
+
+ for( spname = strtok_r(spnamelist, ":", &tok_lasts) ;
+ spname != NULL ;
+ spname = strtok_r(NULL, ":", &tok_lasts) )
+ {
+ curr_spooler_type = XpSpoolerNameToXpSpoolerType(spname);
+ if(!curr_spooler_type)
+ {
+ FatalError("BuildPrinterDb:No spooler type entry found for '%s'.\n", spname);
+ }
+
+ if(curr_spooler_type->list_queues_command == NULL ||
+ strlen(curr_spooler_type->list_queues_command) == 0)
+ {
+ continue;
+ }
+
+ num_printers_found = AugmentPrinterDb(curr_spooler_type->list_queues_command);
+ /* Did we found a spooler which works ? */
+ if(num_printers_found > 0)
+ {
+ spooler_type = curr_spooler_type;
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "BuildPrinterDb: using '%s'.\n", spooler_type->name);
+#endif /* DEBUG_gisburn */
+ break;
+ }
+ }
+
+ free(spnamelist);
}
MergeNameMap();
@@ -782,6 +905,7 @@ BuildPrinterDb(void)
* in the printerDb
*/
StoreDriverNames();
+ StoreDescriptors();
if(freeConfigFileName)
{
@@ -951,7 +1075,7 @@ FindFontDir(
return (char *)NULL;
configDir = XpGetConfigDir(TRUE);
- if ((fontDir = ValidateFontDir(configDir, modelName)) != 0)
+ if(fontDir = ValidateFontDir(configDir, modelName))
{
xfree(configDir);
return fontDir;
@@ -1013,8 +1137,8 @@ AddToFontPath(
static void
AugmentFontPath(void)
{
- char *modelID, **allIDs = (char **)NULL;
- PrinterDbPtr pDbEntry;
+ char *newPath, *modelID, **allIDs = (char **)NULL;
+ PrinterDbPtr pDb, pDbEntry;
int numModels, i;
if(!origFontPath)
@@ -1072,7 +1196,7 @@ AugmentFontPath(void)
for(i = 0; allIDs != (char **)NULL && allIDs[i] != (char *)NULL; i ++)
{
char *fontDir;
- if ((fontDir = FindFontDir(allIDs[i])) != 0)
+ if(fontDir = FindFontDir(allIDs[i]))
{
AddToFontPath(fontDir);
xfree(fontDir);
@@ -1162,7 +1286,7 @@ XpClientIsPrintClient(
* fpe->name.
*/
if(fpe->name_length < PATH_PREFIX_LEN ||
- (strlen(fontDir) != (unsigned)(fpe->name_length - PATH_PREFIX_LEN)) ||
+ (strlen(fontDir) != (fpe->name_length - PATH_PREFIX_LEN)) ||
strncmp(fontDir, fpe->name + PATH_PREFIX_LEN,
fpe->name_length - PATH_PREFIX_LEN))
{
@@ -1235,6 +1359,38 @@ PrinterInitOutput(
char **driverNames;
char *configDir;
+ /* This should NEVER happen, but... */
+ if( !xprintInitGlobalsCalled )
+ {
+ FatalError("Internal error: XprintInitGlobals() not called.");
+ }
+#ifdef SMART_SCHEDULE
+ /* |XprintInitGlobals| should have set |SmartScheduleDisable| to
+ * |TRUE| - if not we will trigger this safeguard. */
+ if( SmartScheduleDisable != TRUE )
+ {
+ FatalError("Internal error: XF86 smart scheduler incompatible to Xprint DDX.");
+ }
+#endif /* SMART_SCHEDULE */
+ /* Safeguard for
+ * http://pdx.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=567 ("Xorg
+ * Xprt starts to consume 100% CPU when being idle for some time")
+ * |XprintInitGlobals| should have set |defaultScreenSaverTime| to
+ * |0| - if not we will trigger this trap. */
+ if( defaultScreenSaverTime != 0 )
+ {
+ FatalError("Internal screen saver must be OFF for printing.");
+ }
+
+ /* Print a warnung when the maximum request size of the BIGREQUESTS
+ * extension is smaller than 8MB (see
+ * http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=622)
+ */
+ if (maxBigRequestSize < (8*1048576)-1) {
+ ErrorF("Xp Extension: BIGREQUESTS max. request is currently %ld bytes "
+ ", recommemded minimum for Xprint is 8MB.\n", (long)maxBigRequestSize);
+ }
+
/*
* this little test is just a warning at startup to make sure
* that the config directory exists.
@@ -1254,10 +1410,9 @@ PrinterInitOutput(
xfree(configDir);
}
else {
- ErrorF("Xp Extension: could not find config dir %s\n",
- configDir ? configDir : XPRINTDIR);
-
- if (configDir) xfree(configDir);
+ /* Refuse to start when we do not have our config dir... */
+ FatalError("Xp Extension: could not find config dir %s\n",
+ configDir ? configDir : XPRINTDIR);
}
if(printerDb != (PrinterDbPtr)NULL)
@@ -1414,7 +1569,7 @@ InitPrintDrivers(
}
if(callInit == TRUE)
{
- pBFunc initFunc;
+ Bool (*initFunc)();
initFunc = GetInitFunc(pDb->driverName);
if(initFunc(index, pScreen, argc, argv) == FALSE)
{
@@ -1451,9 +1606,10 @@ GenericScreenInit(
int argc,
char **argv)
{
+ int i;
float fWidth, fHeight, maxWidth, maxHeight;
unsigned short width, height;
- PrinterDbPtr pDb;
+ PrinterDbPtr pDb, pDb2;
int res, maxRes;
/*
@@ -1477,6 +1633,7 @@ GenericScreenInit(
{
if(pDb->screenNum == index)
{
+
XpValidatePoolsRec *pValRec;
pVFunc dimensionsFunc;
@@ -1506,6 +1663,57 @@ GenericScreenInit(
}
/*
+ * QualifyName - takes an unqualified file name such as X6printers and
+ * a colon-separated list of directory path names such as
+ * /etc/opt/dt:/opt/dt/config.
+ *
+ * Returns a fully qualified file path name such as /etc/opt/dt/X6printers.
+ * The returned value is malloc'd, and the caller is responsible for
+ * freeing the associated memory.
+ */
+static char *
+QualifyName(fileName, searchPath)
+ char *fileName;
+ char *searchPath;
+{
+ char * curPath = searchPath;
+ char * nextPath;
+ char * chance;
+ FILE *pFile;
+
+ if (fileName == NULL || searchPath == NULL)
+ return NULL;
+
+ while (1) {
+ if ((nextPath = strchr(curPath, ':')) != NULL)
+ *nextPath = 0;
+
+ chance = (char *)xalloc(strlen(curPath) + strlen(fileName) + 2);
+ sprintf(chance,"%s/%s",curPath,fileName);
+
+ /* see if we can read from the file */
+ if((pFile = fopen(chance, "r")) != (FILE *)NULL)
+ {
+ fclose(pFile);
+ /* ... restore the colon, .... */
+ if (nextPath)
+ *nextPath = ':';
+
+ return chance;
+ }
+
+ xfree(chance);
+
+ if (nextPath == NULL) /* End of path list? */
+ break;
+
+ /* try the next path */
+ curPath = nextPath + 1;
+ }
+ return NULL;
+}
+
+/*
* FillPrinterListEntry fills in a single XpDiListEntry element with data
* derived from the supplied PrinterDbPtr element.
*
@@ -1548,12 +1756,11 @@ GetPrinterListInfo(
int localeLen,
char *locale)
{
- PrinterDbPtr pDb;
+ PrinterDbPtr pDb, pDb2;
for(pDb = printerDb; pDb != (PrinterDbPtr)NULL; pDb = pDb->next)
{
- if (strlen(pDb->name) == (unsigned)nameLen
- && !strncmp(pDb->name, name, nameLen))
+ if(strlen(pDb->name) == nameLen && !strncmp(pDb->name, name, nameLen))
{
FillPrinterListEntry(pEntry, pDb, localeLen, locale);
return TRUE;
@@ -1598,7 +1805,7 @@ XpDiGetPrinterList(
if(!nameLen || name == (char *)NULL)
{
int i;
- PrinterDbPtr pDb;
+ PrinterDbPtr pDb, pDb2;
for(pDb = printerDb, i = 0; pDb != (PrinterDbPtr)NULL;
pDb = pDb->next, i++)
@@ -1648,11 +1855,12 @@ WindowPtr
XpDiValidatePrinter(char *printerName, int printerNameLen)
{
PrinterDbPtr pCurEntry;
+ WindowPtr pWin;
for(pCurEntry = printerDb;
pCurEntry != (PrinterDbPtr)NULL; pCurEntry = pCurEntry->next)
{
- if(strlen(pCurEntry->name) == (unsigned)printerNameLen &&
+ if(strlen(pCurEntry->name) == printerNameLen &&
!strncmp(pCurEntry->name, printerName, printerNameLen))
return WindowTable[pCurEntry->screenNum];
}
@@ -1680,3 +1888,4 @@ XpDiGetDriverName(int index, char *printerName)
return (char *)NULL; /* XXX Should we supply a default driverName? */
}
+
diff --git a/Xprint/Oid.c b/Xprint/Oid.c
index 311d177d0..32be3efb1 100644
--- a/Xprint/Oid.c
+++ b/Xprint/Oid.c
@@ -30,7 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/Oid.c,v 1.5tsi Exp $ */
#include "attributes.h"
@@ -274,7 +273,7 @@ XpOidParse(const char* value_string,
*/
if(ptr_return != (const char**)NULL)
*ptr_return = ptr+length;
- return (XpOid)i;
+ return i;
}
/*
@@ -751,7 +750,7 @@ XpOidLinkedListFirstOid(XpOidLinkedList* me)
XpOid
XpOidLinkedListNextOid(XpOidLinkedList* me)
{
- if(me->current ? (me->current = me->current->next) != 0 : xFalse)
+ if(me->current ? me->current = me->current->next : xFalse)
return me->current->oid;
else
return xpoid_none;
@@ -1652,6 +1651,8 @@ TrayMediumListValidate(XpOidTrayMediumList* me,
const XpOidMediumSS* msss)
{
int i_mss, i_ds, i_itm;
+ XpOidMediumDiscreteSizeList* ds_list;
+ int tray_count;
XpOid current_tray, current_medium;
XpOidMediumDiscreteSizeList* unspecified_tray_ds;
XpOidMediumDiscreteSizeList* tray_ds;
@@ -1711,7 +1712,6 @@ TrayMediumListValidate(XpOidTrayMediumList* me,
* list
*/
if(tray_ds == (XpOidMediumDiscreteSizeList*)NULL)
- {
if(unspecified_tray_ds == (XpOidMediumDiscreteSizeList*)NULL)
{
/*
@@ -1722,10 +1722,7 @@ TrayMediumListValidate(XpOidTrayMediumList* me,
continue;
}
else
- {
tray_ds = unspecified_tray_ds;
- }
- }
/*
* loop through the discrete sizes list, looking for a size that
* matches the medium for the current input tray
@@ -2107,13 +2104,15 @@ const char* XpOidNotifyString(XpOidNotify notify)
{
switch(notify)
{
- default:
case XPOID_NOTIFY_UNSUPPORTED:
return (const char*)NULL;
+ break;
case XPOID_NOTIFY_NONE:
return NOTIFY_NONE_STR;
+ break;
case XPOID_NOTIFY_EMAIL:
return NOTIFY_EMAIL_STR;
+ break;
}
}
@@ -2238,7 +2237,7 @@ XpOidDocFmtNext(XpOidDocFmt* doc_fmt,
const char* first_nonws_ptr;
const char* format;
const char* variant;
- const char* version = 0;
+ const char* version;
int format_len;
int variant_len;
int version_len;
@@ -2551,12 +2550,10 @@ XpOidDocFmtListHasFmt(const XpOidDocFmtList* list,
* variants must both be NULL or match
*/
if(fmt->variant == (char*)NULL)
- {
if(list->list[i].variant == (char*)NULL)
return xTrue;
else
continue;
- }
if(list->list[i].variant == (char*)NULL)
continue;
if(strcmp(fmt->variant, list->list[i].variant) != 0)
@@ -2565,12 +2562,10 @@ XpOidDocFmtListHasFmt(const XpOidDocFmtList* list,
* versions must both be NULL or match
*/
if(fmt->version == (char*)NULL)
- {
if(list->list[i].version == (char*)NULL)
return xTrue;
else
continue;
- }
if(list->list[i].version == (char*)NULL)
continue;
if(strcmp(fmt->version, list->list[i].version) == 0)
diff --git a/Xprint/Oid.h b/Xprint/Oid.h
index e2a97869f..70bd8d3e5 100644
--- a/Xprint/Oid.h
+++ b/Xprint/Oid.h
@@ -30,7 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/Oid.h,v 1.3 1999/12/16 02:26:24 robin Exp $ */
#ifndef _Xp_Oid_h
#define _Xp_Oid_h
@@ -206,7 +205,7 @@ char* XpOidListString(const XpOidList*);
/*
* XpOidLinkedList public methods
*/
-XpOidLinkedList* XpOidLinkedListNew(void);
+XpOidLinkedList* XpOidLinkedListNew();
void XpOidLinkedListDelete(XpOidLinkedList*);
#define XpOidLinkedListCount(l) ((l) ? (l)->count : 0)
XpOid XpOidLinkedListGetOid(XpOidLinkedList* list, int i);
diff --git a/Xprint/OidDefs.h b/Xprint/OidDefs.h
index 03e530cb2..55b6568f0 100644
--- a/Xprint/OidDefs.h
+++ b/Xprint/OidDefs.h
@@ -133,6 +133,14 @@ typedef enum {
xpoid_val_medium_size_jis_b8,
xpoid_val_medium_size_jis_b9,
xpoid_val_medium_size_jis_b10,
+ xpoid_val_medium_size_hp_2x_postcard,
+ xpoid_val_medium_size_hp_european_edp,
+ xpoid_val_medium_size_hp_mini,
+ xpoid_val_medium_size_hp_postcard,
+ xpoid_val_medium_size_hp_tabloid,
+ xpoid_val_medium_size_hp_us_edp,
+ xpoid_val_medium_size_hp_us_government_legal,
+ xpoid_val_medium_size_hp_us_government_letter,
xpoid_val_plex_simplex,
xpoid_val_plex_duplex,
xpoid_val_plex_tumble,
diff --git a/Xprint/OidStrs.h b/Xprint/OidStrs.h
index 6489ae533..1792a6e16 100644
--- a/Xprint/OidStrs.h
+++ b/Xprint/OidStrs.h
@@ -30,140 +30,144 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/OidStrs.h,v 1.4 2001/01/17 22:36:28 dawes Exp $ */
+/* This is an automatically-generated file. Do not edit. */
static int XpOidStringMapCount = 127;
-#define OIDATA(name) { name, sizeof(name)-1, 0, 0, 0 }
-
static const XpOidStringMapEntry XpOidStringMap[] = {
- OIDATA(""),
- OIDATA(""),
- OIDATA("descriptor"),
- OIDATA("content-orientation"),
- OIDATA("copy-count"),
- OIDATA("default-printer-resolution"),
- OIDATA("default-input-tray"),
- OIDATA("default-medium"),
- OIDATA("document-format"),
- OIDATA("plex"),
- OIDATA("xp-listfonts-modes"),
- OIDATA("job-name"),
- OIDATA("job-owner"),
- OIDATA("notification-profile"),
- OIDATA("xp-setup-state"),
- OIDATA("xp-spooler-command-options"),
- OIDATA("content-orientations-supported"),
- OIDATA("document-formats-supported"),
- OIDATA("dt-pdm-command"),
- OIDATA("input-trays-medium"),
- OIDATA("medium-source-sizes-supported"),
- OIDATA("plexes-supported"),
- OIDATA("printer-model"),
- OIDATA("printer-name"),
- OIDATA("printer-resolutions-supported"),
- OIDATA("xp-embedded-formats-supported"),
- OIDATA("xp-listfonts-modes-supported"),
- OIDATA("xp-page-attributes-supported"),
- OIDATA("xp-raw-formats-supported"),
- OIDATA("xp-setup-proviso"),
- OIDATA("document-attributes-supported"),
- OIDATA("job-attributes-supported"),
- OIDATA("locale"),
- OIDATA("multiple-documents-supported"),
- OIDATA("available-compression"),
- OIDATA("available-compressions-supported"),
- OIDATA("portrait"),
- OIDATA("landscape"),
- OIDATA("reverse-portrait"),
- OIDATA("reverse-landscape"),
- OIDATA("iso-a0"),
- OIDATA("iso-a1"),
- OIDATA("iso-a2"),
- OIDATA("iso-a3"),
- OIDATA("iso-a4"),
- OIDATA("iso-a5"),
- OIDATA("iso-a6"),
- OIDATA("iso-a7"),
- OIDATA("iso-a8"),
- OIDATA("iso-a9"),
- OIDATA("iso-a10"),
- OIDATA("iso-b0"),
- OIDATA("iso-b1"),
- OIDATA("iso-b2"),
- OIDATA("iso-b3"),
- OIDATA("iso-b4"),
- OIDATA("iso-b5"),
- OIDATA("iso-b6"),
- OIDATA("iso-b7"),
- OIDATA("iso-b8"),
- OIDATA("iso-b9"),
- OIDATA("iso-b10"),
- OIDATA("na-letter"),
- OIDATA("na-legal"),
- OIDATA("executive"),
- OIDATA("folio"),
- OIDATA("invoice"),
- OIDATA("ledger"),
- OIDATA("quarto"),
- OIDATA("iso-c3"),
- OIDATA("iso-c4"),
- OIDATA("iso-c5"),
- OIDATA("iso-c6"),
- OIDATA("iso-designated-long"),
- OIDATA("na-10x13-envelope"),
- OIDATA("na-9x12-envelope"),
- OIDATA("na-number-10-envelope"),
- OIDATA("na-7x9-envelope"),
- OIDATA("na-9x11-envelope"),
- OIDATA("na-10x14-envelope"),
- OIDATA("na-number-9-envelope"),
- OIDATA("na-6x9-envelope"),
- OIDATA("na-10x15-envelope"),
- OIDATA("monarch-envelope"),
- OIDATA("a"),
- OIDATA("b"),
- OIDATA("c"),
- OIDATA("d"),
- OIDATA("e"),
- OIDATA("jis-b0"),
- OIDATA("jis-b1"),
- OIDATA("jis-b2"),
- OIDATA("jis-b3"),
- OIDATA("jis-b4"),
- OIDATA("jis-b5"),
- OIDATA("jis-b6"),
- OIDATA("jis-b7"),
- OIDATA("jis-b8"),
- OIDATA("jis-b9"),
- OIDATA("jis-b10"),
- OIDATA("simplex"),
- OIDATA("duplex"),
- OIDATA("tumble"),
- OIDATA("top"),
- OIDATA("middle"),
- OIDATA("bottom"),
- OIDATA("envelope"),
- OIDATA("manual"),
- OIDATA("large-capacity"),
- OIDATA("main"),
- OIDATA("side"),
- OIDATA("event-report-job-completed"),
- OIDATA("electronic-mail"),
- OIDATA("xp-setup-mandatory"),
- OIDATA("xp-setup-optional"),
- OIDATA("xp-setup-ok"),
- OIDATA("xp-setup-incomplete"),
- OIDATA("xp-list-glyph-fonts"),
- OIDATA("xp-list-internal-printer-fonts"),
- OIDATA("0"),
- OIDATA("01"),
- OIDATA("02"),
- OIDATA("03"),
- OIDATA("012"),
- OIDATA("013"),
- OIDATA("023"),
- OIDATA("0123")
+ { "", 0 },
+ { "", 0 },
+ { "descriptor", 10 },
+ { "content-orientation", 19 },
+ { "copy-count", 10 },
+ { "default-printer-resolution", 26 },
+ { "default-input-tray", 18 },
+ { "default-medium", 14 },
+ { "document-format", 15 },
+ { "plex", 4 },
+ { "xp-listfonts-modes", 18 },
+ { "job-name", 8 },
+ { "job-owner", 9 },
+ { "notification-profile", 20 },
+ { "xp-setup-state", 14 },
+ { "xp-spooler-command-options", 26 },
+ { "content-orientations-supported", 30 },
+ { "document-formats-supported", 26 },
+ { "dt-pdm-command", 14 },
+ { "input-trays-medium", 18 },
+ { "medium-source-sizes-supported", 29 },
+ { "plexes-supported", 16 },
+ { "printer-model", 13 },
+ { "printer-name", 12 },
+ { "printer-resolutions-supported", 29 },
+ { "xp-embedded-formats-supported", 29 },
+ { "xp-listfonts-modes-supported", 28 },
+ { "xp-page-attributes-supported", 28 },
+ { "xp-raw-formats-supported", 24 },
+ { "xp-setup-proviso", 16 },
+ { "document-attributes-supported", 29 },
+ { "job-attributes-supported", 24 },
+ { "locale", 6 },
+ { "multiple-documents-supported", 28 },
+ { "available-compression", 21 },
+ { "available-compressions-supported", 32 },
+ { "portrait", 8 },
+ { "landscape", 9 },
+ { "reverse-portrait", 16 },
+ { "reverse-landscape", 17 },
+ { "iso-a0", 6 },
+ { "iso-a1", 6 },
+ { "iso-a2", 6 },
+ { "iso-a3", 6 },
+ { "iso-a4", 6 },
+ { "iso-a5", 6 },
+ { "iso-a6", 6 },
+ { "iso-a7", 6 },
+ { "iso-a8", 6 },
+ { "iso-a9", 6 },
+ { "iso-a10", 7 },
+ { "iso-b0", 6 },
+ { "iso-b1", 6 },
+ { "iso-b2", 6 },
+ { "iso-b3", 6 },
+ { "iso-b4", 6 },
+ { "iso-b5", 6 },
+ { "iso-b6", 6 },
+ { "iso-b7", 6 },
+ { "iso-b8", 6 },
+ { "iso-b9", 6 },
+ { "iso-b10", 7 },
+ { "na-letter", 9 },
+ { "na-legal", 8 },
+ { "executive", 9 },
+ { "folio", 5 },
+ { "invoice", 7 },
+ { "ledger", 6 },
+ { "quarto", 6 },
+ { "iso-c3", 6 },
+ { "iso-c4", 6 },
+ { "iso-c5", 6 },
+ { "iso-c6", 6 },
+ { "iso-designated-long", 19 },
+ { "na-10x13-envelope", 17 },
+ { "na-9x12-envelope", 16 },
+ { "na-number-10-envelope", 21 },
+ { "na-7x9-envelope", 15 },
+ { "na-9x11-envelope", 16 },
+ { "na-10x14-envelope", 17 },
+ { "na-number-9-envelope", 20 },
+ { "na-6x9-envelope", 15 },
+ { "na-10x15-envelope", 17 },
+ { "monarch-envelope", 16 },
+ { "a", 1 },
+ { "b", 1 },
+ { "c", 1 },
+ { "d", 1 },
+ { "e", 1 },
+ { "jis-b0", 6 },
+ { "jis-b1", 6 },
+ { "jis-b2", 6 },
+ { "jis-b3", 6 },
+ { "jis-b4", 6 },
+ { "jis-b5", 6 },
+ { "jis-b6", 6 },
+ { "jis-b7", 6 },
+ { "jis-b8", 6 },
+ { "jis-b9", 6 },
+ { "jis-b10", 7 },
+ { "hp-2x-postcard", 14 },
+ { "hp-european-edp", 15 },
+ { "hp-mini", 7 },
+ { "hp-postcard", 11 },
+ { "hp-tabloid", 10 },
+ { "hp-us-edp", 9 },
+ { "hp-us-government-legal", 22 },
+ { "hp-us-government-letter", 23 },
+ { "simplex", 7 },
+ { "duplex", 6 },
+ { "tumble", 6 },
+ { "top", 3 },
+ { "middle", 6 },
+ { "bottom", 6 },
+ { "envelope", 8 },
+ { "manual", 6 },
+ { "large-capacity", 14 },
+ { "main", 4 },
+ { "side", 4 },
+ { "event-report-job-completed", 26 },
+ { "electronic-mail", 15 },
+ { "xp-setup-mandatory", 18 },
+ { "xp-setup-optional", 17 },
+ { "xp-setup-ok", 11 },
+ { "xp-setup-incomplete", 19 },
+ { "xp-list-glyph-fonts", 19 },
+ { "xp-list-internal-printer-fonts", 30 },
+ { "0", 1 },
+ { "01", 2 },
+ { "02", 2 },
+ { "03", 2 },
+ { "012", 3 },
+ { "013", 3 },
+ { "023", 3 },
+ { "0123", 4 }
};
-
-#undef OIDATA
diff --git a/Xprint/attributes.c b/Xprint/attributes.c
index c75af1a88..8dd1b64cb 100644
--- a/Xprint/attributes.c
+++ b/Xprint/attributes.c
@@ -1,4 +1,3 @@
-/* $XdotOrg: xc/programs/Xserver/Xprint/attributes.c,v 1.1.4.3.4.1 2004/03/04 17:47:23 eich Exp $ */
/* $Xorg: attributes.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
/*
(c) Copyright 1996 Hewlett-Packard Company
@@ -45,18 +44,15 @@ copyright holders.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/attributes.c,v 1.20 2003/10/29 22:11:54 tsi Exp $ */
-#include <X11/Xproto.h>
+#include <Xproto.h>
#include <string.h>
#include <stdlib.h>
-#include <sys/types.h>
#include <sys/wait.h>
#include <pwd.h>
#if (defined(sun) && defined(SVR4)) || (defined(SCO))
#include <wchar.h>
#endif
-
#include "scrnintstr.h"
#include <X11/extensions/Printstr.h>
@@ -67,11 +63,13 @@ copyright holders.
#include "Xresource.h"
#include "Xrm.c"
+#include "spooler.h"
+
static XrmDatabase CopyDb(XrmDatabase inDb);
extern XrmDatabase XpSpoolerGetServerAttributes(void);
-static unsigned long attrGeneration = 0;
+static int attrGeneration = 0;
typedef struct {
XrmDatabase *pDb;
@@ -138,6 +136,26 @@ static const char XPMODELDIR[] = "/models";
static char NULL_STRING[] = "\0";
/*
+ * XpGetConfigDirBase returns a string containing the path name of the base
+ * where the print server configuration directory is localed.
+ */
+static
+char *XpGetConfigDirBase()
+{
+ char **configDir;
+
+ /*
+ * If the XPCONFIGDIR environment variable is not set, then use the
+ * compile-time constant XPRINTDIR. XPRINTDIR is passed in on the
+ * compile command line, and is defined in $(TOP)/config/cf/Project.tmpl.
+ */
+ if((configDir = getenv("XPCONFIGDIR")) == (char *)NULL)
+ configDir = XPRINTDIR;
+
+ return configDir;
+}
+
+/*
* XpGetConfigDir returns a string containing the path name of the print
* server configuration directory. If the useLocale parameter is False
* the it returns the path to the "/C" directory. If the useLocale
@@ -153,7 +171,12 @@ XpGetConfigDir(Bool useLocale)
if(useLocale == False) langDir = "/C";
else
{
- if((langName = getenv("LANG")) == (char *)NULL)
+ langName = getenv("LC_ALL");
+ if (langName == NULL) {
+ langName = getenv("LANG");
+ }
+
+ if(langName == (char *)NULL)
return (char *)NULL;
else
{
@@ -165,13 +188,7 @@ XpGetConfigDir(Bool useLocale)
}
}
- /*
- * If the XPCONFIGDIR environment variable is not set, then use the
- * compile-time constant XPRINTDIR. XPRINTDIR is passed in on the
- * compile command line, and is defined in $(TOP)/config/cf/Project.tmpl.
- */
- if((configDir = getenv("XPCONFIGDIR")) == (char *)NULL)
- configDir = XPRINTDIR;
+ configDir = XpGetConfigDirBase();
dirName = (char *)xalloc(strlen(configDir) + strlen(XPDIR) +
strlen(langDir) + 1);
@@ -307,7 +324,7 @@ BuildPrinterAttrs(
if(systemAttributes.printers != (XrmDatabase)NULL)
{
- char *fileName;
+ char *dirName, *fileName;
XrmDatabase modelDB = (XrmDatabase)NULL;
XrmName xrm_name[5], xrm_class[2];
XrmRepresentation rep_type;
@@ -607,6 +624,7 @@ XpGetOneAttribute(
{
ContextAttrPtr pCtxtAttrs;
XrmDatabase db = (XrmDatabase)NULL;
+ char *retVal;
XrmName xrm_name[3];
XrmRepresentation rep_type;
XrmValue value;
@@ -670,10 +688,10 @@ XpGetOneAttribute(
*/
void
XpPutOneAttribute(
- XpContextPtr pContext,
- XPAttributes class,
- const char* attributeName,
- const char* value)
+ XpContextPtr pContext,
+ XPAttributes class,
+ const char* attributeName,
+ const char* value)
{
ContextAttrPtr pCtxtAttrs;
XrmDatabase db;
@@ -798,7 +816,7 @@ AppendEntry(
char *s, c;
if (*type != XrmQString)
- return False;
+ return;
for (firstNameSeen = False; *quarks; bindings++, quarks++) {
if (*bindings == XrmBindLoosely) {
@@ -857,6 +875,7 @@ XpGetAttributes(
{
ContextAttrPtr pCtxtAttrs;
XrmDatabase db = (XrmDatabase)NULL;
+ char *retVal;
StringDbStruct enumStruct;
XrmQuark empty = NULLQUARK;
@@ -1065,6 +1084,34 @@ XpSpoolerGetServerAttributes(void)
}
/*
+ * ExecuteCommand takes two pointers - the command to execute,
+ * and the "argv" style NULL-terminated vector of arguments for the command.
+ * We wait for the command to terminate before continuing to ensure that
+ * we don't delete the job file before the spooler has made a copy.
+ */
+static void
+ExecCommand(pCommand, argVector)
+ char *pCommand;
+ char **argVector;
+{
+ pid_t childPid;
+ int status;
+
+ if((childPid = fork()) == 0)
+ {
+ /* return BadAlloc? */
+ if (execv(pCommand, argVector) == -1) {
+ FatalError("unable to exec '%s'", pCommand);
+ }
+ }
+ else
+ {
+ (void) waitpid(childPid, &status, 0);
+ }
+ return;
+}
+
+/*
* SendFileToCommand takes three character pointers - the file name,
* the command to execute,
* and the "argv" style NULL-terminated vector of arguments for the command.
@@ -1107,11 +1154,17 @@ SendFileToCommand(
if((childPid = fork()) == 0)
{
- close(pipefd[1]);
+ close(pipefd[1]);
+
+ /* Replace current stdin with input from the pipe */
close(0);
dup(pipefd[0]);
close(pipefd[0]);
+ /* Close current stdout and redirect it to stderr */
+ close(1);
+ dup(2);
+
/*
* If a user name is specified, try to set our uid to match that
* user name. This is to allow e.g. a banner page to show the
@@ -1120,13 +1173,22 @@ SendFileToCommand(
*/
if(userName)
{
- if(geteuid() == (uid_t)0)
+ uid_t myUid;
+
+ if((myUid = geteuid()) == (uid_t)0)
{
struct passwd *pPasswd;
if((pPasswd = getpwnam(userName)))
{
- setuid((uid_t)pPasswd->pw_uid);
+ if (setgid((gid_t)pPasswd->pw_gid) != 0)
+ perror("SendFileToCommand: setgid() failure.");
+
+ if (initgroups(userName, (gid_t)pPasswd->pw_gid) != 0)
+ perror("SendFileToCommand: initgroups() failure.");
+
+ if (setuid((uid_t)pPasswd->pw_uid) != 0)
+ perror("SendFileToCommand: setuid() failure.");
}
}
}
@@ -1137,6 +1199,8 @@ SendFileToCommand(
}
else
{
+ int res;
+
(void) close(pipefd[0]);
outPipe = fdopen(pipefd[1], "w");
@@ -1156,6 +1220,7 @@ SendFileToCommand(
* store for the supplied print context. The ReplaceAnyString utility
* routine is used to perform the actual replacements.
*/
+extern char *ReplaceAnyString(char *, char *, char *);
static char *
ReplaceAllKeywords(
@@ -1197,6 +1262,10 @@ ReplaceAllKeywords(
else
command = ReplaceAnyString(command, "%options%", "");
+ /* New in xprint.mozdev.org release 007 - replace "%xpconfigdir%" with
+ * location of $XPCONFIGDIR */
+ command = ReplaceAnyString(command, "%xpconfigdir%", XpGetConfigDirBase());
+
return command;
}
@@ -1367,43 +1436,58 @@ VectorizeCommand(
char ***pVector,
XpContextPtr pContext)
{
- char *cmdName;
+ char *cmdName, *curTok;
+ int i, numChars;
if(command == (char *)NULL)
return (char *)NULL;
- (void) GetToken(command, &cmdName);
+ numChars = GetToken(command, &cmdName);
if(cmdName == (char *)NULL)
return (char *)NULL;
- *pVector = BuildArgVector(command, pContext);
+ /* Mangle the command name, too... */
+ cmdName = ReplaceAllKeywords(pContext, cmdName);
+
+ if(cmdName == (char *)NULL)
+ return (char *)NULL;
+ *pVector = BuildArgVector(command, pContext);
+
return cmdName;
}
-#ifdef hpux
-static char DEFAULT_SPOOL_COMMAND[] = "/usr/bin/lp -d %printer-name% -o raw -n %copy-count% -t %job-name% %options%";
-#else
-static char DEFAULT_SPOOL_COMMAND[] = "/usr/bin/lp -d %printer-name% -n %copy-count% -t %job-name% %options%";
-#endif
-
int
-XpSubmitJob(
- char *fileName,
- XpContextPtr pContext)
+XpSubmitJob(fileName, pContext)
+ char *fileName;
+ XpContextPtr pContext;
{
- char **vector, *cmdNam, *command, *userName;
+ char **vector, *cmdNam, *cmdOpt, *command, *userName;
int i;
command = XpGetOneAttribute(pContext, XPPrinterAttr, "xp-spooler-command");
if(command == (char *)NULL || strlen(command) == 0)
- command = strdup(DEFAULT_SPOOL_COMMAND);
+ {
+ if( spooler_type )
+ {
+ command = strdup(spooler_type->spool_command);
+ }
+ else
+ {
+ ErrorF("XpSubmitJob: No default spool command defined.\n");
+ }
+ }
else
+ {
command = strdup(command);
+ }
if(command == (char *)NULL)
+ {
+ ErrorF("XpSubmitJob: No spooler command found, cannot submit job.\n");
return BadAlloc;
-
+ }
+
cmdNam = VectorizeCommand(command, &vector, pContext);
xfree(command);
@@ -1431,7 +1515,6 @@ XpSubmitJob(
FreeVector(vector);
xfree(cmdNam);
- return Success;
}
/*
@@ -1504,6 +1587,7 @@ XpGetTrayMediumFromContext(XpContextPtr pCon,
{
char *defMedium, *defTray;
char *t, *m;
+ char *pS, *pE, *pLast;
defMedium = XpGetOneAttribute( pCon, XPPageAttr,
"default-medium" );
diff --git a/Xprint/attributes.h b/Xprint/attributes.h
index b43d76af5..c4e30d274 100644
--- a/Xprint/attributes.h
+++ b/Xprint/attributes.h
@@ -30,7 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/attributes.h,v 1.5 2001/08/01 00:44:45 tsi Exp $ */
#ifndef _Xp_attributes_h
#define _Xp_attributes_h 1
@@ -49,11 +48,11 @@ typedef void (*pVFunc)(VFuncArgs);
*/
void XpInitAttributes(XpContextPtr pContext);
void XpBuildAttributeStore(char *printerName,
- char *qualifierName);
+ char *qualifierName);
void XpAddPrinterAttribute(char *printerName,
- char *printerQualifier,
- char *attributeName,
- char *attributeValue);
+ char *printerQualifier,
+ char *attributeName,
+ char *attributeValue);
void XpDestroyAttributes(XpContextPtr pContext);
char *XpGetConfigDir(Bool useLocale);
char *XpGetOneAttribute(XpContextPtr pContext,
@@ -98,33 +97,33 @@ void XpGetMediumDimensions(XpContextPtr pContext,
void XpGetReproductionArea(XpContextPtr pContext,
xRectangle *pRect);
void XpGetMaxWidthHeightRes(const char *printer_name,
- const XpValidatePoolsRec* vpr,
- float *width,
- float *height,
- int* resolution);
+ const XpValidatePoolsRec* vpr,
+ float *width,
+ float *height,
+ int* resolution);
/* Util.c */
-char * ReplaceAnyString(char *string,
- char *target,
- char *replacement);
-char * ReplaceFileString(char *string,
- char *inFileName,
- char *outFileName);
+char *ReplaceAnyString(char *string,
+ char *target,
+ char *replacement);
+char *ReplaceFileString(char *string,
+ char *inFileName,
+ char *outFileName);
void ExecCommand(char *pCommand,
- char **argVector);
+ char **argVector);
int TransferBytes(FILE *pSrcFile,
- FILE *pDstFile,
- int numBytes);
+ FILE *pDstFile,
+ int numBytes);
Bool CopyContentsAndDelete(FILE **ppSrcFile,
- char **pSrcFileName,
- FILE *pDstFile);
+ char **pSrcFileName,
+ FILE *pDstFile);
int XpSendDocumentData(ClientPtr client,
- FILE *fp,
- int fileLen,
- int maxBufSize);
+ FILE *fp,
+ int fileLen,
+ int maxBufSize);
int XpFinishDocData(ClientPtr client);
Bool XpOpenTmpFile(char *mode,
- char **fname,
- FILE **stream);
+ char **fname,
+ FILE **stream);
#endif /* _Xp_attributes_h */
diff --git a/Xprint/ddxInit.c b/Xprint/ddxInit.c
index 02e5ea370..54f9b611a 100644
--- a/Xprint/ddxInit.c
+++ b/Xprint/ddxInit.c
@@ -30,13 +30,12 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ddxInit.c,v 1.13 2001/06/11 16:59:02 dawes Exp $ */
#include "X.h"
+#include "Xos.h"
#include "Xproto.h"
#include "windowstr.h"
#include "servermd.h"
-#include "Xos.h"
#include "DiPrint.h"
/*-
@@ -68,10 +67,13 @@ copyright holders.
void
InitOutput(
- ScreenInfo *pScreenInfo,
- int argc,
- char **argv)
+ ScreenInfo *pScreenInfo,
+ int argc,
+ char **argv)
+
{
+ int i;
+
pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
@@ -168,10 +170,10 @@ PointerProc(
void
InitInput(
- int argc,
+ int argc,
char **argv)
{
- DeviceIntPtr ptr, kbd;
+ DevicePtr ptr, kbd;
ptr = AddInputDevice((DeviceProc)PointerProc, TRUE);
kbd = AddInputDevice((DeviceProc)KeyboardProc, TRUE);
@@ -195,10 +197,26 @@ ProcessInputEvents(void)
}
#ifdef __DARWIN__
+#include "micmap.h"
+
+void GlxExtensionInit(void);
+void GlxWrapInitVisuals(miInitVisualsProcPtr *procPtr);
+
void
DarwinHandleGUI(int argc, char *argv[])
{
}
+
+void DarwinGlxExtensionInit(void)
+{
+ GlxExtensionInit();
+}
+
+void DarwinGlxWrapInitVisuals(
+ miInitVisualsProcPtr *procPtr)
+{
+ GlxWrapInitVisuals(procPtr);
+}
#endif
#ifdef DDXOSINIT
@@ -232,6 +250,12 @@ GetTimeInMillis(void)
}
#endif
+/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
+void ddxInitGlobals(void)
+{
+ XprintInitGlobals();
+}
+
/****************************************
* ddxUseMsg()
*
@@ -241,7 +265,11 @@ GetTimeInMillis(void)
void ddxUseMsg(void)
{
- /* Right now, let's just do nothing */
+/* Enable |XprintUseMsg()| only if |XprintOptions()| is called
+ * by |ddxProcessArgument|, too (see below...) */
+#ifdef PRINT_ONLY_SERVER
+ XprintUseMsg();
+#endif /* PRINT_ONLY_SERVER */
}
void AbortDDX (void)
@@ -275,12 +303,12 @@ extern int BadDevice;
int
ChangePointerDevice (
- DeviceIntPtr old_dev,
- DeviceIntPtr new_dev,
- unsigned char x,
- unsigned char y)
+ DeviceIntPtr old_dev,
+ DeviceIntPtr new_dev,
+ unsigned char x,
+ unsigned char y)
{
- return (BadDevice);
+ return (BadDevice);
}
int
diff --git a/Xprint/etc/init.d/xprint.cpp b/Xprint/etc/init.d/xprint.cpp
new file mode 100644
index 000000000..40ab6fbae
--- /dev/null
+++ b/Xprint/etc/init.d/xprint.cpp
@@ -0,0 +1,1274 @@
+XCOMM!/bin/sh
+XCOMM
+XCOMM Copyright 2002-2004 by Roland Mainz <roland.mainz@nrubsig.org>.
+XCOMM
+XCOMM This script manages the Xprint server side
+
+XCOMM Basic support for IRIX-style "chkconfig"
+XCOMM chkconfig: 2345 61 61
+XCOMM description: Startup/shutdown script for Xprint server(s)
+
+XCOMM Basic support for the Linux Standard Base Specification 1.0.0
+XCOMM (Note: The Should-Start/Stop lines are there so that this works in the
+XCOMM future, when the LSB adopts these. The X-UnitedLinux lines are there
+XCOMM so that it works right now.)
+XCOMM## BEGIN INIT INFO
+XCOMM Provides: xprint
+XCOMM Required-Start: $local_fs $remote_fs $syslog $network
+XCOMM Required-Stop: $local_fs $remote_fs $syslog
+XCOMM Should-Start: cups lpd xfs
+XCOMM Should-Stop: cups lpd xfs
+XCOMM X-UnitedLinux-Should-Start: cups lpd xfs
+XCOMM X-UnitedLinux-Should-Stop: cups lpd xfs
+XCOMM Default-Start: 3 5
+XCOMM Default-Stop: 0 1 2 6
+XCOMM Description: Startup/shutdown script for Xprint server(s)
+XCOMM## END INIT INFO
+
+#undef sun
+#undef unix
+
+XCOMM###########################################################################
+XCOMM
+XCOMM This script has three main tasks:
+XCOMM 1. Start Xprint servers ("Xprt") at boot time.
+XCOMM 2. Shutdown Xprint servers when the machine is being shut down.
+XCOMM 3. Query the list of available printers.
+XCOMM
+XCOMM Additional tasks are:
+XCOMM 4. Restart ('restart'|'force-reload') and conditional restart
+XCOMM ('condrestart'/'try-restart') for Linux support
+XCOMM 5. Wrapping of application call with setting XPSERVERLIST ('wrapper')
+XCOMM
+XCOMM Usage:
+XCOMM - Start Xprint server(s) manually:
+XCOMM % /etc/init.d/xprint start
+XCOMM
+XCOMM - Stop Xprint server(s) manually:
+XCOMM % /etc/init.d/xprint stop
+XCOMM
+XCOMM - Populate $XPSERVERLIST env var (for example as part of a global
+XCOMM login script like /etc/profile or per-user login scripts like
+XCOMM $HOME/.profile (sh/ksh/bash))
+XCOMM % XPSERVERLIST="`/etc/init.d/xprint get_xpserverlist`"
+XCOMM % export XPSERVERLIST
+XCOMM
+XCOMM Installation:
+XCOMM Copy this script to /etc/init.d/xprint and make sure that it is
+XCOMM executable. If your installation is LSB-compliant, then run
+XCOMM % /usr/lib/lsb/install_initd /etc/init.d/xprint
+XCOMM to start the service on startup. Otherwise, manually create links
+XCOMM to the matching run levels.
+XCOMM Examples:
+XCOMM - Solaris 2.7/2.8/2.9:
+XCOMM % cp xprint /etc/init.d/xprint
+XCOMM % chmod a+rx /etc/init.d/xprint
+XCOMM % ln /etc/init.d/xprint /etc/rc0.d/K38xprint
+XCOMM % ln /etc/init.d/xprint /etc/rc1.d/K38xprint
+XCOMM % ln /etc/init.d/xprint /etc/rc2.d/S81xprint
+XCOMM % ln /etc/init.d/xprint /etc/rcS.d/K38xprint
+XCOMM
+XCOMM - SuSE Linux 7.3
+XCOMM % cp xprint /etc/init.d/xprint
+XCOMM % chmod a+rx /etc/init.d/xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc3.d/K13xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc3.d/S12xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc5.d/K13xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc5.d/S12xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc2.d/K13xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc2.d/S12xprint
+XCOMM
+XCOMM - SuSE Linux 6.4:
+XCOMM % cp xprint /sbin/init.d/xprint
+XCOMM % chmod a+rx /sbin/init.d/xprint
+XCOMM % ln -s ../xprint /sbin/init.d/rc2.d/K20xprint
+XCOMM % ln -s ../xprint /sbin/init.d/rc2.d/S20xprint
+XCOMM % ln -s ../xprint /sbin/init.d/rc3.d/K20xprint
+XCOMM % ln -s ../xprint /sbin/init.d/rc3.d/S20xprint
+XCOMM
+XCOMM Notes:
+XCOMM - The Xprint servers must be started _after_ the print
+XCOMM spooler or the server(s) may refuse to start
+XCOMM - The script should be readable by all users to ensure that they
+XCOMM can use the "get_xpserverlist"-option
+XCOMM
+XCOMM Custom configuration:
+XCOMM - Edit the function setup_config() in this script to match your needs
+XCOMM
+XCOMM Known bugs/ToDo/Notes:
+XCOMM - The shell script assumes that a Xserver can be reached via
+XCOMM "hostname:displaynum" where "hostname" is obtained from
+XCOMM "/usr/bin/hostname". It may happen that a kernel firewall
+XCOMM blocks an X connection on the same host (e.g. client && Xserver
+XCOMM are running on the same host).
+XCOMM Suggested fix: Fix the firewall config.
+XCOMM Suggested workaround: Edit this script and replace the use of
+XCOMM /usr/bin/hostname with "echo 'localhost'".
+XCOMM
+XCOMM###########################################################################
+XCOMM
+
+
+XCOMM###########################################################################
+
+fatal_error()
+{
+ echo "${0}: ## FATAL ERROR: ${1}" 1>&2
+ exit 1
+}
+
+error_echo()
+{
+ echo "${0}: ## ERROR: ${1}" 1>&2
+}
+
+warning_echo()
+{
+ echo "${0}: ## WARNING: ${1}" 1>&2
+}
+
+verbose_echo()
+{
+ echo "${0}: ${1}"
+}
+
+msg()
+{
+ echo "${1}"
+}
+
+XCOMM###########################################################################
+
+#ifndef OS_LINUX
+XCOMM Force use of a POSIX conformant sh
+XCOMM (Solaris /sbin/sh is plain Bourne shell)
+[ "$1" != "posix_sh_forced" -a -x /bin/ksh ] && exec /bin/ksh "$0" posix_sh_forced "$@"
+[ "$1" != "posix_sh_forced" -a -x /bin/bash ] && exec /bin/bash --norc --noprofile "$0" posix_sh_forced "$@"
+[ "$1" != "posix_sh_forced" -a -x /usr/local/bin/ksh ] && exec /usr/local/bin/ksh "$0" posix_sh_forced "$@"
+[ "$1" != "posix_sh_forced" -a -x /usr/local/bin/bash ] && exec /usr/local/bin/bash --norc --noprofile "$0" posix_sh_forced "$@"
+if [ "$1" != "posix_sh_forced" ] ; then
+ echo "${0}: ## FATAL ERROR: No POSIX-shell found." 1>&2
+ exit 1
+fi
+
+shift # Drop "posix_sh_forced"
+#endif /* !OS_LINUX */
+
+XCOMM#debug
+XCOMM set -x
+
+XCOMM Change current dir to a location which is writeable by everyone
+cd /tmp
+
+XCOMM Clear some environment variables
+unset TEMP TMPDIR SCREENDIR
+
+XCOMM Set search path for commands
+export PATH=/usr/bin:/bin:/usr/sbin:/sbin
+#ifdef OS_SOLARIS
+export PATH=/usr/xpg4/bin:${PATH}
+#endif
+
+XCOMM# Try to figure-out where X11 was installed
+#if defined(OS_SOLARIS)
+XPROJECTROOT=/usr/openwin
+export OPENWINHOME=/usr/openwin
+#elif defined(OS_AIX)
+XPROJECTROOT=/usr/lpp/X11
+#else
+[ -d /usr/X11/bin ] && XPROJECTROOT=/usr/X11
+[ -d /usr/X11R6/bin ] && XPROJECTROOT=/usr/X11R6
+#endif
+XPCUSTOMGLUE=DEF_XPCUSTOMGLUE # This is used for customizing this script
+export XPROJECTROOT XPCUSTOMGLUE
+
+if [ -z "${XPROJECTROOT}" ] ; then
+ fatal_error "Unknown XProjectRoot."
+fi
+
+XCOMM Set the location of the Xprt binary we want to use.
+XPRT_BIN="${XPROJECTROOT}/bin/Xprt"
+
+XCOMM Set the location of the global file where we store the locations
+XCOMM of the system-wide servers
+if [ -d /var/run ] ; then
+ XP_GLOBAL_SERVERS=/var/run/Xprint_servers
+else
+ XP_GLOBAL_SERVERS=/tmp/.Xprint_servers
+fi
+
+XCOMM ${LOGNAME} will not work if user su'ed into another account
+export CURRLOGNAME="$(id -u -n)"
+
+XCOMM Set location where we want to store the list of Xprint servers managed
+XCOMM by this user
+XCOMM - If we start as "root" use the global file
+XCOMM - If we start as normal user use a per-user file
+
+if [ "${CURRLOGNAME}" != "root" -a "${CURRLOGNAME}" != "" ] ; then
+ XP_PER_USER_SERVERS="/tmp/.Xprint_servers_${CURRLOGNAME}"
+ XP_SERVERS="${XP_PER_USER_SERVERS}"
+else
+ XP_SERVERS="${XP_GLOBAL_SERVERS}"
+fi
+
+XCOMM Set umask that owner can r/w all files and everyone else can read them
+umask 022
+
+XCOMM Bump limit for per-process open files to ensure that Xprt can open many many fonts
+ulimit -n 1024
+
+XCOMM###########################################################################
+
+XCOMM Get list of fonts for a given display
+get_fontlist_from_display()
+{
+ ${XPROJECTROOT}/bin/xset -display "${1}" q |
+ awk "/Font Path:/ { i=1 ; next } i==1 { print \$0 ; i=0 }" |
+ fontpath2fontlist
+}
+
+XCOMM Get list from a fontserver config
+get_fontlist_from_xfs_config()
+{
+ if [ ! -r "${1}" ] ; then
+ return 0
+ fi
+
+ (
+ cat "${1}" |
+ while read -r i ; do
+ for val in $i; do
+ case $val in
+ \#*) break ;;
+ ?*=*) key="${val%%=*}" ;;
+ =*) key="${tok}" ;;
+ *) [ "${key}" = "catalogue" -a "${tok}" != "" ] && echo "${tok}" ;;
+ esac
+ tok="${val#*=}"
+ done
+ done
+ ) | tr "," "[\n]" | fontpath2fontlist
+}
+
+get_fontlist_from_all_xfs_configs()
+{
+ get_fontlist_from_xfs_config "/etc/openwin/fs/fontserver.cfg"
+ get_fontlist_from_xfs_config "/usr/openwin/lib/X11/fontserver.cfg"
+ get_fontlist_from_xfs_config "/etc/X11/fs-xtt/config"
+ get_fontlist_from_xfs_config "/etc/X11/fs/config"
+ get_fontlist_from_xfs_config "/etc/X11/xfs/config"
+ get_fontlist_from_xfs_config "${XPROJECTROOT}/lib/X11/fs/config"
+}
+
+get_fontlist_from_xf86config()
+{
+ srcxconf=""
+
+ XCOMM see xorg.conf(5x) manual page for the list of locations used here
+ [ "${srcxconf}" = "" -a -f "/etc/X11/xorg.conf" ] && srcxconf="/etc/X11/xorg.conf"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf"
+ [ "${srcxconf}" = "" -a -f "/etc/X11/xorg.conf-4" ] && srcxconf="/etc/X11/xorg.conf-4"
+ [ "${srcxconf}" = "" -a -f "/etc/X11/xorg.conf" ] && srcxconf="/etc/X11/xorg.conf"
+ [ "${srcxconf}" = "" -a -f "/etc/xorg.conf" ] && srcxconf="/etc/xorg.conf"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf.${hostname}" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf.${hostname}"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf-4" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf-4"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/lib/X11/xorg.conf.${hostname}" ] && srcxconf="/usr/X11R6/lib/X11/xorg.conf.${hostname}"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/lib/X11/xorg.conf-4" ] && srcxconf="/usr/X11R6/lib/X11/xorg.conf-4"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/lib/X11/xorg.conf" ] && srcxconf="/usr/X11R6/lib/X11/xorg.conf"
+
+ XCOMM Xfree86 locations
+ [ "${srcxconf}" = "" -a -f "/etc/X11/XF86Config-4" ] && srcxconf="/etc/X11/XF86Config-4"
+ [ "${srcxconf}" = "" -a -f "/etc/X11/XF86Config" ] && srcxconf="/etc/X11/XF86Config"
+
+
+ if [ "${srcxconf}" = "" ] ; then
+ return 0
+ fi
+
+ currsection=""
+ cat "${srcxconf}" |
+ while read i1 i2 i3 i4 ; do
+ # Strip "\"" from I2
+ i2="${i2#\"}" ; i2="${i2%\"}"
+
+ case "${i1}" in
+ \#*)
+ continue
+ ;;
+ 'Section')
+ currsection="${i2}"
+ ;;
+ 'EndSection')
+ currsection=""
+ ;;
+ 'FontPath')
+ [ "$currsection" = "Files" ] && echo "${i2%:unscaled}"
+ ;;
+ esac
+ done | egrep -v -i "tcp/|tcp4/|tcp6/|unix/"
+
+ return 0
+}
+
+get_fontlist_from_defoma()
+{
+ # Include Debian defoma font directory where relevant
+ if [ -d "/var/lib/defoma/x-ttcidfont-conf.d/dirs" ] ; then
+ find "/var/lib/defoma/x-ttcidfont-conf.d/dirs" -name fonts.dir |
+ while read i ; do echo "${i%/fonts.dir}" ; done
+ fi
+}
+
+XCOMM Get list of system fonts
+get_system_fontlist()
+{
+#if defined(OS_SOLARIS)
+ ## List the standard X11 fonts
+ # echo "${XPROJECTROOT}/lib/X11/fonts/F3/"
+ # echo "${XPROJECTROOT}/lib/X11/fonts/F3bitmaps/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/Type1/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/Type1/outline/"
+ # We cannot use /usr/openwin/lib/X11/fonts/Type1/sun/ - see
+ # http://xprint.mozdev.org/bugs/show_bug.cgi?id=5726
+ # ("Xprint doesn't start under Solaris 2.9 due *.ps files in /usr/openwin/lib/X11/fonts/Type1/sun/fonts.dir")
+ #echo "${XPROJECTROOT}/lib/X11/fonts/Type1/sun/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/TrueType/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/Speedo/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/misc/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/75dpi/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/100dpi/"
+
+ ## List all fonts in all locales installed on this machine
+ cat /usr/openwin/lib/locale/''*/OWfontpath | tr "," "\n" | sort -u
+#elif defined(OS_LINUX)
+ (
+ get_fontlist_from_defoma
+
+ get_fontlist_from_xf86config
+
+ # Getting font paths from XFS is mainly required for compatibilty to RedHat
+ get_fontlist_from_all_xfs_configs
+
+ ## List all fonts in all locales installed on this machine
+ (
+ [ -d "/usr/share/fonts" ] && find /usr/share/fonts -name fonts.dir
+ find "${XPROJECTROOT}/lib/X11/fonts" -name fonts.dir
+ ) |
+ while read i ; do echo "${i%/fonts.dir}" ; done
+ ) | sort -u
+#else
+ ## List the standard X11 fonts
+ # (AIX should be handled like Solaris but I did not found a way to
+ # enumerate all fonts in all installed locales without scanning the
+ # dirs manually)
+ echo "${XPROJECTROOT}/lib/X11/fonts/Type1/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/TrueType/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/TTF/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/Speedo/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/misc/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/75dpi/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/100dpi/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/"
+#endif
+}
+
+XCOMM Filter fonts per given extended regular expressions
+XCOMM (and make sure we filter any model-config fonts - they are managed by Xprt internally)
+filter_fontlist()
+{
+ egrep -- "${1}" | fgrep -v "/models/" | egrep -v -- "${2}"
+}
+
+XCOMM Filter font paths with unsupported font types
+XCOMM (such as CID fonts)
+filter_unsupported_fonts()
+{
+ egrep -v -i "/cid(/$|$)|/csl(/$|$)"
+}
+
+XCOMM Validate fontpath
+XCOMM Only return valid font path entries (note that these entries may
+XCOMM include non-file stuff like font server references)
+validate_fontlist()
+{
+ while read i ; do
+ case "${i}" in
+ # Check if font path entry is a font server...
+ tcp/''*|tcp4/''*|tcp6/''*|unix/''*)
+ echo "${i}"
+ ;;
+ # ... if not check if the path is accessible
+ # and has a valid "fonts.dir" index
+ *)
+ [ -f "${i}/fonts.dir" ] && echo "${i}"
+ ;;
+ esac
+ done
+}
+
+XCOMM Build a comma-seperated list of fonts (font path) from a list of fonts
+fontlist2fontpath()
+{
+ fp=""
+ read fp;
+ while read i ; do
+ fp="${fp},${i}"
+ done
+
+ echo "$fp"
+}
+
+XCOMM Build a list (one item per line) of fonts from a font path
+fontpath2fontlist()
+{
+ while read i ; do
+ echo "${i}" | tr "," "\n"
+ done
+}
+
+XCOMM Sort scaleable fonts (PS Type1 and TrueType) first in a font list
+sort_scaleable_fonts_first()
+{
+ i="$(fontlist2fontpath)"
+ # First list PS Type1 fonts...
+ echo "${i}" | fontpath2fontlist | fgrep "/Type1"
+ # ... then TrueType fonts ...
+ echo "${i}" | fontpath2fontlist | egrep -i "/TrueType|/TT(/$|$)|/TTF(/$|$)"
+ # ... then all others
+ echo "${i}" | fontpath2fontlist | egrep -v -i "/Type1|/TrueType|/TT(/$|$)|/TTF(/$|$)"
+}
+
+XCOMM Check if a X display is used by a Xserver or not
+XCOMM Known bugs:
+XCOMM - there is no way in plain bourne shell or bash (see comment about ksh93
+XCOMM below) to test if a Xserver sits only on a socket and not on a pipe
+XCOMM - some Xserver's don't cleanup their stuff in /tmp on exit which may end
+XCOMM in the problem that we don't detect possible free display numbers
+XCOMM (one problem is that only ksh93 can do stuff like
+XCOMM "cat </dev/tcp/0.0.0.0/6001")
+CheckIfDisplayIsInUse()
+{
+ id=$1
+
+ [ -r "/tmp/.X${id}-lock" ] && return 0;
+ [ -r "/tmp/.X11-unix/X${id}" ] && return 0;
+ [ -r "/tmp/.X11-pipe/X${id}" ] && return 0;
+
+ return 1;
+}
+
+lastdisplaynumreturned_store=/tmp/.Xp_last_display_returned_by_findfreexdisplaynum_${RANDOM}_${RANDOM}
+
+XCOMM Try to find a free display number
+FindFreeXDisplayNum()
+{
+ if [ -r "${lastdisplaynumreturned_store}" ] ; then
+ i="$(cat "${lastdisplaynumreturned_store}")"
+ else
+ i=32 # start at display 32
+ fi
+
+ while [ $i -lt 127 ] ; do
+ i=$(($i + 1))
+
+ if CheckIfDisplayIsInUse $i ; then
+ true
+ else
+ echo "$i"
+ echo "$i" >"${lastdisplaynumreturned_store}"
+ return 0
+ fi
+ done
+
+ # Using "magic" value of 189 here due lack of a better solution
+ echo "189"
+ echo "189" >"${lastdisplaynumreturned_store}"
+ return 0
+}
+
+XCOMM Check if a process exists or not
+pexists()
+{
+ [ "$1" = "" ] && return 1;
+
+ # Use of /proc would be better but not all platforms (like AIX) have procfs
+ [ "$(ps -p $1 | fgrep $1)" != "" ] && return 0;
+ return 1
+}
+
+XCOMM Check if there is a spooler running...
+is_spooler_running()
+{
+ # This covers Linux lpd, CUPS, Solaris and AIX 4.x - but what about
+ # AIX 5.x, HP-UX and IRIX ?
+
+ [ "$(ps -A | egrep 'lpd|lpsched|cupsd|qdaemon' | fgrep -v 'grep')" != "" ] && return 0;
+ return 1
+}
+
+XCOMM Wait until the spooler system has been started (but not more than 30secs)
+wait_for_print_spooler()
+{
+ for i in 1 2 3 4 5 6 7 8 9 10 ; do
+ is_spooler_running && return 0;
+ sleep 3
+ done
+
+ return 0
+}
+
+lock_server_registry()
+{
+ lock_counter=0 # counts in 1/100s
+ waiting_for_lock_msg_send="false"
+ while ! mkdir "${XP_SERVERS}.lock" 2>/dev/null ; do
+ # print notice after 2 seconds
+ if [ ${lock_counter} -gt 200 -a "${waiting_for_lock_msg_send}" != "true" ] ; then
+ echo "${0}: waiting for lock(=${XP_SERVERS}.lock)..."
+ waiting_for_lock_msg_send="true"
+ fi
+
+ # tread the lock as "broken" after 20 seconds
+ if [ ${lock_counter} -gt 2000 ] ; then
+ echo "${0}: WARNING: lock timeout for lock(=${XP_SERVERS}.lock)."
+ return 0
+ fi
+
+ if [ -x /bin/usleep ] ; then
+ /bin/usleep 200000
+ lock_counter=$((${lock_counter} + 20)) # 20/100s
+ else
+ sleep 1
+ lock_counter=$((${lock_counter} + 100)) # 100/100s
+ fi
+ done
+}
+
+unlock_server_registry()
+{
+ rmdir "${XP_SERVERS}.lock"
+}
+
+XCOMM Kill dead registry locks (silently!)
+kill_dead_registry_locks()
+{
+ rm -Rf "${XP_SERVERS}.lock"
+}
+
+XCOMM Start Xprint servers
+start_servers()
+{
+ # Write registry "intro" ...
+ lock_server_registry
+ echo "# Xprint server list" >>"${XP_SERVERS}"
+ echo "# File is for private use for ${0}." >>"${XP_SERVERS}"
+ echo "# Do not edit, rely on the content or file format." >>"${XP_SERVERS}"
+ unlock_server_registry
+
+ hostname="$(hostname)"
+
+ default_fontpath="$(get_system_fontlist | fontlist2fontpath)"
+ default_fontpath_acceptpattern=".*";
+ default_fontpath_rejectpattern="_No_Match_"; # Match nothing
+
+ curr=0
+ while [ $curr -lt $num_xpstart ] ; do
+ if [ "${xpstart_remote_server[$curr]}" != "" ] ; then
+ # Remote Xprt, just put the entry into the registry
+ lock_server_registry
+ echo "display=${xpstart_remote_server[$curr]}" >>"${XP_SERVERS}"
+ unlock_server_registry
+ else
+ # Run block in seperate process to avoid that changes to the
+ # xpstart_* variables affect the next cycle
+ (
+ # Use defaults if there are no special options
+ [ "${xpstart_fontpath[$curr]}" = "" ] && xpstart_fontpath[$curr]="${default_fontpath}";
+ [ "${xpstart_fontpath_acceptpattern[$curr]}" = "" ] && xpstart_fontpath_acceptpattern[$curr]="$default_fontpath_acceptpattern";
+ [ "${xpstart_fontpath_rejectpattern[$curr]}" = "" ] && xpstart_fontpath_rejectpattern[$curr]="$default_fontpath_rejectpattern";
+ [ "${xpstart_displayid[$curr]}" = "" ] && xpstart_displayid[$curr]="$(FindFreeXDisplayNum)"
+ [ "${xpstart_logger[$curr]}" = "" ] && xpstart_logger[$curr]="logger -p lpr.notice -t Xprt_${xpstart_displayid[$curr]}";
+ [ "${xpstart_logfile[$curr]}" = "" ] && xpstart_logfile[$curr]="/dev/null";
+ [ "${xpstart_xprt_binary[$curr]}" = "" ] && xpstart_xprt_binary[$curr]="${XPRT_BIN}";
+ if [ "${xpstart_xprt_binary[$curr]}" = "/usr/openwin/bin/Xprt" -o "$(uname -s)" = "SunOS" ] ; then
+ # Solaris /usr/openwin/bin/Xprt does not support "-nolisten tcp"
+ # yet nor is it possible to run a Xserver on a unix socket only
+ # in Solaris since access to the unix domain sockets in
+ # /tmp/.X11-pipe and /tmp/.X11-unix is restricted to applications
+ # with group-id "root" (e.g. the Xprt server would need to be
+ # setgid "root" that plain users can start it listening on a unix
+ # socket only)
+ [ "${xpstart_options[$curr]}" = "" ] && xpstart_options[$curr]="-ac -pn"
+ else
+ [ "${xpstart_options[$curr]}" = "" ] && xpstart_options[$curr]="-ac -pn -nolisten tcp"
+ fi
+
+ # Check if the Xprt binary is available
+ if [ ! -x "${xpstart_xprt_binary[$curr]}" ] ; then
+ error_echo "Can't find \"${xpstart_xprt_binary[$curr]}\"."
+ exit 1 # exit block
+ fi
+
+ # Verify and set location of font encodings directory file
+ if [ "${xpstart_font_encodings_dir[$curr]}" = "" ] ; then
+ if [ -f "${XPROJECTROOT}/lib/X11/fonts/xf86encodings/encodings.dir" ] ; then
+ xpstart_font_encodings_dir[$curr]="${XPROJECTROOT}/lib/X11/fonts/xf86encodings/encodings.dir"
+ else
+ xpstart_font_encodings_dir[$curr]="${XPROJECTROOT}/lib/X11/fonts/encodings/encodings.dir";
+ fi
+ fi
+
+ unset FONT_ENCODINGS_DIRECTORY
+ if [ ! -f "${xpstart_font_encodings_dir[$curr]}" ] ; then
+ warning_echo "Can't find \"${xpstart_font_encodings_dir[$curr]}\", TrueType font support may not work."
+ fi
+
+ export FONT_ENCODINGS_DIRECTORY="${xpstart_font_encodings_dir[$curr]}"
+
+ # Generate font path (containing only valid font path elements)
+ # from input font path and filter expressions
+ curr_fp=$(echo "${xpstart_fontpath[$curr]}" |
+ fontpath2fontlist |
+ filter_fontlist "${xpstart_fontpath_acceptpattern[$curr]}" "${xpstart_fontpath_rejectpattern[$curr]}" |
+ filter_unsupported_fonts |
+ sort_scaleable_fonts_first |
+ validate_fontlist |
+ fontlist2fontpath)
+
+ # Set Xserver auditing level option
+ unset curr_audit
+ if [ "${xpstart_auditlevel[$curr]}" != "" ] ; then
+ curr_audit="-audit ${xpstart_auditlevel[$curr]}"
+ fi
+
+ # Set Xprt -XpFile option
+ unset curr_xpfile
+ if [ "${xpstart_xpfile[$curr]}" != "" ] ; then
+ curr_xpfile="-XpFile ${xpstart_xpfile[$curr]}"
+ fi
+
+ # Set custom XPCONFIGDIR (if there is one)
+ unset XPCONFIGDIR
+ if [ "${xpstart_xpconfigdir[$curr]}" != "" ] ; then
+ export XPCONFIGDIR="${xpstart_xpconfigdir[$curr]}"
+ fi
+
+ # If someone uses "-nolisten tcp" make sure we do not add a hostname to force local transport
+ if [ "$(echo "${xpstart_options[$curr]}" | egrep "nolisten.*tcp")" != "" ] ; then
+ xp_display=":${xpstart_displayid[$curr]}"
+ else
+ xp_display="${hostname}:${xpstart_displayid[$curr]}"
+ fi
+
+ (
+ (
+ "${xpstart_xprt_binary[$curr]}" \
+ ${xpstart_options[$curr]} \
+ ${curr_xpfile} ${curr_audit} \
+ -fp ${curr_fp} \
+ :${xpstart_displayid[$curr]} &
+ server_pid="$!"
+
+ # Append the new server to the registry
+ lock_server_registry
+ echo "display=${xp_display} display_id=${xpstart_displayid[$curr]} pid=${server_pid}" >>"${XP_SERVERS}"
+ unlock_server_registry
+
+ wait
+ echo "Xprint server pid=${server_pid} done, exitcode=$?."
+
+ # Remove the dead server from the registry
+ # (only if the registry still exists - if /etc/init.d/xprint stop" gets called the registry
+ # will be removed - and we should not re-create it afterwards...)
+ lock_server_registry
+ if [ -f "${XP_SERVERS}" ] ; then
+ x="$(cat "${XP_SERVERS}")" # Store content of file "${XP_SERVERS}" in var "x"
+ echo "${x}" | fgrep -v "display_id=${xpstart_displayid[$curr]} pid=${server_pid}" >"${XP_SERVERS}"
+ fi
+ unlock_server_registry
+ ) 2>&1 | while read i ; do echo "$i" | tee -a "${xpstart_logfile[$curr]}" | ${xpstart_logger[$curr]} ; done
+ ) &
+ )
+ fi
+
+ curr=$(($curr + 1))
+ done
+
+ # Remove tmp. file created by |FindFreeXDisplayNum()|
+ rm -f "${lastdisplaynumreturned_store}"
+
+ # Done.
+ lock_server_registry
+ echo "# EOF." >>"${XP_SERVERS}"
+ unlock_server_registry
+ return 0
+}
+
+
+XCOMM Convenience function to check setup and start Xprt server(s)
+do_start()
+{
+ if [ -f "${XP_SERVERS}" ] ; then
+ numservers="$(do_get_xpserverlist | wc -l)"
+ if [ ${numservers} -gt 0 ] ; then
+ verbose_echo "Xprint servers are already running."
+ return 0
+ else
+ verbose_echo "Old server registry found, cleaning-up..."
+ do_stop
+ fi
+ fi
+
+ # Check if we can write the registry file
+ touch "${XP_SERVERS}" 2>/dev/null
+ if [ ! -f "${XP_SERVERS}" ] ; then
+ error_echo "Cannot create \"${XP_SERVERS}\"."
+ # exit code 4 = user had insufficient privilege (LSB)
+ exit 4
+ fi
+
+ if ! setup_config ; then
+ error_echo "setup_config failed."
+ exit 1
+ fi
+
+ # Provide two paths here - one which simply starts the Xprt servers,
+ # assuming that there is a print spooler already running (or that
+ # ${XPCONFIG}/C/print/Xprinters provides static print queue entries
+ # (like for the PSspooldir print model)) and a 2nd path which
+ # explicitly checks if the print queue daemons are running
+ if true ; then
+ msg "Starting Xprint servers: Xprt."
+ start_servers
+ else
+ # Continue in the background if there is no spooler running yet (that
+ # we don't hold off the boot process nor run in a possible race-condition
+ # when /etc/init.d/lpd was not called yet but the runlevel script waits
+ # for us to finish first ...
+ if is_spooler_running ; then
+ msg "Starting Xprint servers: Xprt."
+ start_servers
+ else
+ msg "Starting Xprint servers (in the background): Xprt."
+ (wait_for_print_spooler ; start_servers) &
+ sleep 5
+ fi
+ fi
+
+ if [ "${CURRLOGNAME}" = "root" -a -d /var/lock/subsys/ ] ; then
+ touch /var/lock/subsys/xprint
+ fi
+}
+
+XCOMM Convenience function to stop Xprt server(s)
+do_stop()
+{
+ msg "Stopping Xprint servers: Xprt."
+
+ lock_server_registry
+ if [ -f "${XP_SERVERS}" ] ; then
+ reglist="$(cat "${XP_SERVERS}")"
+ rm -f "${XP_SERVERS}"
+ fi
+ unlock_server_registry
+
+ if [ "${reglist}" != "" ] ; then
+ echo "${reglist}" |
+ grep "^display=.*:.* pid=[0-9]*$" |
+ while read i ; do
+ (
+ eval ${i}
+ if pexists ${pid} ; then
+ kill ${pid}
+ fi
+
+ # Remove the X sockets/pipes which are not in use anymore
+ # (It would be better if the Xservers would cleanup this
+ # automatically, but most Xservers do not do that... ;-(
+ # Note that this will not work on Solaris where applications
+ # must run with groupid="root" if they want to write into
+ # /tmp/.X11-unix/ and/or /tmp/.X11-pipe/)
+ if [ "${display_id}" != "" ] ; then
+ rm -f "/tmp/.X${display_id}-lock" 2>/dev/null
+ rm -f "/tmp/.X11-unix/X${display_id}" 2>/dev/null
+ rm -f "/tmp/.X11-pipe/X${display_id}" 2>/dev/null
+ fi
+ )
+ done
+ fi
+
+ if [ "${CURRLOGNAME}" = "root" -a -d /var/lock/subsys/ ] ; then
+ rm -f /var/lock/subsys/xprint
+ fi
+
+ # Remove any outstanding (dead) locks and cleanup
+ rm -f "${XP_SERVERS}"
+ kill_dead_registry_locks
+}
+
+XCOMM Convenience function to obtain a list of available Xprint servers
+do_get_xpserverlist()
+{
+ if [ -f "${XP_PER_USER_SERVERS}" -o -f "${XP_GLOBAL_SERVERS}" ] ; then
+ xpserverlist=$(
+ # Enumerate both per-user and global servers (in that order)
+ (
+ [ -f "${XP_PER_USER_SERVERS}" ] && cat "${XP_PER_USER_SERVERS}"
+ [ -f "${XP_GLOBAL_SERVERS}" ] && cat "${XP_GLOBAL_SERVERS}"
+ ) |
+ egrep "^display=.*:.* pid=[0-9]*$|^display=.*:[0-9]*$" |
+ while read i ; do
+ (
+ pid="none"
+ eval ${i}
+ # Check if the Xprt process exists (if possible)
+ if [ "$pid" != "none" ] ; then
+ if pexists ${pid} ; then
+ echo ${display}
+ fi
+ else
+ echo ${display}
+ fi
+ )
+ done | tr "[\n]" " "
+ )
+ # Only produce output if we have some entries...
+ [ "${xpserverlist}" != "" ] && echo "${xpserverlist}"
+ fi
+}
+
+do_restart()
+{
+ msg "Restarting Xprint server(s): Xprt."
+ do_stop
+ sleep 1
+ do_start
+}
+
+do_diag()
+{
+ echo "##### Diag start $(date)."
+
+ # General info
+ echo "## General info start."
+ (
+ echo "PATH=\"${PATH}\""
+ echo "TZ=\"${TZ}\""
+ echo "LANG=\"${LANG}\""
+ echo "uname -a=\"$(uname -a)\""
+ echo "uname -s=\"$(uname -s)\""
+ echo "uname -p=\"$(uname -p)\""
+ echo "uname -i=\"$(uname -i)\""
+ echo "uname -m=\"$(uname -m)\""
+ echo "has /etc/SuSE-release ... $([ -f "/etc/SuSE-release" ] && echo "yes" || echo "no")"
+ echo "has /etc/redhat-release ... $([ -f "/etc/redhat-release" ] && echo "yes" || echo "no")"
+ echo "has /etc/debian_version ... $([ -f "/etc/debian_version" ] && echo "yes" || echo "no")"
+ echo "how many Xprt servers are running ...$(ps -ef | fgrep Xprt | fgrep -v "grep" | wc -l)"
+ ) 2>&1 | while read i ; do echo " $i" ; done
+ echo "## General info end."
+
+ # Testing font paths
+ echo "## Testing font paths start."
+ (
+ get_system_fontlist |
+ filter_unsupported_fonts |
+ sort_scaleable_fonts_first |
+ validate_fontlist | while read d ; do
+ echo "#### Testing \"${d}\" ..."
+ if [ ! -d "$d" ] ; then
+ echo "# Error: $d does not exists."
+ continue
+ fi
+ if [ ! -r "$d" ] ; then
+ echo "# Error: $d not readable."
+ continue
+ fi
+ if [ ! -f "${d}/fonts.dir" ] ; then
+ echo "# Error: ${d}/fonts.dir not found."
+ continue
+ else
+ if [ ! -r "${d}/fonts.dir" ] ; then
+ echo "# Error: ${d}/fonts.dir not readable."
+ continue
+ fi
+ fi
+ if [ -f "${d}/fonts.alias" ] ; then
+ if [ ! -r "${d}/fonts.alias" ] ; then
+ echo "# Error: ${d}/fonts.alias not readable."
+ fi
+ fi
+
+ if [ "$(cat "${d}/fonts.dir" | fgrep 'cursor')" != "" ] ; then
+ echo "${d}/fonts.dir has cursor font."
+ fi
+ if [ "$(cat "${d}/fonts.dir" | fgrep 'fixed')" != "" ] ; then
+ echo "${d}/fonts.dir has fixed font."
+ fi
+
+ if [ -r "${d}/fonts.alias" ] ; then
+ if [ "$(cat "${d}/fonts.alias" | fgrep 'cursor')" != "" ] ; then
+ echo "${d}/fonts.alias has cursor font."
+ fi
+ if [ "$(cat "${d}/fonts.alias" | fgrep 'fixed')" != "" ] ; then
+ echo "${d}/fonts.alias has fixed font."
+ fi
+ fi
+
+ linenum=0
+ cat "${d}/fonts.dir" | while read i1 i2 i3 i4 ; do
+ linenum=$((${linenum} + 1))
+ [ ${linenum} -eq 1 ] && continue
+
+ if [ ! -f "${d}/${i1}" ] ; then
+ echo "ERROR: ${d}/fonts.dir line ${linenum} has non-exististant font \"${i1}\" (=\"${i1} ${i2} ${i3} ${i4}\")"
+ fi
+ done
+ done
+ ) 2>&1 | while read i ; do echo " $i" ; done
+ echo "## Testing font paths end."
+
+ echo "##### Diag End $(date)."
+}
+
+XCOMM Set platform-defaults for setup_config()
+setup_config_defaults()
+{
+ curr_num_xpstart="${1}"
+
+ #### Defaults for Linux/Solaris
+ # Start Xprt using builtin XPCONFIGDIR at a free display numer
+ # (Solaris(=SunOS5.x)'s /usr/openwin/bin/Xprt supports TrueType fonts,
+ # therefore we don't need to filter them)
+ xpstart_fontpath[${curr_num_xpstart}]="";
+ xpstart_fontpath_acceptpattern[${curr_num_xpstart}]=".*";
+ xpstart_fontpath_rejectpattern[${curr_num_xpstart}]="/Speedo|/F3bitmaps|/F3";
+ xpstart_displayid[${curr_num_xpstart}]="";
+ xpstart_xpconfigdir[${curr_num_xpstart}]="";
+ xpstart_xpfile[${curr_num_xpstart}]="";
+ xpstart_auditlevel[${curr_num_xpstart}]="4";
+ xpstart_options[${curr_num_xpstart}]="";
+ xpstart_logger[${curr_num_xpstart}]="";
+ # Check whether we have /dev/stderr (needed for old AIX + old Debian)
+ if [ -w "/dev/stderr" ] ; then
+ xpstart_logfile[${curr_num_xpstart}]="/dev/stderr";
+ else
+ xpstart_logfile[${curr_num_xpstart}]="/dev/tty";
+ fi
+ xpstart_xprt_binary[${curr_num_xpstart}]="";
+
+ # Custom rules for the GISWxprintglue package on Solaris
+ # (which uses Solaris's /usr/openwin/bin/Xprt but a custom config)
+ if [ "${XPCUSTOMGLUE}" = "GISWxprintglue" ] ; then
+ xpstart_xpconfigdir[${curr_num_xpstart}]="/opt/GISWxprintglue/server/etc/XpConfig"
+ xpstart_xprt_binary[${curr_num_xpstart}]="/usr/openwin/bin/Xprt"
+ fi
+ # Custom rules for the GISWxprint package on Solaris
+ # (which uses both it's own Xprt and a custom config)
+ if [ "${XPCUSTOMGLUE}" = "GISWxprint" ] ; then
+ xpstart_xpconfigdir[${curr_num_xpstart}]="/opt/GISWxprint/server/etc/XpConfig"
+ xpstart_xprt_binary[${curr_num_xpstart}]="/opt/GISWxprint/bin/Xprt"
+ xpstart_font_encodings_dir[${curr_num_xpstart}]="/opt/GISWxprint/lib/X11/fonts/encodings/encodings.dir"
+ fi
+
+ #######################################################
+ ###
+ ### Debian Xprint package default configuration
+ ###
+ if [ "${XPCUSTOMGLUE}" = "DebianGlue" ] ; then
+ # Set XPCONFIGDIR=/usr/share/Xprint/xserver
+ xpstart_xpconfigdir[${curr_num_xpstart}]="/usr/share/Xprint/xserver";
+
+ # Use fixed display ID (":64"), or else all client programs will have to be
+ # restarted simply to update XPSERVERLIST to the latest ID when upgrading,
+ # which would be a nightmare.
+ xpstart_displayid[${curr_num_xpstart}]=64;
+
+ # Do not send any messages to console
+ xpstart_logfile[${curr_num_xpstart}]="/dev/null";
+
+ # By default use binary provided by Debian's "xprt-xprintorg" package
+ # (=/usr/bin/Xprt), otherwise leave blank (e.g. use script's default
+ # (=/usr/X11R6/bin/Xprt))
+ if [ -x "/usr/bin/Xprt" ] ; then
+ xpstart_xprt_binary[${curr_num_xpstart}]="/usr/bin/Xprt";
+ fi
+ fi
+ ###
+ ### End Debian default configuration
+ ###
+ #######################################################
+}
+
+fetch_etc_initd_xprint_envvars()
+{
+ curr_num_xpstart="${1}"
+
+ ## Process some $ETC_INITD_XPRINT_* vars after all which may be used by
+ # a user to override the hardcoded values here when starting Xprt per-user
+ # (a more flexible way is to provide an own setup config script in
+ # "~./Xprint_per_user_startup" - see above)
+ if [ "${ETC_INITD_XPRINT_XPRT_PATH}" != "" ] ; then
+ xpstart_xprt_binary[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPRT_PATH}"
+ fi
+ if [ "${ETC_INITD_XPRINT_XPCONFIGDIR}" != "" ] ; then
+ xpstart_xpconfigdir[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPCONFIGDIR}"
+ fi
+ if [ "${ETC_INITD_XPRINT_XPFILE}" != "" ] ; then
+ xpstart_xpfile[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPFILE}"
+ fi
+ if [ "${ETC_INITD_XPRINT_LOGFILE}" != "" ] ; then
+ xpstart_logfile[${curr_num_xpstart}]="${ETC_INITD_XPRINT_LOGFILE}"
+ fi
+ if [ "${ETC_INITD_XPRINT_DISPLAYID}" != "" ] ; then
+ xpstart_displayid[${curr_num_xpstart}]="${ETC_INITD_XPRINT_DISPLAYID}"
+ fi
+ if [ "${ETC_INITD_XPRINT_FONTPATH}" != "" ] ; then
+ xpstart_fontpath[${curr_num_xpstart}]="${ETC_INITD_XPRINT_FONTPATH}"
+ fi
+ if [ "${ETC_INITD_XPRINT_XPRT_OPTIONS}" != "" ] ; then
+ xpstart_options[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPRT_OPTIONS}"
+ fi
+ if [ "${ETC_INITD_XPRINT_AUDITLEVEL}" != "" ] ; then
+ xpstart_auditlevel[${curr_num_xpstart}]="${ETC_INITD_XPRINT_AUDITLEVEL}"
+ fi
+ if [ "${ETC_INITD_XPRINT_XF86ENCODINGSDIR}" != "" ] ; then
+ xpstart_font_encodings_dir[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XF86ENCODINGSDIR}"
+ fi
+}
+
+XCOMM###########################################################################
+XCOMM setup_config() sets the configuration parameters used to start one
+XCOMM or more Xprint servers ("Xprt").
+XCOMM The following variables are used:
+XCOMM - "num_xpstart" - number of servers to start
+XCOMM - "xpstart_fontpath[index]" - custom font path. Leave blank if you want
+XCOMM the platform-specific default
+XCOMM - "xpstart_fontpath_acceptpattern[index]" - extended regular expression
+XCOMM (see egrep(1)) used to filter the font path - items only pass this
+XCOMM filter if they match the pattern (leave blank if you want to filter
+XCOMM nothing)
+XCOMM - "xpstart_fontpath_rejectpattern[index]" - extended regular expression
+XCOMM (see egrep(1)) used to filter the font path - items only pass this
+XCOMM filter if they do not match the pattern (leave blank if you want to
+XCOMM filter nothing)
+XCOMM - "xpstart_font_encodings_dir[index]" - location of "encodings.dir".
+XCOMM Leave blank to use the default.
+XCOMM - "xpstart_displayid[index]" - display id to use for the Xprint server
+XCOMM (leave blank to choose the next available free display id)
+XCOMM - "xpstart_xpconfigdir[index]" - value for custom XPCONFIGDIR (leave blank
+XCOMM if you don not want that that XPCONFIGDIR is set at Xprt startup)
+XCOMM - "xpstart_xpfile[index]" - value used for Xprt's "-XpFile" option (leave
+XCOMM blank if you do not want to set this option)
+XCOMM - "xpstart_auditlevel[index]" - set Xserver auditing level (leave blank to
+XCOMM use no auditing)
+XCOMM - "xpstart_options[index]" - set further Xprt options (leave blank to set
+XCOMM no further options)
+XCOMM - "xpstart_logger[index]" - utility which gets stderr/stdout messages from
+XCOMM Xprt and sends them to a logging daemon. Leave blank to use /usr/bin/logger
+XCOMM to send such messages to the lpr.notice syslog)
+XCOMM - "xpstart_logfile[index]" - log file to append stderr/stdout messages from
+XCOMM Xprt to. Leave blank to send messages to /dev/null
+XCOMM - "xpstart_xprt_binary[index]" - set custom Xprt binary (leave blank to use
+XCOMM the platform-specifc default)
+setup_config()
+{
+ num_xpstart=0;
+
+ if [ "${ETC_INITD_XPRINT_CUSTOM_SETUP_CONFIG}" != "" ] ; then
+ user_cfg="${ETC_INITD_XPRINT_CUSTOM_SETUP_CONFIG}"
+ else
+ user_cfg="${HOME}/.Xprint_per_user_startup"
+ fi
+
+ # Source per-user ~/.Xprint_per_user_startup file if there is one
+ # (and do not use the script's defaults below)
+ if [ -r "${user_cfg}" ] ; then
+ # Define API version which should be checked by ${HOME}/.Xprint_per_user_startup
+ # ${HOME}/.Xprint_per_user_startup should bail-out if the version differ
+ etc_initd_xprint_api_version=2
+
+ # Source per-user settings script
+ . "${user_cfg}"
+
+ # done with setting the config for per-user Xprt instances
+ return 0;
+ else
+ # Use /etc/init.d/xprint's builtin config
+ # Each entry should start with |setup_config_defaults| to pull the
+ # platform defaults and finish with |num_xpstart=$(($num_xpstart + 1))|
+ # to end the entry
+
+ # Set platform-defaults
+ setup_config_defaults "${num_xpstart}"
+
+ ## -- snip --
+
+ # Admins can put their stuff "in" here...
+
+ ## -- snip --
+
+ # Override script's builtin values with those a user may set via the
+ # $ETC_INIITD_XPRINT_* env vars
+ fetch_etc_initd_xprint_envvars "${num_xpstart}"
+
+ num_xpstart=$((${num_xpstart} + 1))
+
+ return 0;
+ fi
+
+ #### Sample 1:
+ # # Start Xprt on a free display ID with custom XPCONFIGDIR and without
+ # # Speedo and TrueType fonts
+ # xpstart_fontpath_rejectpattern[$num_xpstart]="/Speedo|/TrueType|/TT(/$|$)|/TTF(/$|$)";
+ # xpstart_xpconfigdir[$num_xpstart]="/home/gisburn/cwork/Xprint/Xprt_config/XpConfig";
+ # xpstart_auditlevel[$num_xpstart]="4";
+ # xpstart_options[$num_xpstart]="-ac -pn";
+ #num_xpstart=$(($num_xpstart + 1))
+
+
+ #### Sample 2:
+ # # Start Xprt without TrueType fonts on a display 55 with custom
+ # # XPCONFIGDIR
+ # xpstart_fontpath_rejectpattern[$num_xpstart]="/TrueType|/TT(/$|$)|/TTF(/$|$)";
+ # xpstart_displayid[$num_xpstart]=55;
+ # xpstart_xpconfigdir[$num_xpstart]="/home/gisburn/cwork/Xprint/Xprt_config/XpConfig";
+ # xpstart_auditlevel[$num_xpstart]=4;
+ # xpstart_options[$num_xpstart]="-ac -pn";
+ #num_xpstart=$(($num_xpstart + 1))
+
+ #### Sample 3:
+ # # Start Xprt without TrueType fonts on a display 56 with custom
+ # # XPCONFIGDIR and alternate "Xprinters" file
+ # xpstart_fontpath_rejectpattern[$num_xpstart]="/TrueType|/TT(/$|$)|/TTF(/$|$)";
+ # xpstart_displayid[$num_xpstart]=56;
+ # xpstart_xpconfigdir[$num_xpstart]="/etc/XpConfig/default";
+ # xpstart_xpfile[$num_xpstart]="/etc/XpConfig/default/Xprinters_test2"
+ # xpstart_auditlevel[$num_xpstart]="4";
+ # xpstart_options[$num_xpstart]="-ac -pn";
+ # xpstart_xprt_binary[$num_xpstart]="";
+ #num_xpstart=$(($num_xpstart + 1))
+
+ #### Sample 4:
+ # # Start Xprt with Solaris ISO-8859-7 (greek(="el") locale) fonts on
+ # # display 57
+ # xpstart_fontpath[$num_xpstart]="/usr/openwin/lib/locale/iso_8859_7/X11/fonts/75dpi,/usr/openwin/lib/locale/iso_8859_7/X11/fonts/Type1,/usr/openwin/lib/X11/fonts/misc/";
+ # xpstart_fontpath_acceptpattern[$num_xpstart]="";
+ # xpstart_fontpath_rejectpattern[$num_xpstart]="_No_Match_";
+ # xpstart_displayid[$num_xpstart]="57";
+ # xpstart_auditlevel[$num_xpstart]="4";
+ # xpstart_options[$num_xpstart]="-ac -pn";
+ #num_xpstart=$(($num_xpstart + 1))
+
+ #### Sample 5:
+ # # Start Xprt with the font list of an existing Xserver (excluding Speedo fonts) on
+ # # display 58
+ # # Note that this only works within a X session. At system boot time
+ # # there will be no $DISPLAY to fetch the information from!!
+ # xpstart_fontpath[$num_xpstart]="$(get_fontlist_from_display ${DISPLAY} | fontlist2fontpath)";
+ # xpstart_fontpath_acceptpattern[$num_xpstart]="";
+ # xpstart_fontpath_rejectpattern[$num_xpstart]="";
+ # xpstart_displayid[$num_xpstart]="58";
+ # xpstart_xpconfigdir[$num_xpstart]="";
+ # xpstart_auditlevel[$num_xpstart]="4";
+ # xpstart_options[$num_xpstart]="-ac -pn";
+ # xpstart_xprt_binary[$num_xpstart]="";
+ #num_xpstart=$(($num_xpstart + 1))
+
+ #### Sample 6:
+ # # List remote Xprt's here
+ # # (note that there is no test to check whether these DISPLAYs are valid!)
+ # xpstart_remote_server[$num_xpstart]="sera:12" ; num_xpstart=$(($num_xpstart + 1))
+ # xpstart_remote_server[$num_xpstart]="gandalf:19" ; num_xpstart=$(($num_xpstart + 1))
+}
+
+XCOMM###########################################################################
+
+XCOMM Main
+case "$1" in
+ ## Start Xprint servers
+ 'start')
+ do_start
+ ;;
+
+ ## Stop Xprint servers
+ # Note that this does _not_ kill Xprt instances started using this script
+ # by non-root users
+ 'stop')
+ do_stop
+ ;;
+
+ ## Restart Xprint servers
+ 'restart'|'force-reload')
+ do_restart
+ ;;
+
+ ## Reload configuration without stopping and restarting
+ 'reload')
+ # not supported
+ msg "reload not supported, use 'restart' or 'force-reload'"
+ exit 3
+ ;;
+
+ ## Restart Xprint only if it is already running
+ 'condrestart'|'try-restart')
+ # only restart if it is already running
+ [ -f /var/lock/subsys/xprint ] && do_restart || :
+ ;;
+
+ ## Get list of all Xprint servers for this user
+ # (incl. per-user and system-wide instances)
+ 'get_xpserverlist')
+ do_get_xpserverlist
+ ;;
+
+ ## Get status of Xprint servers, RedHat-style
+ 'status')
+ x="$(do_get_xpserverlist)"
+ if [ "${x}" != "" ] ; then
+ msg "Xprint (${x}) is running..."
+ exit 0
+ else
+ msg "Xprint is stopped"
+ exit 3
+ fi
+ ;;
+
+ ## Wrapper
+ 'wrapper')
+ cmd="${2}"
+ [ "${cmd}" = "" ] && fatal_error "No command given."
+ shift ; shift
+ export XPSERVERLIST="$(do_get_xpserverlist)"
+ [ "${XPSERVERLIST}" = "" ] && fatal_error "No Xprint servers found."
+ exec "${cmd}" "$@"
+ ;;
+
+ ## Wrapper for "xplsprinters"
+ 'lsprinters')
+ [ "${ETC_INITD_XPRINT_XPLSPRINTERS_PATH}" != "" ] && cmd="${ETC_INITD_XPRINT_XPLSPRINTERS_PATH}"
+ [ "${cmd}" = "" -a "${XPCUSTOMGLUE}" = "GISWxprintglue" ] && cmd="/opt/GISWxprintglue/bin/xplsprinters"
+ [ "${cmd}" = "" -a "${XPCUSTOMGLUE}" = "GISWxprint" ] && cmd="/opt/GISWxprint/bin/xplsprinters"
+ [ "${cmd}" = "" -a "${XPROJECTROOT}" != "" ] && cmd="${XPROJECTROOT}/bin/xplsprinters"
+ [ "${cmd}" = "" ] && cmd="xplsprinters"
+
+ shift
+ export XPSERVERLIST="$(do_get_xpserverlist)"
+ [ "${XPSERVERLIST}" = "" ] && fatal_error "No Xprint servers found."
+ exec "${cmd}" "$@"
+ ;;
+
+ ## Diagnostics
+ 'diag')
+ do_diag
+ ;;
+
+ ## Print usage
+ *)
+ msg "Usage: $0 { start | stop | restart | reload | force-reload | status | condrestart | try-restart | wrapper | lsprinters | get_xpserverlist | diag }"
+ exit 2
+esac
+exit 0
+
+XCOMM EOF.
diff --git a/Xprint/mediaSizes.c b/Xprint/mediaSizes.c
index b24f5c6c0..12482b281 100644
--- a/Xprint/mediaSizes.c
+++ b/Xprint/mediaSizes.c
@@ -30,8 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/mediaSizes.c,v 1.4 2001/01/17 22:36:28 dawes Exp $ */
-
/*******************************************************************
**
** *********************************************************
@@ -130,6 +128,14 @@ static PageDimensionsRec PageDimensions[] =
{xpoid_val_medium_size_jis_b8, 64, 91},
{xpoid_val_medium_size_jis_b9, 45, 64},
{xpoid_val_medium_size_jis_b10, 32, 45},
+ {xpoid_val_medium_size_hp_2x_postcard, 148, 200},
+ {xpoid_val_medium_size_hp_european_edp, 304.8, 355.6},
+ {xpoid_val_medium_size_hp_mini, 139.7, 215.9},
+ {xpoid_val_medium_size_hp_postcard, 100, 148},
+ {xpoid_val_medium_size_hp_tabloid, 279.4, 431.8},
+ {xpoid_val_medium_size_hp_us_edp, 279.4, 355.6},
+ {xpoid_val_medium_size_hp_us_government_legal, 203.2, 330.2},
+ {xpoid_val_medium_size_hp_us_government_letter, 203.2, 254},
{xpoid_val_medium_size_iso_c3, 324, 458},
{xpoid_val_medium_size_iso_c4, 229, 324},
{xpoid_val_medium_size_iso_c5, 162, 229},
@@ -145,7 +151,8 @@ static PageDimensionsRec PageDimensions[] =
* attributes pools have been validated.
*/
int
-XpGetResolution(XpContextPtr pContext)
+XpGetResolution(
+ XpContextPtr pContext)
{
unsigned long resolution;
@@ -185,7 +192,8 @@ XpGetResolution(XpContextPtr pContext)
* attributes pools have been validated.
*/
XpOid
-XpGetContentOrientation(XpContextPtr pContext)
+XpGetContentOrientation(
+ XpContextPtr pContext)
{
XpOid orientation;
@@ -415,7 +423,7 @@ XpGetMediumMillimeters(
float *width, /* return */
float *height) /* return */
{
- unsigned i;
+ int i;
*width = *height = 0;
for(i = 0; i < XpNumber(PageDimensions); i++)
@@ -739,7 +747,9 @@ XpGetMaxWidthHeightRes(
}
FontResolutionPtr
-XpGetClientResolutions(ClientPtr client, int *num)
+XpGetClientResolutions(client, num)
+ ClientPtr client;
+ int *num;
{
static struct _FontResolution res;
int resolution = XpGetResolution(XpContextOfClient(client));
@@ -755,13 +765,15 @@ XpGetClientResolutions(ClientPtr client, int *num)
}
-void XpSetFontResFunc(ClientPtr client)
+void XpSetFontResFunc(client)
+ ClientPtr client;
{
client->fontResFunc = XpGetClientResolutions;
}
-void XpUnsetFontResFunc(ClientPtr client)
+void XpUnsetFontResFunc(client)
+ ClientPtr client;
{
client->fontResFunc = NULL;
}
diff --git a/Xprint/ps/Ps.h b/Xprint/ps/Ps.h
index d33f301fa..6bde70f47 100644
--- a/Xprint/ps/Ps.h
+++ b/Xprint/ps/Ps.h
@@ -7,6 +7,7 @@ Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
+documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
@@ -73,7 +74,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/Ps.h,v 1.13 2001/12/21 21:02:05 dawes Exp $ */
#ifndef _PS_H_
#define _PS_H_
@@ -113,6 +113,7 @@ typedef char *XPointer;
#include <X11/Xresource.h>
#include "attributes.h"
+
/*
* Public index variables from PsInit.c
*/
@@ -245,10 +246,66 @@ typedef DisplayListRec *DisplayListPtr;
typedef struct
{
XrmDatabase resDB;
- ColormapPtr CMap;
Bool (*DestroyWindow)(WindowPtr);
} PsScreenPrivRec, *PsScreenPrivPtr;
+typedef struct PsFontTypeInfoRec PsFontTypeInfoRec;
+
+/* Structure to hold information about one font on disk
+ * Notes:
+ * - multiple XLFD names can refer to the same |PsFontTypeInfoRec| (if
+ * they all use the same font on the disk)
+ * - the FreeType font download code uses multiple |PsFontTypeInfoRec|
+ * records for one font on disk if they differ in the encoding being
+ * used (this is an exception from the
+ * 'one-|PsFontTypeInfoRec|-per-font-on-disk'-design; maybe it it is better
+ * to rework that in a later step and add a new per-encoding structure).
+ */
+struct PsFontTypeInfoRec
+{
+ PsFontTypeInfoRec *next; /* Next record in list... */
+ char *adobe_ps_name; /* PostScript font name (from the
+ * "_ADOBE_POSTSCRIPT_FONTNAME" atom) */
+ char *download_ps_name; /* PostScript font name used for font download */
+ char *filename; /* File name of font */
+#ifdef XP_USE_FREETYPE
+ char *ft_download_encoding; /* encoding used for download */
+ PsFTDownloadFontType ft_download_font_type; /* PS font type used for download (e.g. Type1/Type3/CID/etc.) */
+#endif /* XP_USE_FREETYPE */
+ int is_iso_encoding; /* Is this font encoded in ISO Latin 1 ? */
+ int font_type; /* See PSFTI_FONT_TYPE_* below... */
+ Bool downloadableFont; /* Font can be downloaded */
+ Bool alreadyDownloaded[256]; /* Font has been downloaded (for 256 8bit "sub"-font) */
+};
+
+#define PSFTI_FONT_TYPE_OTHER (0)
+#define PSFTI_FONT_TYPE_PMF (1)
+#define PSFTI_FONT_TYPE_PS_TYPE1_PFA (2)
+#define PSFTI_FONT_TYPE_PS_TYPE1_PFB (3)
+#define PSFTI_FONT_TYPE_TRUETYPE (4)
+/* PSFTI_FONT_TYPE_FREETYPE is means the font is handled by the freetype engine */
+#define PSFTI_FONT_TYPE_FREETYPE (5)
+
+typedef struct PsFontInfoRec PsFontInfoRec;
+
+/* Structure which represents our context info for a single XLFD font
+ * Note that multiple |PsFontInfoRec| records can share the same
+ * |PsFontTypeInfoRec| record - the |PsFontInfoRec| records represent
+ * different appearances of the same font on disk(=|PsFontTypeInfoRec|)).
+ */
+struct PsFontInfoRec
+{
+ PsFontInfoRec *next; /* Next record in list... */
+ /* |font| and |font_fontPrivate| are used by |PsFindFontInfoRec()| to
+ * identify a font */
+ FontPtr font; /* The font this record is for */
+ pointer font_fontPrivate;
+ PsFontTypeInfoRec *ftir; /* Record about the font file on disk */
+ const char *dfl_name; /* XLFD for this font */
+ int size; /* Font size. Use |mtx| if |size==0| */
+ float mtx[4]; /* Transformation matrix (see |size|) */
+};
+
typedef struct
{
char *jobFileName;
@@ -259,6 +316,8 @@ typedef struct
ClientPtr getDocClient;
int getDocBufSize;
PsOutPtr pPsOut;
+ PsFontTypeInfoRec *fontTypeInfoRecords;
+ PsFontInfoRec *fontInfoRecords;
} PsContextPrivRec, *PsContextPrivPtr;
typedef struct
@@ -291,6 +350,7 @@ typedef struct
extern Bool InitializePsDriver(int ndx, ScreenPtr pScreen, int argc,
char **argv);
+static Bool PsDestroyContext(XpContextPtr pCon);
extern XpContextPtr PsGetContextFromWindow(WindowPtr win);
/*
@@ -314,6 +374,10 @@ extern int PsGetDocumentData(XpContextPtr pCon, ClientPtr client,
*/
extern Bool PsCreateGC(GCPtr pGC);
+static int PsGetDrawablePrivateStuff(DrawablePtr pDrawable, GC *gc,
+ unsigned long *valid, PsOutPtr *psOut,
+ ColormapPtr *cMap);
+extern PsContextPrivPtr PsGetPsContextPriv( DrawablePtr pDrawable );
extern int PsUpdateDrawableGC(GCPtr pGC, DrawablePtr pDrawable,
PsOutPtr *psOut, ColormapPtr *cMap);
extern void PsValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
@@ -366,9 +430,8 @@ extern void PsPutScaledImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
extern void PsPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
int x, int y, int w, int h, int leftPad, int format,
char *pImage);
-extern void PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth,
- int x, int y, int w, int h, int leftPad, int format,
- char *pImage);
+extern void PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, char *pImage);
extern RegionPtr PsCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
int srcx, int srcy, int width, int height,
int dstx, int dsty);
@@ -456,7 +519,19 @@ extern Bool PsUnrealizeFont(ScreenPtr pscr, FontPtr pFont);
extern char *PsGetFontName(FontPtr pFont);
extern int PsGetFontSize(FontPtr pFont, float *mtx);
extern char *PsGetPSFontName(FontPtr pFont);
+extern char *PsGetPSFaceOrFontName(FontPtr pFont);
extern int PsIsISOLatin1Encoding(FontPtr pFont);
+extern char *PsGetEncodingName(FontPtr pFont);
+extern PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont);
+extern void PsFreeFontInfoRecords(PsContextPrivPtr priv);
+extern PsFTDownloadFontType PsGetFTDownloadFontType(void);
+
+/*
+ * Functions in PsFTFonts.c
+ */
+
+extern char *PsGetFTFontFileName(FontPtr pFont);
+extern Bool PsIsFreeTypeFont(FontPtr pFont);
/*
* Functions in PsAttr.c
@@ -503,14 +578,4 @@ extern PsElmPtr PsCreateFillElementList(PixmapPtr pix, int *nElms);
extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms);
extern void PsDestroyFillElementList(int nElms, PsElmPtr elms);
-/*
- * Functions in PsCache.c
- */
-
-#ifdef BM_CACHE
-extern int PsBmIsImageCached(int gWidth, int gHeight, char *pBuffer);
-extern int PsBmPutImageInCache(int gWidth, int gHeight, char *pBuffer);
-extern void PsBmClearImageCache(void);
-#endif
-
#endif /* _PS_H_ */
diff --git a/Xprint/ps/PsArea.c b/Xprint/ps/PsArea.c
index eed650ada..134686a87 100644
--- a/Xprint/ps/PsArea.c
+++ b/Xprint/ps/PsArea.c
@@ -228,7 +228,7 @@ error:
return;
}
-static void
+void
PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
int w, int h, int leftPad, int format, int imageRes, char *pImage)
{
@@ -269,9 +269,9 @@ PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
ColormapPtr cMap;
int pageRes, sw, sh;
#ifdef BM_CACHE
- long cache_id = 0;
+ long cache_id = 0;
#endif
-
+
if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
if (!imageRes) {
sw = w;
@@ -296,100 +296,100 @@ PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
PsOut_BeginImageCache(psOut, cache_id);
#endif
- if( depth==24 )
- {
- PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3);
- if( format==XYPixmap )
+ if( depth==24 )
{
- int rowsiz = PixmapBytePad(w, depth);
- char *planes[3];
- planes[0] = pImage;
- planes[1] = &pImage[rowsiz*h];
- planes[2] = &pImage[rowsiz*h*2];
- for( r=0 ; r<h ; r++ )
+ PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3);
+ if( format==XYPixmap )
{
- char *pt[3];
- for( i=0 ; i<3 ; i++ ) pt[i] = &planes[i][rowsiz*r];
- for( c=0 ; c<w ; c++ )
+ int rowsiz = PixmapBytePad(w, depth);
+ char *planes[3];
+ planes[0] = pImage;
+ planes[1] = &pImage[rowsiz*h];
+ planes[2] = &pImage[rowsiz*h*2];
+ for( r=0 ; r<h ; r++ )
{
- for( i=0 ; i<3 ; i++ )
- { PsOut_OutImageBytes(psOut, 1, &pt[i][c]); pt[i]++; }
+ char *pt[3];
+ for( i=0 ; i<3 ; i++ ) pt[i] = &planes[i][rowsiz*r];
+ for( c=0 ; c<w ; c++ )
+ {
+ for( i=0 ; i<3 ; i++ )
+ { PsOut_OutImageBytes(psOut, 1, &pt[i][c]); pt[i]++; }
+ }
+ }
+ }
+ else if( format==ZPixmap )
+ {
+ int rowsiz = PixmapBytePad(w, depth);
+ for( r=0 ; r<h ; r++ )
+ {
+ char *pt = &pImage[rowsiz*r];
+ for( c=0 ; c<w ; c++,pt+=4 )
+ {
+ if( swap )
+ {
+ char tmp[4];
+ tmp[0] = pt[3]; tmp[1] = pt[2]; tmp[2] = pt[1]; tmp[3] = pt[0];
+ PsOut_OutImageBytes(psOut, 3, &tmp[1]);
+ }
+ else
+ PsOut_OutImageBytes(psOut, 3, &pt[1]);
+ }
}
}
+ else goto error;
+ PsOut_EndImage(psOut);
}
- else if( format==ZPixmap )
+ else if( depth==8 )
{
int rowsiz = PixmapBytePad(w, depth);
+ PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3);
for( r=0 ; r<h ; r++ )
{
char *pt = &pImage[rowsiz*r];
- for( c=0 ; c<w ; c++,pt+=4 )
+ for( c=0 ; c<w ; c++,pt++ )
{
+ int val = PsGetPixelColor(cMap, (int)(*pt)&0xFF);
+ char *ipt = (char *)&val;
if( swap )
{
char tmp[4];
- tmp[0] = pt[3]; tmp[1] = pt[2]; tmp[2] = pt[1]; tmp[3] = pt[0];
+ tmp[0] = ipt[3]; tmp[1] = ipt[2]; tmp[2] = ipt[1]; tmp[3] = ipt[0];
PsOut_OutImageBytes(psOut, 3, &tmp[1]);
}
else
- PsOut_OutImageBytes(psOut, 3, &pt[1]);
+ PsOut_OutImageBytes(psOut, 3, &ipt[1]);
}
}
+ PsOut_EndImage(psOut);
}
- else goto error;
- PsOut_EndImage(psOut);
- }
- else if( depth==8 )
- {
- int rowsiz = PixmapBytePad(w, depth);
- PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3);
- for( r=0 ; r<h ; r++ )
- {
- char *pt = &pImage[rowsiz*r];
- for( c=0 ; c<w ; c++,pt++ )
- {
- int val = PsGetPixelColor(cMap, (int)(*pt)&0xFF);
- char *ipt = (char *)&val;
- if( swap )
- {
- char tmp[4];
- tmp[0] = ipt[3]; tmp[1] = ipt[2]; tmp[2] = ipt[1]; tmp[3] = ipt[0];
- PsOut_OutImageBytes(psOut, 3, &tmp[1]);
- }
- else
- PsOut_OutImageBytes(psOut, 3, &ipt[1]);
- }
- }
- PsOut_EndImage(psOut);
- }
- else if( depth==1 )
- {
+ else if( depth==1 )
{
- int rowsiz = BitmapBytePad(w);
- int psrsiz = (w+7)/8;
- PsOut_BeginImageIM(psOut, PsGetPixelColor(cMap, pGC->bgPixel),
- PsGetPixelColor(cMap, pGC->fgPixel),
- x, y, w, h, sw, sh, 1);
- for( r=0 ; r<h ; r++ )
{
- char *pt = &pImage[rowsiz*r];
- for( i=0 ; i<psrsiz ; i++ )
+ int rowsiz = BitmapBytePad(w);
+ int psrsiz = (w+7)/8;
+ PsOut_BeginImageIM(psOut, PsGetPixelColor(cMap, pGC->bgPixel),
+ PsGetPixelColor(cMap, pGC->fgPixel),
+ x, y, w, h, sw, sh, 1);
+ for( r=0 ; r<h ; r++ )
{
- int iv_, iv = (int)pt[i]&0xFF;
- char c;
- if( swap )
- { for( j=0,iv_=0 ; j<8 ; j++ ) iv_ |= (((iv>>j)&1)<<(7-j)); }
- else
- iv_ = iv;
- c = iv_;
- PsOut_OutImageBytes(psOut, 1, &c);
+ char *pt = &pImage[rowsiz*r];
+ for( i=0 ; i<psrsiz ; i++ )
+ {
+ int iv_, iv = (int)pt[i]&0xFF;
+ char c;
+ if( swap )
+ { for( j=0,iv_=0 ; j<8 ; j++ ) iv_ |= (((iv>>j)&1)<<(7-j)); }
+ else
+ iv_ = iv;
+ c = iv_;
+ PsOut_OutImageBytes(psOut, 1, &c);
+ }
}
+ PsOut_EndImage(psOut);
}
- PsOut_EndImage(psOut);
}
- }
#ifdef BM_CACHE
- PsOut_EndImageCache(psOut);
+ PsOut_EndImageCache(psOut);
}
PsOut_ImageCache(psOut, x, y, cache_id, PsGetPixelColor(cMap, pGC->bgPixel),
PsGetPixelColor(cMap, pGC->fgPixel));
diff --git a/Xprint/ps/PsAttVal.c b/Xprint/ps/PsAttVal.c
index 4a7865af6..5ebd0d3b9 100644
--- a/Xprint/ps/PsAttVal.c
+++ b/Xprint/ps/PsAttVal.c
@@ -32,7 +32,6 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsAttVal.c,v 1.4 2001/01/17 22:36:31 dawes Exp $ */
#include "Ps.h"
#include "AttrValid.h"
@@ -73,7 +72,16 @@ static XpOidList DefaultPlexes = {
};
static unsigned long ValidPrinterResolutionsCards[] = {
+ 75,
+ 100,
+ 120,
+ 150,
+ 180,
+ 200,
+ 240,
300,
+ 360,
+ 400,
600,
720,
940,
@@ -86,7 +94,20 @@ static XpOidCardList ValidPrinterResolutions = {
};
static unsigned long DefaultPrinterResolutionsCards[] = {
- 300
+ 75,
+ 100,
+ 120,
+ 150,
+ 180,
+ 200,
+ 240,
+ 300,
+ 360,
+ 400,
+ 600,
+ 720,
+ 940,
+ 1200
};
static XpOidCardList DefaultPrinterResolutions = {
DefaultPrinterResolutionsCards, XpNumber(DefaultPrinterResolutionsCards)
@@ -143,13 +164,6 @@ static XpOidDocFmtList DefaultEmbeddedFormatsSupported = {
DefaultEmbeddedFormatsSupportedFmts, XpNumber(DefaultEmbeddedFormatsSupportedFmts)
};
-/*
-** So filtered printers that accept other raw formats can be
-** used with this driver.
-**
-** Noah Roberts (jik-)
-*/
-#if 0
static XpOidDocFmt ValidRawFormatsSupportedFmts[] = {
{ "Postscript", "2", NULL }
@@ -157,7 +171,6 @@ static XpOidDocFmt ValidRawFormatsSupportedFmts[] = {
static XpOidDocFmtList ValidRawFormatsSupported = {
ValidRawFormatsSupportedFmts, XpNumber(ValidRawFormatsSupportedFmts)
};
-#endif
static XpOidDocFmt DefaultRawFormatsSupportedFmts[] = {
{ "Postscript", "2", NULL }
@@ -178,12 +191,74 @@ static XpOidList ValidInputTrays = {
};
static XpOid ValidMediumSizesOids[] = {
+ xpoid_val_medium_size_iso_a0,
+ xpoid_val_medium_size_iso_a1,
+ xpoid_val_medium_size_iso_a2,
+ xpoid_val_medium_size_iso_a3,
xpoid_val_medium_size_iso_a4,
+ xpoid_val_medium_size_iso_a5,
+ xpoid_val_medium_size_iso_a6,
+ xpoid_val_medium_size_iso_a7,
+ xpoid_val_medium_size_iso_a8,
+ xpoid_val_medium_size_iso_a9,
+ xpoid_val_medium_size_iso_a10,
+ xpoid_val_medium_size_iso_b0,
+ xpoid_val_medium_size_iso_b1,
+ xpoid_val_medium_size_iso_b2,
+ xpoid_val_medium_size_iso_b3,
+ xpoid_val_medium_size_iso_b4,
+ xpoid_val_medium_size_iso_b5,
+ xpoid_val_medium_size_iso_b6,
+ xpoid_val_medium_size_iso_b7,
+ xpoid_val_medium_size_iso_b8,
+ xpoid_val_medium_size_iso_b9,
+ xpoid_val_medium_size_iso_b10,
xpoid_val_medium_size_na_letter,
xpoid_val_medium_size_na_legal,
xpoid_val_medium_size_executive,
+ xpoid_val_medium_size_folio,
+ xpoid_val_medium_size_invoice,
+ xpoid_val_medium_size_ledger,
+ xpoid_val_medium_size_quarto,
+ xpoid_val_medium_size_iso_c3,
+ xpoid_val_medium_size_iso_c4,
+ xpoid_val_medium_size_iso_c5,
+ xpoid_val_medium_size_iso_c6,
xpoid_val_medium_size_iso_designated_long,
- xpoid_val_medium_size_na_number_10_envelope
+ xpoid_val_medium_size_na_10x13_envelope,
+ xpoid_val_medium_size_na_9x12_envelope,
+ xpoid_val_medium_size_na_number_10_envelope,
+ xpoid_val_medium_size_na_7x9_envelope,
+ xpoid_val_medium_size_na_9x11_envelope,
+ xpoid_val_medium_size_na_10x14_envelope,
+ xpoid_val_medium_size_na_number_9_envelope,
+ xpoid_val_medium_size_na_6x9_envelope,
+ xpoid_val_medium_size_na_10x15_envelope,
+ xpoid_val_medium_size_monarch_envelope,
+ xpoid_val_medium_size_a,
+ xpoid_val_medium_size_b,
+ xpoid_val_medium_size_c,
+ xpoid_val_medium_size_d,
+ xpoid_val_medium_size_e,
+ xpoid_val_medium_size_jis_b0,
+ xpoid_val_medium_size_jis_b1,
+ xpoid_val_medium_size_jis_b2,
+ xpoid_val_medium_size_jis_b3,
+ xpoid_val_medium_size_jis_b4,
+ xpoid_val_medium_size_jis_b5,
+ xpoid_val_medium_size_jis_b6,
+ xpoid_val_medium_size_jis_b7,
+ xpoid_val_medium_size_jis_b8,
+ xpoid_val_medium_size_jis_b9,
+ xpoid_val_medium_size_jis_b10,
+ xpoid_val_medium_size_hp_2x_postcard,
+ xpoid_val_medium_size_hp_european_edp,
+ xpoid_val_medium_size_hp_mini,
+ xpoid_val_medium_size_hp_postcard,
+ xpoid_val_medium_size_hp_tabloid,
+ xpoid_val_medium_size_hp_us_edp,
+ xpoid_val_medium_size_hp_us_government_legal,
+ xpoid_val_medium_size_hp_us_government_letter,
};
static XpOidList ValidMediumSizes = {
ValidMediumSizesOids, XpNumber(ValidMediumSizesOids)
@@ -205,7 +280,7 @@ XpValidatePoolsRec PsValidatePoolsRec = {
&ValidPrinterResolutions, &DefaultPrinterResolutions,
&ValidEmbeddedFormatsSupported, &DefaultEmbeddedFormatsSupported,
&ValidListfontsModes, &DefaultListfontsModes,
- NULL /* Any raw format specified (NR)*/, &DefaultRawFormatsSupported,
+ &ValidRawFormatsSupported, &DefaultRawFormatsSupported,
&ValidSetupProviso,
&DefaultDocumentFormat
};
diff --git a/Xprint/ps/PsAttr.c b/Xprint/ps/PsAttr.c
index f276c180f..8a5bee9e3 100644
--- a/Xprint/ps/PsAttr.c
+++ b/Xprint/ps/PsAttr.c
@@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group.
* or other dealings in this Software without prior written authorization
* from said copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsAttr.c,v 1.4 2001/01/17 22:36:32 dawes Exp $ */
/*******************************************************************
**
@@ -76,6 +75,7 @@ in this Software without prior written authorization from The Open Group.
********************************************************************/
#include "Ps.h"
+#include "attributes.h"
char *
PsGetAttributes(
diff --git a/Xprint/ps/PsCache.c b/Xprint/ps/PsCache.c
index b688fbba1..8c9f4a926 100644
--- a/Xprint/ps/PsCache.c
+++ b/Xprint/ps/PsCache.c
@@ -79,21 +79,21 @@ in this Software without prior written authorization from The Open Group.
#include "fntfil.h"
#include "fntfilst.h"
-#define GET 0
-#define RESET 1
+#define GET 0
+#define RESET 1
struct bm_cache_list {
- struct bm_cache_list *next;
- struct bm_cache_list *prev;
+ struct bm_cache_list *next;
+ struct bm_cache_list *prev;
int height;
- long id;
+ long id;
char *pBuffer;
};
struct bm_cache_head {
- struct bm_cache_list *head;
- int width;
- struct bm_cache_head *next;
+ struct bm_cache_list *head;
+ int width;
+ struct bm_cache_head *next;
struct bm_cache_head *prev;
};
@@ -106,14 +106,14 @@ PsBmUniqueId(int func)
if(func == RESET)
{
- unique_id = 0;
- return 0;
+ unique_id = 0;
+ return 0;
}
else
- return ++unique_id;
+ return ++unique_id;
}
-int
+int
PsBmIsImageCached(
int gWidth,
int gHeight,
@@ -126,28 +126,28 @@ PsBmIsImageCached(
{
if(pList->width == gWidth)
{
- struct bm_cache_list *pItem = pList->head;
-
- while(pItem != NULL)
- {
- if(pItem->height == gHeight)
- {
- int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight;
-
- if(!memcmp(pItem->pBuffer, pBuffer, sizeof(char)*length))
- {
- return_val = pItem->id;
- break;
- }
- }
- else if(pItem->height > gHeight)
- break;
-
- pItem = pItem->next;
- }
+ struct bm_cache_list *pItem = pList->head;
+
+ while(pItem != NULL)
+ {
+ if(pItem->height == gHeight)
+ {
+ int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight;
+
+ if(!memcmp(pItem->pBuffer, pBuffer, sizeof(char)*length))
+ {
+ return_val = pItem->id;
+ break;
+ }
+ }
+ else if(pItem->height > gHeight)
+ break;
+
+ pItem = pItem->next;
+ }
}
- else if(pList->width > gWidth)
- break;
+ else if(pList->width > gWidth)
+ break;
pList = pList->next;
}
@@ -180,39 +180,39 @@ PsBmPutImageInCache(
while(pList != NULL)
{
if(pList->width == gWidth)
- {
- struct bm_cache_list *pItem = pList->head;
-
- while(pItem != NULL)
- {
- if(pItem->height >= gHeight)
- {
- pNew->next = pItem;
- pNew->prev = pItem->prev;
- if(pItem->prev != NULL)
- pItem->prev->next = pNew;
+ {
+ struct bm_cache_list *pItem = pList->head;
+
+ while(pItem != NULL)
+ {
+ if(pItem->height >= gHeight)
+ {
+ pNew->next = pItem;
+ pNew->prev = pItem->prev;
+ if(pItem->prev != NULL)
+ pItem->prev->next = pNew;
else
- pList->head = pNew;
+ pList->head = pNew;
pItem->prev = pNew;
- return_val = pNew->id;
+ return_val = pNew->id;
- break;
- }
- else if(pItem->next == NULL)
- {
- pNew->prev = pItem;
- pItem->next = pNew;
+ break;
+ }
+ else if(pItem->next == NULL)
+ {
+ pNew->prev = pItem;
+ pItem->next = pNew;
- return_val = pNew->id;
+ return_val = pNew->id;
- break;
- }
+ break;
+ }
- pItem = pItem->next;
- }
+ pItem = pItem->next;
+ }
- break;
+ break;
}
pList = pList->next;
@@ -223,50 +223,50 @@ PsBmPutImageInCache(
struct bm_cache_head *pNewList;
pNewList = (struct bm_cache_head *)malloc(sizeof(struct bm_cache_head));
-
+
pNewList->next = NULL;
pNewList->prev = NULL;
pNewList->width = gWidth;
pNewList->head = pNew;
-
+
if(bm_cache == NULL)
{
- bm_cache = pNewList;
- return_val = pNew->id;
+ bm_cache = pNewList;
+ return_val = pNew->id;
}
else
{
- pList = bm_cache;
+ pList = bm_cache;
- while(pList != NULL)
- {
- if(pList->width > gWidth)
- {
- pNewList->next = pList;
- pNewList->prev = pList->prev;
+ while(pList != NULL)
+ {
+ if(pList->width > gWidth)
+ {
+ pNewList->next = pList;
+ pNewList->prev = pList->prev;
- if(pList->prev != NULL)
- pList->prev->next = pNewList;
+ if(pList->prev != NULL)
+ pList->prev->next = pNewList;
else
- bm_cache = pNewList;
- pList->prev = pNewList;
+ bm_cache = pNewList;
+ pList->prev = pNewList;
- return_val = pNew->id;
+ return_val = pNew->id;
- break;
- }
- else if(pList->next == NULL)
+ break;
+ }
+ else if(pList->next == NULL)
{
- pNewList->prev = pList;
- pList->next = pNewList;
+ pNewList->prev = pList;
+ pList->next = pNewList;
- return_val = pNew->id;
+ return_val = pNew->id;
- break;
- }
+ break;
+ }
- pList = pList->next;
- }
+ pList = pList->next;
+ }
}
}
@@ -280,35 +280,35 @@ PsBmClearImageCacheItem(
{
if(pItem != NULL)
{
- if(pItem->pBuffer != NULL)
- free(pItem->pBuffer);
+ if(pItem->pBuffer != NULL)
+ free(pItem->pBuffer);
pItem->pBuffer = NULL;
- if(pItem->next)
- PsBmClearImageCacheItem(pItem->next);
+ if(pItem->next)
+ PsBmClearImageCacheItem(pItem->next);
pItem->next = NULL;
- free(pItem);
- pItem = NULL;
+ free(pItem);
+ pItem = NULL;
}
}
-static void
+static void
PsBmClearImageCacheList(
struct bm_cache_head *pList)
{
if(pList != NULL)
{
- if(pList->head)
- PsBmClearImageCacheItem(pList->head);
+ if(pList->head)
+ PsBmClearImageCacheItem(pList->head);
pList->head = NULL;
- if(pList->next)
- PsBmClearImageCacheList(pList->next);
+ if(pList->next)
+ PsBmClearImageCacheList(pList->next);
pList->next = NULL;
- free(pList);
- pList = NULL;
+ free(pList);
+ pList = NULL;
}
}
diff --git a/Xprint/ps/PsColor.c b/Xprint/ps/PsColor.c
index 6417410ee..da6c82c1d 100644
--- a/Xprint/ps/PsColor.c
+++ b/Xprint/ps/PsColor.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsColor.c,v 1.2 2001/10/28 03:32:56 tsi Exp $ */
#include "Ps.h"
#include "gcstruct.h"
@@ -86,6 +85,7 @@ PsCreateColormap(ColormapPtr pColor)
int i;
unsigned short rgb;
VisualPtr pVisual = pColor->pVisual;
+ Pixel pix;
if( pVisual->class==TrueColor )
{
@@ -120,9 +120,6 @@ PsDestroyColormap(ColormapPtr pColor)
void
PsInstallColormap(ColormapPtr pColor)
{
- PsScreenPrivPtr pPriv =
- (PsScreenPrivPtr)pColor->pScreen->devPrivates[PsScreenPrivateIndex].ptr;
- pPriv->CMap = pColor;
}
void
diff --git a/Xprint/ps/PsFonts.c b/Xprint/ps/PsFonts.c
index 1f87f7e76..6d0ba1a61 100644
--- a/Xprint/ps/PsFonts.c
+++ b/Xprint/ps/PsFonts.c
@@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group.
* or other dealings in this Software without prior written authorization
* from said copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsFonts.c,v 1.6 2001/12/19 21:55:59 dawes Exp $ */
/*******************************************************************
**
@@ -80,9 +79,15 @@ in this Software without prior written authorization from The Open Group.
#include "dixfontstr.h"
#include "scrnintstr.h"
#include "fontxlfd.h"
+#include "fntfil.h"
+#include "fntfilst.h"
#include "Ps.h"
+#include <ctype.h>
+#include <limits.h>
+#include <sys/stat.h>
+
Bool
PsRealizeFont(
ScreenPtr pscr,
@@ -110,7 +115,7 @@ PsGetFontName(FontPtr pFont)
for( i=0 ; i<nprops ; i++ )
{
- if( (Atom)props[i].name == name )
+ if( (Atom)props[i].name==name )
{ value = props[i].value; break; }
}
if( !value ) return (char *)0;
@@ -145,12 +150,14 @@ PsGetPSFontName(FontPtr pFont)
int i;
int nprops = pFont->info.nprops;
FontPropPtr props = pFont->info.props;
- Atom name = MakeAtom("PRINTER_RESIDENT_FONT", 21, True);
+ /* "_ADOBE_POSTSCRIPT_FONTNAME" maps directly to a PMF OBJ_NAME attribute
+ * name - changing the name will break printer-builtin fonts. */
+ Atom name = MakeAtom("_ADOBE_POSTSCRIPT_FONTNAME", 26, True);
Atom value = (Atom)0;
for( i=0 ; i<nprops ; i++ )
{
- if( (Atom)props[i].name == name )
+ if( (Atom)props[i].name==name )
{ value = props[i].value; break; }
}
if( !value ) return (char *)0;
@@ -171,8 +178,8 @@ PsIsISOLatin1Encoding(FontPtr pFont)
for( i=0 ; i<nprops ; i++ )
{
- if( (Atom)props[i].name == reg ) rv = props[i].value;
- if( (Atom)props[i].name == enc ) ev = props[i].value;
+ if( (Atom)props[i].name==reg ) rv = props[i].value;
+ if( (Atom)props[i].name==enc ) ev = props[i].value;
}
if( rv ) rp = NameForAtom(rv);
if( ev ) ep = NameForAtom(ev);
@@ -184,3 +191,682 @@ PsIsISOLatin1Encoding(FontPtr pFont)
ep[0]!='1' ) return(0);
return(1);
}
+
+/* Return the encoding part of the XLFD (e.g. "*-iso8859-6.8x" etc.)*/
+char *PsGetEncodingName(FontPtr pFont)
+{
+ int i;
+ int nprops = pFont->info.nprops;
+ FontPropPtr props = pFont->info.props;
+ Atom fnt = MakeAtom("FONT", 4, True);
+ Atom reg = MakeAtom("CHARSET_REGISTRY", 16, True);
+ Atom enc = MakeAtom("CHARSET_ENCODING", 16, True);
+ Atom fv = 0, rv = 0, ev = 0;
+ char *fp = 0;
+ char *rp = 0;
+ char *ep = 0;
+ char *encname;
+
+ for( i=0 ; i<nprops ; i++ )
+ {
+ if( props[i].name==fnt ) fv = props[i].value;
+ if( props[i].name==reg ) rv = props[i].value;
+ if( props[i].name==enc ) ev = props[i].value;
+ }
+ if( fv ) fp = NameForAtom(fv);
+ if( rv ) rp = NameForAtom(rv);
+ if( ev ) ep = NameForAtom(ev);
+
+ if( (!rp) || (!ep) || (!fp))
+ return(0);
+
+ encname = fp;
+ encname += strlen(encname) - (strlen(rp) + strlen(ep) + 1);
+
+ return encname;
+}
+
+/* strstr(), case-insensitive */
+static
+char *str_case_str(const char *s, const char *find)
+{
+ size_t len;
+ char c,
+ sc;
+
+ if ((c = tolower(*find++)) != '\0')
+ {
+ len = strlen(find);
+ do
+ {
+ do
+ {
+ if ((sc = tolower(*s++)) == '\0')
+ return NULL;
+ } while (sc != c);
+ } while (strncasecmp(s, find, len) != 0);
+ s--;
+ }
+ return ((char *)s);
+}
+
+/* Check if the font path element is a directory which can be examined
+ * (for example the font may be from a font server
+ * (e.g. pFont->fpe->name == "tcp/:7100"))
+ */
+static
+Bool IsFPEaReadableDir(FontPtr pFont)
+{
+ const char *fpe_name = pFont->fpe->name;
+ if (!fpe_name)
+ return False;
+
+#define MODEL_FONTPATH_PREFIX "PRINTER:"
+#define MODEL_FONTPATH_PREFIX_LEN 8
+ /* Strip model-specific font path prefix if there is one... */
+ if (!strncmp(fpe_name, MODEL_FONTPATH_PREFIX, MODEL_FONTPATH_PREFIX_LEN))
+ fpe_name += MODEL_FONTPATH_PREFIX_LEN;
+
+ if (access(fpe_name, F_OK) == 0)
+ {
+ return True;
+ }
+
+ return False;
+}
+
+static
+char *getFontFilename(FontPtr pFont)
+{
+ FontDirectoryPtr dir;
+ const char *dlfnam;
+ FILE *file;
+ struct stat statb;
+ int count, i, status;
+ char buf[512];
+ char *front, *end, *fn;
+ char font_dir_fname[PATH_MAX], /* Full path of fonts.dir */
+ font_file_fname[PATH_MAX]; /* Name of font file (excluding path) */
+
+#ifdef XP_USE_FREETYPE
+ if( PsIsFreeTypeFont(pFont) )
+ {
+ const char *fontname = PsGetFTFontFileName(pFont);
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFilename: freetype font, file='%s'\n", fontname?fontname:"<NULL>");
+#endif /* DEBUG_gisburn */
+
+ if( !fontname )
+ return NULL;
+
+ return strdup(fontname);
+ }
+#endif /* XP_USE_FREETYPE */
+
+ if (!IsFPEaReadableDir(pFont))
+ {
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFilename: '%s' no valid font path on disk\n", pFont->fpe->name);
+#endif /* DEBUG_gisburn */
+ return NULL;
+ }
+
+ dir = pFont->fpe->private;
+ sprintf(font_dir_fname, "%s%s", dir->directory, "fonts.dir");
+
+ if (!(dlfnam = PsGetFontName(pFont)))
+ return NULL;
+
+ file = fopen(font_dir_fname, "r");
+ if (file)
+ {
+ if (fstat (fileno(file), &statb) == -1)
+ return NULL;
+
+ while( fgets(buf, sizeof(buf)-1, file) )
+ {
+ if ((fn = strstr(buf, " -")))
+ {
+ strcpy(font_file_fname, buf);
+ font_file_fname[fn - buf] = '\0';
+ fn++;
+ if ((front = str_case_str(fn, "normal-")))
+ {
+ fn[front - fn] = '\0';
+ if (str_case_str(dlfnam, fn))
+ {
+ char full_font_file_path[PATH_MAX];
+
+ fclose(file);
+
+ sprintf(full_font_file_path, "%s%s", dir->directory, font_file_fname);
+
+#ifdef xDEBUG_gisburn
+ fprintf(stderr, "getFontFilename: returning '%s'\n", full_font_file_path);
+#endif /* DEBUG_gisburn */
+ return strdup(full_font_file_path);
+ }
+ }
+ }
+ }
+ }
+ font_file_fname[0] = '\0';
+ fclose(file);
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFilename: returning NULL\n");
+#endif /* DEBUG_gisburn */
+
+ return NULL;
+}
+
+static
+PsFontTypeInfoRec *PsFindFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+ PsFontTypeInfoRec *rec;
+ const char *psname;
+ char *font_filename;
+ char *encname;
+#ifdef XP_USE_FREETYPE
+ Bool is_freetypefont;
+#endif /* XP_USE_FREETYPE */
+
+#ifdef XP_USE_FREETYPE
+ is_freetypefont = PsIsFreeTypeFont(pFont);
+#endif /* XP_USE_FREETYPE */
+ encname = PsGetEncodingName(pFont);
+
+ /* First try: Search by PostScript font name */
+ psname = PsGetPSFontName(pFont);
+ if (psname)
+ {
+ for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next )
+ {
+#ifdef XP_USE_FREETYPE
+ if (is_freetypefont)
+ {
+ if (rec->adobe_ps_name)
+ {
+ if ((rec->font_type == PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcmp(rec->adobe_ps_name, psname)) &&
+ (!strcmp(rec->ft_download_encoding, encname)))
+ {
+ return rec;
+ }
+ }
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ {
+ if (rec->adobe_ps_name)
+ {
+ if ((rec->font_type != PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcmp(rec->adobe_ps_name, psname)))
+ {
+ return rec;
+ }
+ }
+ }
+ }
+ }
+
+ /* Last attempt: Search by filename */
+ font_filename = getFontFilename(pFont);
+ if (font_filename)
+ {
+ for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next )
+ {
+ if (rec->filename)
+ {
+#ifdef XP_USE_FREETYPE
+ if (is_freetypefont)
+ {
+ if ( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcasecmp(rec->filename, font_filename)) &&
+ (!strcasecmp(rec->ft_download_encoding, encname)) )
+ {
+ free(font_filename);
+ return rec;
+ }
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ {
+ if ( (rec->font_type != PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcasecmp(rec->filename, font_filename)) )
+ {
+ free(font_filename);
+ return rec;
+ }
+ }
+ }
+ }
+
+ free(font_filename);
+ }
+
+ return NULL;
+}
+
+static
+void PsAddFontTypeInfoRec(DrawablePtr pDrawable, PsFontTypeInfoRec *add_rec)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+
+ /* ToDO: Always move the last used entry to the top that the list get's
+ * sorted in an efficient order... :-) */
+ add_rec->next = cPriv->fontTypeInfoRecords;
+ cPriv->fontTypeInfoRecords = add_rec;
+}
+
+static
+Bool strcaseendswith(const char *str, const char *suffix)
+{
+ const char *s;
+
+ s = str + strlen(str) - strlen(suffix);
+
+ if (!strcasecmp(s, suffix))
+ return True;
+
+ return False;
+}
+
+
+static
+int getFontFileType( const char *filename )
+{
+ int type;
+
+ /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */
+ if( strcaseendswith(filename, ".pfb") )
+ {
+ type = PSFTI_FONT_TYPE_PS_TYPE1_PFB;
+ }
+ /* Is this a Adobe PostScript ASCII font (PFA) ? */
+ else if( strcaseendswith(filename, ".pfa") )
+ {
+ type = PSFTI_FONT_TYPE_PS_TYPE1_PFA;
+ }
+ /* Is this a PMF(=Printer Metrics File) ? */
+ else if( strcaseendswith(filename, ".pmf") )
+ {
+ type = PSFTI_FONT_TYPE_PMF;
+ }
+ /* Is this a TrueType font file ? */
+ else if( strcaseendswith(filename, ".ttf") ||
+ strcaseendswith(filename, ".ttc") ||
+ strcaseendswith(filename, ".otf") ||
+ strcaseendswith(filename, ".otc") )
+ {
+ type = PSFTI_FONT_TYPE_TRUETYPE;
+ }
+ else
+ {
+ type = PSFTI_FONT_TYPE_OTHER;
+ }
+
+#ifdef XP_USE_FREETYPE
+ {
+ XpContextPtr pCon;
+ char *downloadfonts;
+ pCon = XpGetPrintContext(requestingClient);
+ downloadfonts = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-fonts");
+ if( downloadfonts )
+ {
+ /* Should we download PS Type1 fonts as PS Type1||Type3 ? */
+ if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFA) &&
+ (strstr(downloadfonts, "pfa") != NULL) )
+ {
+ type = PSFTI_FONT_TYPE_FREETYPE;
+ }
+
+ if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFB) &&
+ (strstr(downloadfonts, "pfb") != NULL) )
+ {
+ type = PSFTI_FONT_TYPE_FREETYPE;
+ }
+
+ /* Should we download TrueType fonts as PS Type1||Type3 ? */
+ if( (type == PSFTI_FONT_TYPE_TRUETYPE) &&
+ ((strstr(downloadfonts, "ttf") != NULL) ||
+ (strstr(downloadfonts, "ttc") != NULL) ||
+ (strstr(downloadfonts, "otf") != NULL) ||
+ (strstr(downloadfonts, "otc") != NULL)) )
+ {
+ type = PSFTI_FONT_TYPE_FREETYPE;
+ }
+ }
+ }
+#endif /* XP_USE_FREETYPE */
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFileType: '%s' is %d\n", filename, (int)type);
+#endif /* DEBUG_gisburn */
+ return type;
+}
+
+PsFTDownloadFontType PsGetFTDownloadFontType(void)
+{
+ PsFTDownloadFontType downloadfonttype;
+ XpContextPtr pCon;
+ char *psfonttype;
+
+ pCon = XpGetPrintContext(requestingClient);
+ psfonttype = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-font-type");
+
+ if( !psfonttype || !strlen(psfonttype) )
+ {
+ return PsFontType1; /* Default download font type is PS Type1 */
+ }
+
+ if( !strcmp(psfonttype, "bitmap") )
+ {
+ downloadfonttype = PsFontBitmap;
+ }
+ else if( !strcmp(psfonttype, "pstype3") )
+ {
+ downloadfonttype = PsFontType3;
+ }
+ else if( !strcmp(psfonttype, "pstype1") )
+ {
+ downloadfonttype = PsFontType1;
+ }
+ else
+ {
+ FatalError("PS DDX: XPPrinterAttr/xp-psddx-download-freetype-font-type='%s' not implemented\n", psfonttype);
+ return 0; /* NO-OP, FatalError() will call |exit()| */
+ }
+
+ return downloadfonttype;
+}
+
+static
+PsFontTypeInfoRec *PsCreateFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ char *dlfnam;
+ PsFontTypeInfoRec *rec;
+ char *psname;
+
+ if (!(dlfnam = PsGetFontName(pFont)))
+ return NULL;
+
+ if (!(rec = (PsFontTypeInfoRec *)xalloc(sizeof(PsFontTypeInfoRec))))
+ return NULL;
+ memset(rec, 0, sizeof(PsFontTypeInfoRec));
+
+ rec->next = NULL;
+
+ if (rec->filename = getFontFilename(pFont))
+ {
+ rec->font_type = getFontFileType(rec->filename);
+ }
+ else
+ {
+ rec->filename = NULL;
+ rec->font_type = PSFTI_FONT_TYPE_OTHER;
+ }
+
+ rec->adobe_ps_name = PsGetPSFontName(pFont);
+#ifdef XP_USE_FREETYPE
+ rec->ft_download_encoding = PsGetEncodingName(pFont);
+ rec->ft_download_font_type = PsGetFTDownloadFontType();
+#endif /* XP_USE_FREETYPE */
+ rec->download_ps_name = NULL;
+
+#define SET_FONT_DOWNLOAD_STATUS(rec, downloaded) { int i; for (i = 0 ; i < 256 ; i++) { (rec)->alreadyDownloaded[i]=(downloaded); } }
+
+ /* Set some flags based on the font type */
+ switch( rec->font_type )
+ {
+ case PSFTI_FONT_TYPE_PS_TYPE1_PFA:
+ case PSFTI_FONT_TYPE_PS_TYPE1_PFB:
+ rec->downloadableFont = True;
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+
+ case PSFTI_FONT_TYPE_PMF:
+ rec->downloadableFont = True; /* This font is in printer's ROM */
+ SET_FONT_DOWNLOAD_STATUS(rec, True);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+
+ case PSFTI_FONT_TYPE_TRUETYPE:
+ /* Note: TrueType font download not implemented */
+ rec->downloadableFont = False;
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+
+#ifdef XP_USE_FREETYPE
+ case PSFTI_FONT_TYPE_FREETYPE:
+ if( rec->ft_download_font_type == PsFontType1 ||
+ rec->ft_download_font_type == PsFontType3 )
+ {
+ rec->downloadableFont = True;
+ }
+ else
+ {
+ rec->downloadableFont = False;
+ }
+
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = False; /* Freetype--->PS Type1/Type3 uses always non-iso PS encoding for now */
+ break;
+#endif /* XP_USE_FREETYPE */
+
+ case PSFTI_FONT_TYPE_OTHER:
+ default:
+ rec->downloadableFont = False;
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+ }
+
+#ifdef XP_USE_FREETYPE
+ if( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) )
+ {
+ char *s;
+ register int c;
+
+ if( rec->adobe_ps_name )
+ {
+ rec->download_ps_name = malloc(strlen(rec->adobe_ps_name) + strlen(rec->ft_download_encoding) + 2);
+ sprintf(rec->download_ps_name, "%s_%s", rec->adobe_ps_name, rec->ft_download_encoding);
+ }
+ else
+ {
+ /* Unfortunately not all TTF fonts have a PostScript font name (like
+ * Solaris TTF fonts in /usr/openwin/lib/locale/ko.UTF-8/X11/fonts/TrueType,
+ * /usr/openwin/lib/locale/ko/X11/fonts/TrueType) - in this case we
+ * have to generate a font name
+ */
+ char ftfontname[64];
+ static long myfontindex = 0L;
+ sprintf(ftfontname, "psfont_%lx", myfontindex++);
+
+ rec->download_ps_name = malloc(strlen(ftfontname) + strlen(rec->ft_download_encoding) + 2);
+ sprintf(rec->download_ps_name, "%s_%s", ftfontname, rec->ft_download_encoding);
+
+ fprintf(stderr, "PsCreateFontTypeInfoRec: Note: '%s' has no PS font name, using '%s' for now.\n", dlfnam, rec->download_ps_name);
+ }
+
+ /* Make sure the font name we use for download is a valid PS font name */
+ for( s = rec->download_ps_name ; *s != '\0'; s++ )
+ {
+ c = *s;
+
+ /* Check for allowed chars, invalid ones are replaced with a '_'
+ * (and check that the first char is not a digit) */
+ if( !(isalnum(c) || c == '.' || c == '_' || c == '-') || (s==rec->download_ps_name && isdigit(c)) )
+ {
+ *s = '_';
+ }
+ }
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ {
+ if( rec->adobe_ps_name )
+ {
+ rec->download_ps_name = strdup(rec->adobe_ps_name);
+ }
+ else
+ {
+ rec->download_ps_name = NULL;
+ }
+ }
+
+ /* Safeguard - only treat font as downloadable when we have a PS font name!! */
+ if (!rec->download_ps_name && rec->downloadableFont)
+ {
+ /* XXX: Log this message to the log when the logging service has been hook'ed up */
+ fprintf(stderr, "PsCreateFontTypeInfoRec: Safeguard: No PS font name for '%s'!\n", dlfnam);
+ rec->downloadableFont = False;
+ }
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "PsCreateFontTypeInfoRec: Created PsFontTypeInfoRec '%s' ('%s'/'%s')\n",
+ ((rec->filename) ?(rec->filename) :("<null>")),
+ ((rec->adobe_ps_name) ?(rec->adobe_ps_name):("<null>")),
+ ((rec->download_ps_name)?(rec->download_ps_name):("<null>")));
+#endif /* DEBUG_gisburn */
+
+ return rec;
+}
+
+static
+PsFontTypeInfoRec *PsGetFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsFontTypeInfoRec *rec;
+ char *dlfnam;
+
+ if(!(dlfnam = PsGetFontName(pFont)))
+ return NULL;
+
+ rec = PsFindFontTypeInfoRec(pDrawable, pFont);
+ if (rec)
+ return rec;
+
+ rec = PsCreateFontTypeInfoRec(pDrawable, pFont);
+ if (!rec)
+ return NULL;
+
+ PsAddFontTypeInfoRec(pDrawable, rec);
+
+ return rec;
+}
+
+static
+void PsFreeFontTypeInfoRecords( PsContextPrivPtr priv )
+{
+ PsFontTypeInfoRec *curr, *next;
+ curr = priv->fontTypeInfoRecords;
+ while( curr != NULL )
+ {
+ if (curr->filename)
+ free(curr->filename); /* Free memory allocated by |strdup()| */
+
+ if (curr->download_ps_name)
+ free(curr->download_ps_name);
+
+ next = curr->next;
+ xfree(curr);
+ curr = next;
+ }
+}
+
+static
+PsFontInfoRec *PsFindFontInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+ PsFontInfoRec *rec;
+
+ if (!pFont)
+ return NULL;
+
+ for( rec = cPriv->fontInfoRecords ; rec != NULL ; rec = rec->next )
+ {
+ if ((rec->font == pFont) &&
+ (rec->font_fontPrivate == pFont->fontPrivate))
+ return rec;
+ }
+
+ return NULL;
+}
+
+static
+void PsAddFontInfoRec(DrawablePtr pDrawable, PsFontInfoRec *add_rec)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+
+ /* ToDO: Always move the last used entry to the top that the list get's
+ * sorted in an efficient order... :-) */
+ add_rec->next = cPriv->fontInfoRecords;
+ cPriv->fontInfoRecords = add_rec;
+}
+
+static
+PsFontInfoRec *PsCreateFontInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsFontInfoRec *rec;
+ PsFontTypeInfoRec *ftir;
+
+ if (!(ftir = PsGetFontTypeInfoRec(pDrawable, pFont)))
+ return NULL;
+
+ if (!(rec = (PsFontInfoRec *)xalloc(sizeof(PsFontInfoRec))))
+ return NULL;
+ memset(rec, 0, sizeof(PsFontInfoRec));
+
+ rec->font = pFont;
+ rec->font_fontPrivate = pFont->fontPrivate;
+ rec->ftir = ftir;
+ rec->next = NULL;
+ rec->dfl_name = PsGetFontName(pFont);
+ rec->size = PsGetFontSize(pFont, rec->mtx);
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "PsCreateFontInfoRec: Created PsFontInfoRec '%s'\n",
+ ((rec->dfl_name)?(rec->dfl_name):("<null>")));
+#endif /* DEBUG_gisburn */
+
+ return rec;
+}
+
+PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsFontInfoRec *rec;
+
+ rec = PsFindFontInfoRec(pDrawable, pFont);
+ if (rec)
+ return rec;
+
+ rec = PsCreateFontInfoRec(pDrawable, pFont);
+ if (!rec)
+ return NULL;
+
+ PsAddFontInfoRec(pDrawable, rec);
+
+ return rec;
+}
+
+void PsFreeFontInfoRecords( PsContextPrivPtr priv )
+{
+ PsFontInfoRec *curr, *next;
+ curr = priv->fontInfoRecords;
+ while( curr != NULL )
+ {
+ next = curr->next;
+ xfree(curr);
+ curr = next;
+ }
+
+ PsFreeFontTypeInfoRecords(priv);
+
+ priv->fontTypeInfoRecords = NULL;
+ priv->fontInfoRecords = NULL;
+}
diff --git a/Xprint/ps/PsGC.c b/Xprint/ps/PsGC.c
index ea441cff5..78c83930d 100644
--- a/Xprint/ps/PsGC.c
+++ b/Xprint/ps/PsGC.c
@@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group.
* or other dealings in this Software without prior written authorization
* from said copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsGC.c,v 1.6tsi Exp $ */
/*******************************************************************
**
@@ -157,13 +156,19 @@ PsGetDrawablePrivateStuff(
if( pCon==NULL ) return FALSE;
else
{
+ Colormap c;
+ ColormapPtr cmap;
+
+ c = wColormap((WindowPtr)pDrawable);
+ cmap = (ColormapPtr)LookupIDByType(c, RT_COLORMAP);
+
cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr;
sPriv = (PsScreenPrivPtr)
pDrawable->pScreen->devPrivates[PsScreenPrivateIndex].ptr;
*gc = cPriv->lastGC;
*valid = cPriv->validGC;
*psOut = cPriv->pPsOut;
- *cMap = sPriv->CMap;
+ *cMap = cmap;
return TRUE;
}
default:
@@ -171,6 +176,26 @@ PsGetDrawablePrivateStuff(
}
}
+PsContextPrivPtr
+PsGetPsContextPriv( DrawablePtr pDrawable )
+{
+ XpContextPtr pCon;
+ PsContextPrivPtr cPriv;
+
+ switch(pDrawable->type)
+ {
+ case DRAWABLE_PIXMAP:
+ return FALSE;
+ case DRAWABLE_WINDOW:
+ pCon = PsGetContextFromWindow((WindowPtr)pDrawable);
+ if (pCon != NULL)
+ {
+ return pCon->devPrivates[PsContextPrivateIndex].ptr;
+ }
+ }
+ return NULL;
+}
+
int
PsUpdateDrawableGC(
GCPtr pGC,
@@ -181,6 +206,7 @@ PsUpdateDrawableGC(
GC dGC;
unsigned long valid;
int i;
+ PsContextPrivPtr cPriv;
BoxPtr boxes;
if (!PsGetDrawablePrivateStuff(pDrawable, &dGC, &valid, psOut, cMap))
@@ -232,6 +258,8 @@ PsUpdateDrawableGC(
PsOut_Offset(*psOut, pDrawable->x, pDrawable->y);
PsOut_Clip(*psOut, pGC->clientClipType, (PsClipPtr)pGC->clientClip);
}
+ cPriv = ( PsGetContextFromWindow( (WindowPtr)pDrawable ) )
+ ->devPrivates[PsContextPrivateIndex].ptr;
break;
}
return TRUE;
diff --git a/Xprint/ps/PsInit.c b/Xprint/ps/PsInit.c
index a7a63343d..f2e064921 100644
--- a/Xprint/ps/PsInit.c
+++ b/Xprint/ps/PsInit.c
@@ -71,9 +71,8 @@ in this Software without prior written authorization from The Open Group.
** * Copyright: Copyright 1996 The Open Group, Inc.
** *
** *********************************************************
-**
+**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsInit.c,v 1.13tsi Exp $ */
#include <stdio.h>
#include <string.h>
@@ -84,6 +83,7 @@ in this Software without prior written authorization from The Open Group.
#include "Ps.h"
#include "mi.h"
+#include "micmap.h"
#include "AttrValid.h"
#include "../../mfb/mfb.h"
@@ -101,6 +101,10 @@ int PsContextPrivateIndex;
int PsPixmapPrivateIndex;
int PsWindowPrivateIndex;
+#ifdef GLXEXT
+extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
+#endif /* GLXEXT */
+
Bool
InitializePsDriver(ndx, pScreen, argc, argv)
int ndx;
@@ -109,12 +113,18 @@ InitializePsDriver(ndx, pScreen, argc, argv)
char **argv;
{
#if 0
+ int maxXres, maxYres, maxWidth, maxHeight;
+ int maxRes, maxDim, numBytes;
PsScreenPrivPtr pPriv;
#endif
+ char **printerNames;
+ int numPrinters;
int nVisuals;
int nDepths;
VisualPtr visuals;
DepthPtr depths;
+ VisualID defaultVisual;
+ int rootDepth;
/*
* Register this driver's InitContext function with the print
@@ -188,7 +198,7 @@ InitializePsDriver(ndx, pScreen, argc, argv)
visuals[1].vid = FakeClientID(0);
visuals[1].class = PseudoColor;
- visuals[1].bitsPerRGBValue = 0;
+ visuals[1].bitsPerRGBValue = 8;
visuals[1].ColormapEntries = 256;
visuals[1].nplanes = 8;
visuals[1].redMask = 0x0;
@@ -200,27 +210,35 @@ InitializePsDriver(ndx, pScreen, argc, argv)
depths[0].depth = 24;
depths[0].numVids = 1;
- depths[0].vids = &visuals[0].vid;
+ depths[0].vids = (VisualID *)xalloc(sizeof(VisualID));
+ depths[0].vids[0] = visuals[0].vid;
depths[1].depth = 8;
depths[1].numVids = 1;
- depths[1].vids = &visuals[1].vid;
+ depths[1].vids = (VisualID *)xalloc(sizeof(VisualID));
+ depths[1].vids[0] = visuals[1].vid;
-/* THE FOLLOWING CAUSES SERVER DEFAULT VISUAL TO BE 24 BIT */
-/* miScreenInit(pScreen, (pointer)0,
- pScreen->width, pScreen->height,
- pScreen->width / (pScreen->mmWidth / 25.40),
- pScreen->height / (pScreen->mmHeight / 25.40),
- 0, 24, nDepths,
- depths, visuals[1].vid, nVisuals, visuals); */
+ /* Defaul visual is 8bit PseudoColor */
+ defaultVisual = visuals[1].vid;
+ rootDepth = visuals[1].nplanes;
+
+#ifdef GLXEXT
+ {
+ miInitVisualsProcPtr proc = NULL;
+
+ GlxWrapInitVisuals(&proc);
+ /* GlxInitVisuals ignores the last three arguments. */
+ proc(&visuals, &depths, &nVisuals, &nDepths,
+ &rootDepth, &defaultVisual, 0, 0, 0);
+ }
+#endif /* GLXEXT */
-/* THE FOLLOWING CAUSES SERVER DEFAULT VISUAL TO BE 8 BIT */
miScreenInit(pScreen, (pointer)0,
- pScreen->width, pScreen->height,
- (int) (pScreen->width / (pScreen->mmWidth / 25.40)),
- (int) (pScreen->height / (pScreen->mmHeight / 25.40)),
- 0, 8, nDepths,
- depths, visuals[1].vid, nVisuals, visuals);
+ pScreen->width, pScreen->height,
+ (int) (pScreen->width / (pScreen->mmWidth / 25.40)),
+ (int) (pScreen->height / (pScreen->mmHeight / 25.40)),
+ 0, rootDepth, nDepths,
+ depths, defaultVisual, nVisuals, visuals);
if( cfbCreateDefColormap(pScreen)==FALSE ) return FALSE;
@@ -243,7 +261,7 @@ AllocatePsPrivates(ScreenPtr pScreen)
sizeof(PsWindowPrivRec));
PsContextPrivateIndex = XpAllocateContextPrivateIndex();
- XpAllocateContextPrivate(PsContextPrivateIndex,
+ XpAllocateContextPrivate(PsContextPrivateIndex,
sizeof(PsContextPrivRec));
PsPixmapPrivateIndex = AllocatePixmapPrivateIndex();
@@ -278,7 +296,7 @@ PsInitContext(pCon)
XpDriverFuncsPtr pFuncs;
PsContextPrivPtr pConPriv;
char *server, *attrStr;
-
+
/*
* Initialize the attribute store for this printer.
*/
@@ -304,18 +322,23 @@ PsInitContext(pCon)
pFuncs->GetMediumDimensions = PsGetMediumDimensions;
pFuncs->GetReproducibleArea = PsGetReproducibleArea;
pFuncs->SetImageResolution = PsSetImageResolution;
-
+
/*
* Set up the context privates
*/
pConPriv =
(PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
- pConPriv->jobFileName = (char *)NULL;
- pConPriv->pJobFile = (FILE *)NULL;
-
- pConPriv->getDocClient = (ClientPtr)NULL;
- pConPriv->getDocBufSize = 0;
+ memset(pConPriv, 0, sizeof(PsContextPrivRec));
+ pConPriv->jobFileName = (char *)NULL;
+ pConPriv->pJobFile = (FILE *)NULL;
+ pConPriv->dash = (unsigned char *)NULL;
+ pConPriv->validGC = 0;
+ pConPriv->getDocClient = (ClientPtr)NULL;
+ pConPriv->getDocBufSize = 0;
+ pConPriv->pPsOut = NULL;
+ pConPriv->fontInfoRecords = NULL;
+ pConPriv->fontTypeInfoRecords = NULL;
/*
* document-attributes-supported
@@ -323,15 +346,15 @@ PsInitContext(pCon)
server = XpGetOneAttribute( pCon, XPServerAttr, DOC_ATT_SUPP );
if ((attrStr = (char *) xalloc(strlen(server) +
strlen(DOC_ATT_SUPP) + strlen(DOC_ATT_VAL)
- + strlen(PAGE_ATT_VAL) + 6)) == NULL)
+ + strlen(PAGE_ATT_VAL) + 6)) == NULL)
{
return BadAlloc;
}
- sprintf(attrStr, "*%s:\t%s %s %s",
+ sprintf(attrStr, "*%s:\t%s %s %s",
DOC_ATT_SUPP, server, DOC_ATT_VAL, PAGE_ATT_VAL);
XpAugmentAttributes( pCon, XPPrinterAttr, attrStr);
xfree(attrStr);
-
+
/*
* job-attributes-supported
*/
@@ -344,7 +367,7 @@ PsInitContext(pCon)
sprintf(attrStr, "*%s:\t%s %s", JOB_ATT_SUPP, server, JOB_ATT_VAL);
XpAugmentAttributes(pCon, XPPrinterAttr, attrStr);
xfree(attrStr);
-
+
/*
* xp-page-attributes-supported
*/
@@ -375,7 +398,7 @@ PsDestroyContext(pCon)
{
PsContextPrivPtr pConPriv =
(PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
-
+
if( pConPriv->pJobFile!=(FILE *)NULL )
{
fclose(pConPriv->pJobFile);
@@ -388,6 +411,11 @@ PsDestroyContext(pCon)
pConPriv->jobFileName = (char *)NULL;
}
+ PsFreeFontInfoRecords(pConPriv);
+
+ /* Reset context to make sure we do not use any stale/invalid/obsolete data */
+ memset(pConPriv, 0, sizeof(PsContextPrivRec));
+
/*### free up visuals/depths ###*/
return Success;
diff --git a/Xprint/ps/PsLine.c b/Xprint/ps/PsLine.c
index dd01fcb65..23e105804 100644
--- a/Xprint/ps/PsLine.c
+++ b/Xprint/ps/PsLine.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsLine.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */
#include "Ps.h"
#include "gcstruct.h"
diff --git a/Xprint/ps/PsMisc.c b/Xprint/ps/PsMisc.c
index 3085888c7..86d862ce1 100644
--- a/Xprint/ps/PsMisc.c
+++ b/Xprint/ps/PsMisc.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsMisc.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */
#include "Xos.h" /* for SIGCLD on pre-POSIX systems */
#include <stdio.h>
diff --git a/Xprint/ps/PsPixel.c b/Xprint/ps/PsPixel.c
index 303b0d5ec..c2c360d2e 100644
--- a/Xprint/ps/PsPixel.c
+++ b/Xprint/ps/PsPixel.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPixel.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */
#include <stdio.h>
diff --git a/Xprint/ps/PsPixmap.c b/Xprint/ps/PsPixmap.c
index a020aba22..616c2dbe8 100644
--- a/Xprint/ps/PsPixmap.c
+++ b/Xprint/ps/PsPixmap.c
@@ -57,7 +57,7 @@ in this Software without prior written authorization from The Open Group.
* or other dealings in this Software without prior written authorization
* from said copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPixmap.c,v 1.4 2001/01/17 22:36:32 dawes Exp $ */
+
/*******************************************************************
**
** *********************************************************
@@ -79,6 +79,10 @@ in this Software without prior written authorization from The Open Group.
#include "Ps.h"
+#define _BitsPerPixel(d) (\
+ (1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
+ (PixmapWidthPaddingInfo[d].padRoundUp+1))
+
PixmapPtr
PsCreatePixmap(
ScreenPtr pScreen,
@@ -94,7 +98,7 @@ PsCreatePixmap(
pPixmap->drawable.class = 0;
pPixmap->drawable.pScreen = pScreen;
pPixmap->drawable.depth = depth;
- pPixmap->drawable.bitsPerPixel = BitsPerPixel(depth);
+ pPixmap->drawable.bitsPerPixel = _BitsPerPixel(depth);
pPixmap->drawable.id = 0;
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pPixmap->drawable.x = 0;
@@ -199,7 +203,7 @@ PsGetFreeDisplayBlock(PsPixmapPrivPtr priv)
return(disp);
}
-static void
+void
PsReplay(DisplayElmPtr elm, DrawablePtr pDrawable)
{
switch(elm->type)
@@ -488,8 +492,6 @@ PsCreateFillElementList(PixmapPtr pix, int *nElms)
case PolyFillArcCmd:
*nElms += elm->c.arcs.nArcs;
break;
- default:
- break;
}
}
}
@@ -552,8 +554,6 @@ PsCreateFillElementList(PixmapPtr pix, int *nElms)
*nElms += 1;
}
break;
- default:
- break;
}
}
}
diff --git a/Xprint/ps/PsPolygon.c b/Xprint/ps/PsPolygon.c
index d334c7778..a5b373775 100644
--- a/Xprint/ps/PsPolygon.c
+++ b/Xprint/ps/PsPolygon.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPolygon.c,v 1.6 2001/01/17 22:36:32 dawes Exp $ */
#include "Ps.h"
#include "gcstruct.h"
@@ -176,7 +175,8 @@ PsFillPolygon(
}
else
{
- pts[0].x = pPoints[0].x; pts[0].y = pPoints[0].y;
+ i = 0;
+ pts[0].x = pPoints[i].x; pts[0].y = pPoints[i].y;
for( i=1 ; i<nPoints ; i++ )
{
pts[i].x = pts[i-1].x+pPoints[i].x;
diff --git a/Xprint/ps/PsPrint.c b/Xprint/ps/PsPrint.c
index 5e549836f..f0356d705 100644
--- a/Xprint/ps/PsPrint.c
+++ b/Xprint/ps/PsPrint.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPrint.c,v 1.10 2001/12/14 19:59:17 dawes Exp $ */
#include <stdio.h>
#include <string.h>
@@ -91,6 +90,7 @@ in this Software without prior written authorization from The Open Group.
#include "Ps.h"
#include "windowstr.h"
+#include "attributes.h"
#include "Oid.h"
/* static utility function to get document/page attributes */
@@ -206,6 +206,8 @@ PsEndJob(
unlink(priv->jobFileName);
xfree(priv->jobFileName);
priv->jobFileName = (char *)NULL;
+
+ PsFreeFontInfoRecords(priv);
return Success;
}
@@ -214,6 +216,7 @@ PsEndJob(
* Append any trailing information here
*/
PsOut_EndFile(priv->pPsOut, 0);
+ priv->pPsOut = NULL;
/* this is where we find out if we're out of space */
error = (fclose(priv->pJobFile) == EOF);
@@ -233,6 +236,8 @@ PsEndJob(
xfree(priv->jobFileName);
priv->jobFileName = (char *)NULL;
+ PsFreeFontInfoRecords(priv);
+
return BadAlloc;
}
@@ -265,10 +270,12 @@ PsEndJob(
xfree(priv->jobFileName);
priv->jobFileName = (char *)NULL;
+ PsFreeFontInfoRecords(priv);
+
#ifdef BM_CACHE
PsBmClearImageCache();
#endif
-
+
return r;
}
@@ -281,10 +288,13 @@ PsStartPage(
{
int iorient, iplex, icount, ires;
unsigned short iwd, iht;
+ register WindowPtr pChild;
PsContextPrivPtr pConPriv =
(PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
PsWindowPrivPtr pWinPriv =
(PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
+ char s[80];
+ xEvent event;
/*
* Put a pointer to the context in the window private structure
@@ -298,9 +308,16 @@ PsStartPage(
* Start the page
*/
if (pConPriv->pPsOut == NULL) {
- pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile,
- iorient, icount, iplex, ires,
- (int)iwd, (int)iht, False);
+ char *title;
+
+ /* get job level attributes */
+ title = XpGetOneAttribute(pCon, XPJobAttr, "job-name");
+
+ pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile,
+ title, iorient, icount, iplex, ires,
+ (int)iwd, (int)iht, False);
+ pConPriv->fontInfoRecords = NULL;
+ pConPriv->fontTypeInfoRecords = NULL;
}
PsOut_BeginPage(pConPriv->pPsOut, iorient, icount, iplex, ires,
(int)iwd, (int)iht);
@@ -348,15 +365,22 @@ PsStartDoc(XpContextPtr pCon, XPDocumentType type)
{
int iorient, iplex, icount, ires;
unsigned short iwd, iht;
+ char *title;
PsContextPrivPtr pConPriv =
(PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ /* get job level attributes */
+ title = XpGetOneAttribute(pCon, XPJobAttr, "job-name");
+
/* get document level attributes */
S_GetPageAttributes(pCon,&iorient,&icount,&iplex,&ires,&iwd,&iht);
pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile,
- iorient, icount, iplex, ires,
- (int)iwd, (int)iht, (type == XPDocRaw));
+ title, iorient, icount, iplex, ires,
+ (int)iwd, (int)iht, (Bool)(type == XPDocRaw));
+
+ pConPriv->fontInfoRecords = NULL;
+ pConPriv->fontTypeInfoRecords = NULL;
return Success;
}
@@ -391,8 +415,11 @@ PsDocumentData(
PsContextPrivPtr cPriv;
PsOutPtr psOut;
- if (len_fmt != 12 || !strcmp(pFmt, "PostScript 2") || len_opt)
+ if (len_fmt != 12 ||
+ strncasecmp(pFmt, "PostScript 2", len_fmt) != 0 ||
+ len_opt)
return BadValue;
+
cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr;
psOut = cPriv->pPsOut;
diff --git a/Xprint/ps/PsText.c b/Xprint/ps/PsText.c
index ae44b3f1c..8bb0b0fb2 100644
--- a/Xprint/ps/PsText.c
+++ b/Xprint/ps/PsText.c
@@ -73,49 +73,13 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsText.c,v 1.12tsi Exp $ */
#include "Ps.h"
#include "gcstruct.h"
#include "windowstr.h"
+#include "fntfil.h"
#include "fntfilst.h"
-#include <sys/stat.h>
-
-static int readFontName(char *fileName, char *file_name, char *dlfnam)
-{
- FILE *file;
- struct stat statb;
- char buf[256];
- char *front, *fn;
-
- file = fopen(fileName, "r");
- if(file)
- {
- if (fstat (fileno(file), &statb) == -1)
- return 0;
- while(fgets(buf, 255, file))
- {
- if((fn = strstr(buf, " -")))
- {
- strcpy(file_name, buf);
- file_name[fn - buf - 4] = '\0';
- fn++;
- if((front = strstr(fn, "normal-")))
- {
- fn[front - fn] = '\0';
- if(strstr(dlfnam, fn))
- {
- fclose(file);
- return 1;
- }
- }
- }
- }
- }
- file_name[0] = '\0';
- fclose(file);
- return 0;
-}
+#include <limits.h>
int
PsPolyText8(
@@ -147,70 +111,97 @@ PsPolyText8(
elm->c.text8.string = (char *)xalloc(count);
memcpy(elm->c.text8.string, string, count);
disp->nelms += 1;
+
+ return x;
}
else
{
- char *fnam, ffname[512], *dlfnam;
- FontDirectoryPtr dir;
- char file_name[MAXFONTNAMELEN];
-
- dir = pGC->font->fpe->private;
- sprintf(ffname, "%s%s", dir->directory, "fonts.dir");
-
- fnam = PsGetPSFontName(pGC->font);
- if(!fnam){
- if(!(dlfnam = PsGetFontName(pGC->font)))
- return x;
- /* If Type1 font, try to download to printer first */
- if(strstr(ffname, "Type1") && readFontName(ffname, file_name, dlfnam))
- {
- int siz;
- float mtx[4];
- PsOutPtr psOut;
- ColormapPtr cMap;
-
- if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
- return x;
- sprintf(ffname, "%s%s%s", dir->directory, file_name, ".pfa");
- PsOut_DownloadType1(psOut, file_name, ffname);
- PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
- PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
- siz = PsGetFontSize(pGC->font, mtx);
- if( !siz ) PsOut_TextAttrsMtx(psOut, file_name, mtx, 1);
- else PsOut_TextAttrs(psOut, file_name, siz, 1);
- PsOut_Text(psOut, x, y, string, count, -1);
- return x;
- }
- {
- unsigned long n, i;
- int w;
- CharInfoPtr charinfo[255];
-
- GetGlyphs(pGC->font, (unsigned long)count,
- (unsigned char *)string, Linear8Bit,&n, charinfo);
- w = 0;
- for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
- if (n != 0)
- PsPolyGlyphBlt(pDrawable, pGC, x, y, n,
- charinfo, FONTGLYPHS(pGC->font));
- x += w;
- }
- }else{
- int iso;
- int siz;
- float mtx[4];
- PsOutPtr psOut;
- ColormapPtr cMap;
-
- if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return x;
- PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
- PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
- siz = PsGetFontSize(pGC->font, mtx);
- iso = PsIsISOLatin1Encoding(pGC->font);
- if( !siz ) PsOut_TextAttrsMtx(psOut, fnam, mtx, iso);
- else PsOut_TextAttrs(psOut, fnam, siz, iso);
- PsOut_Text(psOut, x, y, string, count, -1);
+ PsFontInfoRec *firec;
+
+ /* We need a context for rendering... */
+ if (PsGetPsContextPriv(pDrawable) == NULL)
+ return x;
+
+ firec = PsGetFontInfoRec(pDrawable, pGC->font);
+ if (!firec)
+ return x;
+
+#ifdef XP_USE_FREETYPE
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ if (firec->ftir->alreadyDownloaded[0] == False)
+ {
+ PsOut_DownloadFreeType(psOut,
+ firec->ftir->ft_download_font_type,
+ firec->ftir->download_ps_name, pGC->font, 0);
+ firec->ftir->alreadyDownloaded[0] = True;
+ }
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_FreeType_Text(pGC->font, psOut, x, y, string, count);
+
+ return x;
}
+ else
+#endif /* XP_USE_FREETYPE */
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ if (firec->ftir->alreadyDownloaded[0] == False)
+ {
+ PsOut_DownloadType1(psOut, "PsPolyText8",
+ firec->ftir->download_ps_name, firec->ftir->filename);
+ firec->ftir->alreadyDownloaded[0] = True;
+ }
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_Text(psOut, x, y, string, count, -1);
+
+ return x;
+ }
+
+ /* Render glyphs as bitmaps */
+ {
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255];
+
+ GetGlyphs(pGC->font, (unsigned long)count,
+ (unsigned char *)string, Linear8Bit, &n, charinfo);
+ w = 0;
+ for (i=0; i < n; i++)
+ w += charinfo[i]->metrics.characterWidth;
+
+ if (n != 0)
+ PsPolyGlyphBlt(pDrawable, pGC, x, y, n,
+ charinfo, FONTGLYPHS(pGC->font));
+ x += w;
+
+ return x;
+ }
}
return x;
}
@@ -246,21 +237,136 @@ PsPolyText16(
(unsigned short *)xalloc(count*sizeof(unsigned short));
memcpy(elm->c.text16.string, string, count*sizeof(unsigned short));
disp->nelms += 1;
+
+ return x;
}
else
{
- unsigned long n, i;
- int w;
- CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
-
- GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string,
- (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
- &n, charinfo);
- w = 0;
- for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
- if (n != 0)
- PsPolyGlyphBlt(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font));
- x += w;
+ PsFontInfoRec *firec;
+
+ /* We need a context for rendering... */
+ if (PsGetPsContextPriv(pDrawable) == NULL)
+ return x;
+
+ firec = PsGetFontInfoRec(pDrawable, pGC->font);
+ if (!firec)
+ return x;
+
+#ifdef XP_USE_FREETYPE
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ unsigned short c,
+ c_hiByte,
+ c_lowByte,
+ fontPage;
+ int i;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ /* Scan the string we want to render and download all neccesary parts
+ * of the font (one part(="font page") has 256 glyphs)
+ */
+ for( i = 0 ; i < count ; i++ )
+ {
+ c = string[i];
+#if IMAGE_BYTE_ORDER == LSBFirst
+ c_hiByte = c & 0x00FF;
+ c_lowByte = (c >> 8) & 0x00FF;
+#elif IMAGE_BYTE_ORDER == MSBFirst
+ c_hiByte = (c >> 8) & 0x00FF;
+ c_lowByte = c & 0x00FF;
+#else
+#error Unsupported byte order
+#endif
+ fontPage = c_hiByte;
+
+ if (firec->ftir->alreadyDownloaded[fontPage] == False)
+ {
+ char buffer[256];
+ const char *ps_name;
+
+ if (fontPage > 0)
+ {
+ sprintf(buffer, "%s_%x", firec->ftir->download_ps_name, (int)fontPage);
+ ps_name = buffer;
+ }
+ else
+ {
+ ps_name = firec->ftir->download_ps_name;
+ }
+
+ PsOut_DownloadFreeType(psOut,
+ firec->ftir->ft_download_font_type,
+ ps_name, pGC->font, (fontPage * 0x100)); /* same as (fontPage << 8) */
+
+ firec->ftir->alreadyDownloaded[fontPage] = True;
+ }
+ }
+
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_FreeType_TextAttrsMtx16(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_FreeType_TextAttrs16(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_FreeType_Text16(pGC->font, psOut, x, y, string, count);
+
+ return x;
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ unsigned short c,
+ c_hiByte,
+ c_lowByte,
+ fontPage;
+ int i;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ PsOut_DownloadType1(psOut, "PsPolyText16",
+ firec->ftir->download_ps_name, firec->ftir->filename);
+ firec->ftir->alreadyDownloaded[fontPage] = True;
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_Text16(psOut, x, y, string, count, -1);
+
+ return x;
+ }
+
+ /* Render glyphs as bitmaps */
+ {
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+ w = 0;
+ for (i=0; i < n; i++)
+ w += charinfo[i]->metrics.characterWidth;
+ if (n != 0)
+ PsPolyGlyphBlt(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font));
+ x += w;
+
+ return x;
+ }
}
return x;
}
@@ -386,7 +492,7 @@ PsPolyGlyphBlt(
pointer pGlyphBase)
{
int width, height;
- PixmapPtr pPixmap = NullPixmap;
+ PixmapPtr pPixmap;
int nbyLine; /* bytes per line of padded pixmap */
FontPtr pfont;
GCPtr pGCtmp;
@@ -399,7 +505,7 @@ PsPolyGlyphBlt(
int gWidth, gHeight; /* width and height of glyph */
register int nbyGlyphWidth; /* bytes per scanline of glyph */
int nbyPadGlyph; /* server padded line of glyph */
- int w;
+ int w, tmpx;
XID gcvals[3];
pfont = pGC->font;
@@ -435,6 +541,7 @@ PsPolyGlyphBlt(
PsDestroyPixmap(pPixmap);
return;
}
+ tmpx = 0;
while(nGlyphs--)
{
pci = *pCharInfo++;
@@ -466,8 +573,9 @@ PsPolyGlyphBlt(
1, x + pci->metrics.leftSideBearing,
y - pci->metrics.ascent, gWidth, gHeight,
0, XYBitmap, (char *)pb);
- x += pci->metrics.characterWidth;
}
+
+ x += pci->metrics.characterWidth;
}
DEALLOCATE_LOCAL(pbits);
FreeScratchGC(pGCtmp);
diff --git a/Xprint/ps/PsWindow.c b/Xprint/ps/PsWindow.c
index 987d434ff..3a9a7ed2a 100644
--- a/Xprint/ps/PsWindow.c
+++ b/Xprint/ps/PsWindow.c
@@ -73,11 +73,9 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsWindow.c,v 1.12tsi Exp $ */
#include <stdio.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/wait.h>
#include "mistruct.h"
@@ -87,7 +85,8 @@ in this Software without prior written authorization from The Open Group.
#include "Ps.h"
-#if 0
+extern WindowPtr *WindowTable;
+
/*
* The following list of strings defines the properties which will be
* placed on the screen's root window if the property was defined in
@@ -104,7 +103,7 @@ static char *propStrings[] = {
DT_PRINT_PAGE_COMMAND,
(char *)NULL
};
-#endif
+
/*
* PsCreateWindow - watch for the creation of the root window.
@@ -219,6 +218,8 @@ PsPaintWindow(
RegionPtr pRegion,
int what)
{
+ int status;
+ WindowPtr pRoot;
#define FUNCTION 0
#define FOREGROUND 1
@@ -298,6 +299,7 @@ PsPaintWindow(
gcmask |= GCFunction | GCClipMask;
i = pScreen->myNum;
+ pRoot = WindowTable[i];
pBgWin = pWin;
if (what == PW_BORDER)
@@ -375,14 +377,14 @@ PsPaintWindow(
}
break;
case GCClipMask:
- if( (pointer)(long)pGC->clientClipType!=(pointer)CT_NONE )
+ if( (pointer)pGC->clientClipType!=(pointer)CT_NONE )
{
gcmask |= index;
gcval[i++] = (pointer)CT_NONE;
}
break;
case GCSubwindowMode:
- if( (pointer)(long)pGC->subWindowMode!=newValues[SUBWINDOW] )
+ if( (pointer)pGC->subWindowMode!=newValues[SUBWINDOW] )
{
gcmask |= index;
gcval[i++] = newValues[SUBWINDOW];
@@ -396,7 +398,7 @@ PsPaintWindow(
}
break;
case GCFillStyle:
- if( (pointer)(long)pGC->fillStyle!=newValues[FILLSTYLE] )
+ if( (pointer)pGC->fillStyle!=newValues[FILLSTYLE] )
{
gcmask |= index;
gcval[i++] = newValues[FILLSTYLE];
diff --git a/Xprint/ps/psout.c b/Xprint/ps/psout.c
index 6b4c71a2b..d66374a4c 100644
--- a/Xprint/ps/psout.c
+++ b/Xprint/ps/psout.c
@@ -73,79 +73,21 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/psout.c,v 1.11 2001/12/19 21:55:59 dawes Exp $ */
-
-/*
- * For XFree86 3.3.3:
- *
- * As a *quick* way of preventing some buffers overflowing onto the stack,
- * they have been made static. There are potential problems with
- * PsOutRec.Buf overflowing too which should be investigated as part of a
- * review of this code, but that is at least always allocated with malloc
- * and shouldn't pose an immediate stack trashing problem.
- *
- */
#include <stdlib.h>
+#include <stdio.h>
#include "os.h"
-#include "Ps.h"
+#define USE_PSOUT_PRIVATE 1
#include "psout.h"
+#ifdef XP_USE_FREETYPE
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#endif /* XP_USE_FREETYPE */
+/* For VENDOR_STRING and VENDOR_RELEASE */
+#include "site.h"
-typedef void *voidPtr;
-
-typedef struct PsPatRec_
-{
- PsFillEnum type;
- voidPtr tag;
-} PsPatRec;
-
-typedef PsPatRec *PsPatPtr;
-
-typedef struct PsOutRec_
-{
- FILE *Fp;
- char Buf[256];
- int CurColor;
- int LineWidth;
- PsCapEnum LineCap;
- PsJoinEnum LineJoin;
- int NDashes;
- int *Dashes;
- int DashOffset;
- int LineBClr;
- PsRuleEnum FillRule;
- char *FontName;
- int FontSize;
- float FontMtx[4];
- int ImageFormat;
- int RevImage;
- int NPatterns;
- int MxPatterns;
- PsPatPtr Patterns;
- int ClipType;
- PsClipRec Clip;
- int InFrame;
- int XOff;
- int YOff;
-
- PsFillEnum InTile;
- int ImgSkip;
- int ImgBClr;
- int ImgFClr;
- int ImgX;
- int ImgY;
- int ImgW;
- int ImgH;
- int SclW;
- int SclH;
-
- int NDownloads;
- int MxDownloads;
- char **Downloads;
- Bool isRaw;
-
- int start_image;
-} PsOutRec;
+extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms);
+extern void PsDestroyFillElementList(int nElms, PsElmPtr elms);
/*
* Standard definitions
@@ -174,6 +116,7 @@ static char *S_StandardDefs = "\
/ie{ifelse}bd\
/len{length}bd\
/m{moveto}bd\
+/rm{rmoveto}bd\
/l{lineto}bd\
/rl{rlineto}bd\
/a{arc}bd\
@@ -236,7 +179,11 @@ static char *S_StandardDefs = "\
/mp{makepattern}bd\
/spt{setpattern}bd\
/spd{setpagedevice}bd\
-";
+"
+#ifdef XP_USE_FREETYPE
+"/trmoveto{currentfont /FontMatrix get transform rm}d"
+#endif /* XP_USE_FREETYPE */
+;
/*
* Composite definitions
@@ -341,7 +288,6 @@ static char *S_CompositeDefs = "\
/mtx{scl t [3 i 0 0 5 i 0 0]}bd \
";
-int pagenum = 0;
char *pg_orient[] = {"Portrait","Landscape","Reverse Portrait","Reverse Landscape"};
/*
* Setup definitions
@@ -360,7 +306,7 @@ static char *S_SetupDefs = "\
* PRIVATE FUNCTIONS *
*******************************************************************/
-static void
+void
S_Flush(PsOutPtr self)
{
if( self->Buf[0] )
@@ -388,7 +334,7 @@ S_OutDefs(PsOutPtr self, char *defs)
{
int i, k=0;
S_Flush(self);
- memset(self->Buf, 0, 256);
+ memset(self->Buf, 0, sizeof(self->Buf));
for( i=0 ; defs[i]!='\0' ;)
{
if( k>70 && (i==0 || (i && defs[i-1]!='/')) &&
@@ -396,7 +342,7 @@ S_OutDefs(PsOutPtr self, char *defs)
{
S_Flush(self);
k = 0;
- memset(self->Buf, 0, 256);
+ memset(self->Buf, 0, sizeof(self->Buf));
}
if( k && self->Buf[k-1]==' ' && defs[i]==' ' ) { i++; continue; }
self->Buf[k] = defs[i];
@@ -405,11 +351,11 @@ S_OutDefs(PsOutPtr self, char *defs)
S_Flush(self);
}
-static void
+void
S_OutNum(PsOutPtr self, float num)
{
int i;
- static char buf[64];
+ char buf[64];
sprintf(buf, "%.3f", num);
for( i=strlen(buf)-1 ; buf[i]=='0' ; i-- ); buf[i+1] = '\0';
if( buf[strlen(buf)-1]=='.' ) buf[strlen(buf)-1] = '\0';
@@ -422,7 +368,7 @@ static void
S_OutStr(PsOutPtr self, char *txt, int txtl)
{
int i, k;
- static char buf[512];
+ char buf[1024];
for( i=0,k=0 ; i<txtl ; i++ )
{
if( (txt[i]>=' ' && txt[i]<='~') &&
@@ -430,7 +376,9 @@ S_OutStr(PsOutPtr self, char *txt, int txtl)
{ buf[k] = txt[i]; k++; continue; }
buf[k] = '\\'; k++;
sprintf(&buf[k], "%03o", txt[i]&0xFF);
- k += 3;
+ /* Skip to the end of the buffer */
+ while( buf[k] != '\0' )
+ k++;
}
strcat(self->Buf, "(");
i = strlen(self->Buf);
@@ -440,7 +388,32 @@ S_OutStr(PsOutPtr self, char *txt, int txtl)
if( strlen(self->Buf)>70 ) S_Flush(self);
}
+/* Same as S_OutStr() but takes |short *| instead of |char *| */
static void
+S_OutStr16(PsOutPtr self, unsigned short *txt, int txtl)
+{
+ int i, k;
+ char buf[2048];
+ for( i=0,k=0 ; i<txtl ; i++ )
+ {
+ if( (txt[i]>=' ' && txt[i]<='~') &&
+ txt[i]!='(' && txt[i]!=')' && txt[i]!='\\' )
+ { buf[k] = txt[i]; k++; continue; }
+ buf[k] = '\\'; k++;
+ sprintf(&buf[k], "%03o", txt[i]&0xFFFF);
+ /* Skip to the end of the buffer */
+ while( buf[k] != '\0' )
+ k++;
+ }
+ strcat(self->Buf, "(");
+ i = strlen(self->Buf);
+ memcpy(&self->Buf[i], buf, k);
+ self->Buf[i+k] = '\0';
+ strcat(self->Buf, ")");
+ if( strlen(self->Buf)>70 ) S_Flush(self);
+}
+
+void
S_OutTok(PsOutPtr self, char *tok, int cr)
{
if( self->Buf[0] ) strcat(self->Buf, " ");
@@ -471,6 +444,27 @@ S_SetPageDevice(PsOutPtr self, int orient, int count, int plex, int res,
float fwd = ((float)wd/(float)res)*72.;
float fht = ((float)ht/(float)res)*72.;
+#define USE_WORKAROUND_COPY_COUNT_BUG 1
+
+#ifdef USE_WORKAROUND_COPY_COUNT_BUG
+ /* Workaround (see http://xprint.mozdev.org/bugs/show_bug.cgi?id=1861 -
+ * 'Need workaround for bug 1378 ...') to avoid that we print n^2 copies
+ * instead of n copies.
+ * The problem is that we use both /NumCopies here but pass the
+ * %copy-count% to the spooler, too.
+ * But we only have to use _one_ way...
+ *
+ * The final fix for bug 1378 (http://xprint.mozdev.org/bugs/show_bug.cgi?id=1378 -
+ * "PS DDX creates n^2 copies of a job instead of n copies") will back this
+ * workaround out and replace it with a better solution.
+ * (see mozilla.org bug 140030
+ * (http://bugzilla.mozilla.org/show_bug.cgi?id=140030 - "Setting number
+ * of copies causes too many copies to print") for the initial report for
+ * this issue...)
+ */
+ count = 1;
+#endif /* USE_WORKAROUND_COPY_COUNT_BUG */
+
S_OutTok(self, "/pWd", 0);
S_OutNum(self, fwd);
S_OutTok(self, "d /pHt", 0);
@@ -577,10 +571,11 @@ PsOut_ChangeFile(PsOutPtr self, FILE *fp)
}
PsOutPtr
-PsOut_BeginFile(FILE *fp, int orient, int count, int plex, int res,
+PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex, int res,
int wd, int ht, Bool raw)
{
int i;
+ char buffer[256+32]; /* enougth space for a title with 256 chars... */
/*
* Get ready to output PostScript header
*/
@@ -589,15 +584,41 @@ PsOut_BeginFile(FILE *fp, int orient, int count, int plex, int res,
memset(psout, 0, sizeof(PsOutRec));
psout->Fp = fp;
psout->isRaw = raw;
- pagenum = 0;
+ psout->pagenum = 0;
if (!raw) {
/*
* Output PostScript header
*/
- S_Comment(psout, "%!PS-Adobe-3.0 EPSF-3.0");
- S_Comment(psout, "%%Creator: The Open Group PostScript Print Server");
- /*### BoundingBox ###*/
+ /* GhostScript will rant about the missing BoundingBox if we use
+ * "%!PS-Adobe-3.0 EPSF-3.0" here... */
+ S_Comment(psout, "%!PS-Adobe-3.0");
+#ifdef XP_USE_FREETYPE
+ {
+ FT_Int ftmajor = 0,
+ ftminor = 0,
+ ftpatch = 0;
+ extern FT_Library ftypeLibrary; /* defined in xc/lib/font/FreeType/ftfuncs.c */
+
+ FT_Library_Version(ftypeLibrary, &ftmajor, &ftminor, &ftpatch);
+ sprintf(buffer,
+ "%%%%Creator: The X Print Server's PostScript DDX "
+ "(%s, release %d, FreeType version %d.%d.%d)",
+ VENDOR_STRING, VENDOR_RELEASE,
+ (int)ftmajor, (int)ftminor, (int)ftpatch);
+ }
+#else
+ sprintf(buffer,
+ "%%%%Creator: The X Print Server's PostScript DDX (%s, release %d)",
+ VENDOR_STRING, VENDOR_RELEASE);
+#endif /* XP_USE_FREETYPE */
+ S_Comment(psout, buffer);
+
+ if (title)
+ {
+ sprintf(buffer, "%%%%Title: %.256s", title);
+ S_Comment(psout, buffer);
+ }
S_Comment(psout, "%%EndComments");
S_Comment(psout, "%%BeginProlog");
S_Comment(psout, "%%BeginProcSet: XServer_PS_Functions");
@@ -634,10 +655,13 @@ PsOut_EndFile(PsOutPtr self, int closeFile)
{
char coms[50];
int i;
+
+ if (!self)
+ return;
if (!self->isRaw) {
S_Comment(self,"%%Trailer");
- sprintf(coms,"%%%%Pages: %d",pagenum);
+ sprintf(coms,"%%%%Pages: %d", self->pagenum);
S_Comment(self, coms);
S_Comment(self, "%%EOF");
}
@@ -646,9 +670,6 @@ PsOut_EndFile(PsOutPtr self, int closeFile)
if( self->Patterns ) xfree(self->Patterns);
if( self->Clip.rects ) xfree(self->Clip.rects);
if( closeFile ) fclose(self->Fp);
- for( i=0 ; i<self->NDownloads ; i++ ) xfree(self->Downloads[i]);
- if( self->Downloads ) xfree(self->Downloads);
- pagenum = 0; /* reset page num back to 0 */
xfree(self);
}
@@ -661,8 +682,8 @@ PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex, int res,
/*** comment for pagenumbers *****/
S_Comment(self,"%%PageHeader");
- pagenum++;
- sprintf(coms,"%%%%Page: %d %d",pagenum,pagenum);
+ self->pagenum++;
+ sprintf(coms,"%%%%Page: %d %d", self->pagenum, self->pagenum);
S_Comment(self, coms);
sprintf(coms,"%%%%PageOrientation: %s",pg_orient[orient]);
S_Comment(self, coms);
@@ -959,7 +980,7 @@ void
PsOut_TextAttrs(PsOutPtr self, char *fnam, int siz, int iso)
{
int i;
- static char buf[256];
+ char buf[256];
if( self->FontName && strcmp(fnam, self->FontName)==0 &&
siz==self->FontSize ) return;
if( self->FontName ) xfree(self->FontName);
@@ -979,7 +1000,7 @@ void
PsOut_TextAttrsMtx(PsOutPtr self, char *fnam, float *mtx, int iso)
{
int i;
- static char buf[256];
+ char buf[256];
if( self->FontName && strcmp(fnam, self->FontName)==0 &&
mtx[0]==self->FontMtx[0] && mtx[1]==self->FontMtx[1] &&
mtx[2]==self->FontMtx[2] && mtx[3]==self->FontMtx[3] ) return;
@@ -1171,6 +1192,30 @@ PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl, int bclr)
}
}
+void
+PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, int bclr)
+{
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+ S_OutStr16(self, text, textl);
+ S_OutNum(self, (float)x);
+ S_OutNum(self, (float)y);
+ if( bclr<0 ) S_OutTok(self, "T", 1);
+ else
+ {
+ int ir = bclr>>16;
+ int ig = (bclr>>8)&0xFF;
+ int ib = bclr&0xFF;
+ S_OutNum(self, (float)ir/255.);
+ S_OutNum(self, (float)ig/255.);
+ S_OutNum(self, (float)ib/255.);
+ S_OutTok(self, "Tb", 1);
+ }
+}
+
#ifdef BM_CACHE
void /* new */
PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, int bclr, int fclr)
@@ -1181,7 +1226,7 @@ PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, int bclr, int fclr)
if( self->InFrame || self->InTile ) xo = yo = 0;
x += xo; y += yo;
- sprintf(cacheID, "c%ldi", cache_id);
+ sprintf(cacheID, "c%di", cache_id);
S_OutNum(self, (float)x);
S_OutNum(self, (float)y);
@@ -1214,7 +1259,7 @@ PsOut_BeginImageCache(PsOutPtr self, long cache_id)
{
char cacheID[10];
- sprintf(cacheID, "/c%ldi {", cache_id);
+ sprintf(cacheID, "/c%di {", cache_id);
S_OutTok(self, cacheID, 0);
} /* new */
@@ -1225,7 +1270,7 @@ PsOut_EndImageCache(PsOutPtr self)
S_OutTok(self, "}bd", 1);
} /* new */
#endif
-
+
void
PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y,
int w, int h, int sw, int sh, int format)
@@ -1488,13 +1533,11 @@ PsOut_BeginPattern(PsOutPtr self, void *tag, int w, int h, PsFillEnum type,
}
self->Patterns[self->NPatterns].tag = tag;
self->Patterns[self->NPatterns].type = type;
- sprintf(key, "/ %ld", (long)tag);
+ sprintf(key, "/ %d", (int)tag);
switch(type) {
case PsTile: key[1] = 't'; break;
case PsStip: key[1] = 's'; break;
- case PsOpStip: key[1] = 'o'; break;
- default: break;
- }
+ case PsOpStip: key[1] = 'o'; break; }
S_OutTok(self, key, 0);
S_OutTok(self, "db/PatternType 1 d/PaintType 1 d", 0);
S_OutTok(self, "/TilingType 1 d/BBox[0 0", 0);
@@ -1535,13 +1578,11 @@ PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type)
for( i=0 ; i<self->NPatterns ; i++ )
{ if( tag==self->Patterns[i].tag && type==self->Patterns[i].type ) break; }
if( i>=self->NPatterns ) return;
- sprintf(key, " %ld", (long)tag);
+ sprintf(key, " %d", (int)tag);
switch(type) {
case PsTile: key[0] = 't'; break;
case PsStip: key[0] = 's'; break;
- case PsOpStip: key[0] = 'o'; break;
- default: break;
- }
+ case PsOpStip: key[0] = 'o'; break; }
S_OutTok(self, key, 0);
S_OutTok(self, "spt", 1);
self->CurColor = 0xFFFFFFFF;
@@ -1556,83 +1597,141 @@ PsOut_RawData(PsOutPtr self, char *data, int len)
}
}
-void
-PsOut_DownloadType1(PsOutPtr self, char *name, char *fname)
+typedef enum PsDownfontFontType_
+{
+ PsDFT_Type1PFA=0,
+ PsDFT_Type1PFB,
+ PsDFT_TrueType /* not implemented yet */
+} PsDownfontFontType;
+
+/* Download a PS Type1 font */
+int
+PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname)
{
int i;
int stt;
- static char buf[256];
+ char buf[256];
FILE *fp;
+ PsDownfontFontType type;
+
+ fp = fopen(fname, "r");
+ if( !fp )
+ return 0;
+
+#ifdef DEBUG_gisburn
+ /* This should be log-able! */
+ fprintf(stderr, "PsOut_DownloadType1: %s: Downloading '%s' from '%s'\n", auditmsg, name, fname);
+#endif /* DEBUG_gisburn */
- for( i=0 ; i<self->NDownloads ; i++ )
- { if( strcmp(name, self->Downloads[i])==0 ) break; }
- if( i<self->NDownloads ) return;
+ fread(buf, 32, 1, fp);
+ fseek(fp, (long)0, 0);
- if( (self->NDownloads+1)>self->MxDownloads )
+ /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */
+ if( (buf[0]&0xFF)==0x80 && (buf[1]&0xFF)==0x01 )
{
- if( self->NDownloads )
- {
- self->MxDownloads *= 2;
- self->Downloads = (char **)xrealloc(self->Downloads,
- self->MxDownloads*sizeof(char *));
- }
- else
- {
- self->MxDownloads = 32;
- self->Downloads = (char **)xalloc(self->MxDownloads*sizeof(char *));
- }
+ type = PsDFT_Type1PFB;
+ }
+ /* Is this a Adobe PostScript ASCII font (PFA) ? */
+ else if (!strncmp(buf, "%!PS-AdobeFont", 14))
+ {
+ type = PsDFT_Type1PFA;
}
-
- self->Downloads[self->NDownloads] = (char *)xalloc(strlen(name)+1);
- strcpy(self->Downloads[self->NDownloads], name);
- self->NDownloads += 1;
+ else
+ {
+ /* This should be log-able! */
+ fprintf(stderr, "PsOut_DownloadType1: Unknown font type for '%s'\n", fname);
+ return 0;
+ }
S_Flush(self);
sprintf(buf, "%%%%BeginFont: %s", name);
S_Comment(self, buf);
- fp = fopen(fname, "r");
- if( !fp ) return;
- fread(buf, 1, 1, fp);
- fseek(fp, (long)0, 0);
- if( (buf[0]&0xFF)==0x80 )
- {
- int len;
- for(;;)
+ if( type == PsDFT_Type1PFB )
+ {
+ char *buf,
+ *pt;
+ int len,
+ ch,
+ stype;
+
+ ch = fgetc(fp);
+ /* Strip out the binary headers and de-binary it */
+ while( (ch&0xFF) == 0x80 )
{
- stt = fread(buf, 1, 2, fp);
- if( stt!=2 || (buf[0]&0xFF)!=0x80 ) break;
- if( (int)buf[1]<1 || (int)buf[1]>2 ) break;
- stt = fread(buf, 1, 4, fp);
- if( stt!=4 ) break;
- len = ((buf[3]&0xFF)<<24)|((buf[2]&0xFF)<<16)|
- ((buf[1]&0xFF)<<8)|(buf[0]&0xFF);
- for(; len ;)
+ stype = fgetc(fp);
+ if( stype==3 ) /* eof mark */
+ break;
+ len = fgetc(fp);
+ len |= fgetc(fp)<<8;
+ len |= fgetc(fp)<<16;
+ len |= fgetc(fp)<<24;
+ buf = (char *)xalloc(len+1);
+ if( stype==1 )
+ {
+ /* Process ASCII section */
+ len = fread(buf, 1, len, fp);
+ /* convert any lone CRs (ie Mac eol) to LFs */
+ for( pt = buf ; (pt = memchr(pt, '\r', len-(pt-buf))) != NULL ; pt++ )
+ {
+ if ( pt[1]!='\n' )
+ *pt = '\n';
+ }
+ fwrite(buf, 1, len, self->Fp);
+ }
+ else if( stype==2 )
{
- i = len<256 ? len : 256;
- stt = fread(buf, 1, i, fp);
- if( stt<=0 ) break;
- if (!ferror(self->Fp)) {
- (void) fwrite(buf, 1, stt, self->Fp);
- }
- if( stt<i ) break;
- len -= i;
+ int i;
+
+ /* Process binary section */
+ len = fread(buf, 1, len, fp);
+ for( i=0 ; i<len ; i++ )
+ {
+ ch = buf[i];
+ if( ((ch>>4)&0xf) <= 9 )
+ fputc('0'+((ch>>4)&0xf), self->Fp);
+ else
+ fputc('A'-10+((ch>>4)&0xf), self->Fp);
+
+ if( (ch&0xf) <= 9 )
+ fputc('0'+(ch&0xf), self->Fp);
+ else
+ fputc('A'-10+(ch&0xf), self->Fp);
+
+ if( (i&0x1f)==0x1f )
+ fputc('\n', self->Fp);
+ }
}
+ xfree(buf);
+
+ /* Next block... */
+ ch = fgetc(fp);
}
}
- else
+ /* Is this a Adobe PostScript ASCII font (PFA) ? */
+ else if (type == PsDFT_Type1PFA)
{
for(;;)
{
stt = fread(buf, 1, 256, fp);
if( stt<=0 ) break;
if (!ferror(self->Fp)) {
- (void) fwrite(buf, 1, stt, self->Fp);
+ (void) fwrite(buf, 1, stt, self->Fp);
}
- if( stt<256 ) break;
+ if( stt<256 )
+ break;
}
}
fclose(fp);
S_Flush(self);
S_Comment(self, "%%EndFont");
+
+ /* Success... */
+ return 1;
}
+
+
+
+
+
+
diff --git a/Xprint/ps/psout.h b/Xprint/ps/psout.h
index 37b089ece..c592d7250 100644
--- a/Xprint/ps/psout.h
+++ b/Xprint/ps/psout.h
@@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group.
* or other dealings in this Software without prior written authorization
* from said copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/psout.h,v 1.4 2001/12/14 19:59:18 dawes Exp $ */
/*******************************************************************
**
@@ -147,10 +146,80 @@ typedef struct PsClipRec_
typedef PsClipRec *PsClipPtr;
+typedef enum PsFTDownloadFontType_
+{
+ PsFontBitmap=0,
+ PsFontType1,
+ PsFontType3
+} PsFTDownloadFontType;
+
+#ifdef USE_PSOUT_PRIVATE
+typedef void *voidPtr;
+
+typedef struct PsPatRec_
+{
+ PsFillEnum type;
+ voidPtr tag;
+} PsPatRec;
+
+typedef PsPatRec *PsPatPtr;
+
+typedef struct PsOutRec_
+{
+ FILE *Fp;
+ char Buf[16384];
+ int CurColor;
+ int LineWidth;
+ PsCapEnum LineCap;
+ PsJoinEnum LineJoin;
+ int NDashes;
+ int *Dashes;
+ int DashOffset;
+ int LineBClr;
+ PsRuleEnum FillRule;
+ char *FontName;
+ int FontSize;
+ float FontMtx[4];
+ int ImageFormat;
+ int RevImage;
+ int NPatterns;
+ int MxPatterns;
+ PsPatPtr Patterns;
+ int ClipType;
+ PsClipRec Clip;
+ int InFrame;
+ int XOff;
+ int YOff;
+
+ PsFillEnum InTile;
+ int ImgSkip;
+ int ImgBClr;
+ int ImgFClr;
+ int ImgX;
+ int ImgY;
+ int ImgW;
+ int ImgH;
+ int SclW;
+ int SclH;
+
+ Bool isRaw;
+
+ int pagenum;
+
+ int start_image;
+} PsOutRec;
+
typedef struct PsOutRec_ *PsOutPtr;
-extern PsOutPtr PsOut_BeginFile(FILE *fp, int orient, int count, int plex,
- int res, int wd, int ht, Bool raw);
+extern void S_Flush(PsOutPtr self);
+extern void S_OutNum(PsOutPtr self, float num);
+extern void S_OutTok(PsOutPtr self, char *tok, int cr);
+#else
+typedef struct PsOutRec_ *PsOutPtr;
+#endif /* USE_PSOUT_PRIVATE */
+
+extern PsOutPtr PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex,
+ int res, int wd, int ht, Bool raw);
extern void PsOut_EndFile(PsOutPtr self, int closeFile);
extern void PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex,
int res, int wd, int ht);
@@ -182,8 +251,9 @@ extern void PsOut_DrawArc(PsOutPtr self, int x, int y, int w, int h,
extern void PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl,
int bclr);
+extern void PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, int bclr);
-extern void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y,
+extern void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y,
int w, int h, int sw, int sh, int format);
extern void PsOut_BeginImageIM(PsOutPtr self, int bclr, int fclr, int x, int y,
int w, int h, int sw, int sh, int format);
@@ -200,16 +270,17 @@ extern void PsOut_EndPattern(PsOutPtr self);
extern void PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type);
extern void PsOut_RawData(PsOutPtr self, char *data, int len);
-extern void PsOut_DownloadType1(PsOutPtr self, char *name, char *fname);
-#ifdef BM_CACHE
-extern void PsOut_BeginImageCache(PsOutPtr self, long cache_id);
-extern void PsOut_EndImageCache(PsOutPtr self);
-extern void PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id,
- int bclr, int fclr);
-#endif
+extern int PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname);
-extern FILE *PsOut_ChangeFile(PsOutPtr self, FILE *fp);
+extern int PsOut_DownloadFreeType1(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset);
+extern int PsOut_DownloadFreeType3(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset);
+extern int PsOut_DownloadFreeType(PsOutPtr self, PsFTDownloadFontType downloadfonttype, const char *psfontname, FontPtr pFont, long block_offset);
+extern void PsOut_Get_FreeType_Glyph_Name( char *destbuf, FontPtr pFont, unsigned long x11fontindex);
+extern void PsOut_FreeType_Text(FontPtr pFont, PsOutPtr self, int x, int y, char *text, int textl);
+extern void PsOut_FreeType_Text16(FontPtr pFont, PsOutPtr self, int x, int y, unsigned short *text, int textl);
+extern void PsOut_FreeType_TextAttrs16(PsOutPtr self, char *fnam, int siz, int iso);
+extern void PsOut_FreeType_TextAttrsMtx16(PsOutPtr self, char *fnam, float *mtx, int iso);
#endif
diff --git a/Xprint/ps/ttf2pt1wrap.c b/Xprint/ps/ttf2pt1wrap.c
new file mode 100644
index 000000000..bd5ef526e
--- /dev/null
+++ b/Xprint/ps/ttf2pt1wrap.c
@@ -0,0 +1,10 @@
+/*
+ * Wrapper to add missing symbol to externally supplied code
+ */
+
+#ifdef Lynx
+extern int optind;
+extern char *optarg;
+#endif
+
+#include "ttf2pt1.c"
diff --git a/Xprint/raster/Raster.h b/Xprint/raster/Raster.h
index 750dc0722..9b335743f 100644
--- a/Xprint/raster/Raster.h
+++ b/Xprint/raster/Raster.h
@@ -30,8 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/raster/Raster.h,v 1.3 2001/10/31 22:50:29 tsi Exp $ */
-
/*******************************************************************
**
** *********************************************************
@@ -53,6 +51,7 @@ copyright holders.
* Some sleazes to force the XrmDB stuff into the server
*/
#ifndef HAVE_XPointer
+#define HAVE_XPointer 1
typedef char *XPointer;
#endif
#define Status int
@@ -110,6 +109,6 @@ typedef struct {
extern XpValidatePoolsRec RasterValidatePoolsRec;
extern Bool InitializeRasterDriver(int ndx, ScreenPtr pScreen, int argc,
- char **argv);
+ char **argv);
#endif /* _RASTER_H_ */
diff --git a/cfb/cfbpntwin.c b/cfb/cfbpntwin.c
index 88d8e0f07..91a6cd467 100644
--- a/cfb/cfbpntwin.c
+++ b/cfb/cfbpntwin.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/cfb/cfbpntwin.c,v 1.1.4.4.2.2 2004/03/04 17:47:25 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/cfb/cfbpntwin.c,v 1.2 2004/04/23 19:00:12 eich Exp $ */
/* $Xorg: cfbpntwin.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
/***********************************************************
diff --git a/cfb/stipsparc.s b/cfb/stipsparc.s
index a6a40491f..8ee5e2698 100644
--- a/cfb/stipsparc.s
+++ b/cfb/stipsparc.s
@@ -1,5 +1,6 @@
/*
* $Xorg: stipsparc.s,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $
+ * $XdotOrg: xc/programs/Xserver/cfb/stipsparc.s,v 1.3 2004/04/26 02:39:58 alanc Exp $
*
Copyright 1990, 1998 The Open Group
@@ -101,9 +102,17 @@ in this Software without prior written authorization from The Open Group.
.globl _cfbStippleStack
_cfbStippleStack:
save %sp,-64,%sp
+#ifdef SHAREDCODE
+1:
+ call 2f
+ nop
+2:
+ mov %o7,sbase /* sbase = 1b(1:) */
+ add sbase, CaseBegin-1b, sbase
+#else /* !SHAREDCODE */
sethi %hi(CaseBegin),sbase /* load up switch table */
or sbase,%lo(CaseBegin),sbase
-
+#endif /* SHAREDCODE */
mov 4,lshift /* compute offset within */
sub lshift, shift, lshift /* stipple of remaining bits */
#ifdef LITTLE_ENDIAN
diff --git a/cfb/stipsprc32.s b/cfb/stipsprc32.s
index 5703c0f1b..59d953f3b 100644
--- a/cfb/stipsprc32.s
+++ b/cfb/stipsprc32.s
@@ -1,5 +1,6 @@
/*
* $Xorg: stipsprc32.s,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $
+ * $XdotOrg: xc/programs/Xserver/cfb/stipsprc32.s,v 1.3 2004/04/26 02:39:58 alanc Exp $
*
Copyright 1990, 1998 The Open Group
@@ -98,9 +99,17 @@ in this Software without prior written authorization from The Open Group.
.globl _cfb32StippleStack
_cfb32StippleStack:
save %sp,-64,%sp
+#ifdef SHAREDCODE
+1:
+ call 2f
+ nop
+2:
+ mov %o7,sbase /* sbase = 1b(1:) */
+ add sbase, CaseBegin-1b, sbase
+#else /* !SHAREDCODE */
sethi %hi(CaseBegin),sbase /* load up switch table */
or sbase,%lo(CaseBegin),sbase
-
+#endif /* !SHAREDCODE */
mov 4,lshift /* compute offset within */
sub lshift, shift, lshift /* stipple of remaining bits */
#ifdef LITTLE_ENDIAN
diff --git a/composite/compalloc.c b/composite/compalloc.c
new file mode 100644
index 000000000..2e4eeb0c7
--- /dev/null
+++ b/composite/compalloc.c
@@ -0,0 +1,552 @@
+/*
+ * $Id$
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "compint.h"
+
+void
+compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
+{
+ WindowPtr pWin = (WindowPtr) closure;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ cs->damaged = TRUE;
+ cw->damaged = TRUE;
+}
+
+static void
+compDestroyDamage (DamagePtr pDamage, void *closure)
+{
+ WindowPtr pWin = (WindowPtr) closure;
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ cw->damage = 0;
+}
+
+/*
+ * Redirect one window for one client
+ */
+int
+compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompClientWindowPtr ccw;
+ Bool wasMapped = pWin->mapped;
+
+ /*
+ * Only one Manual update is allowed
+ */
+ if (cw && update == CompositeRedirectManual)
+ for (ccw = cw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == CompositeRedirectManual)
+ return BadAccess;
+
+ /*
+ * Allocate per-client per-window structure
+ * The client *could* allocate multiple, but while supported,
+ * it is not expected to be common
+ */
+ ccw = xalloc (sizeof (CompClientWindowRec));
+ if (!ccw)
+ return BadAlloc;
+ ccw->id = FakeClientID (pClient->index);
+ ccw->update = update;
+ /*
+ * Now make sure there's a per-window structure to hang this from
+ */
+ if (!cw)
+ {
+ cw = xalloc (sizeof (CompWindowRec));
+ if (!cw)
+ {
+ xfree (ccw);
+ return BadAlloc;
+ }
+ cw->damage = DamageCreate (compReportDamage,
+ compDestroyDamage,
+ DamageReportNonEmpty,
+ FALSE,
+ pWin->drawable.pScreen,
+ pWin);
+ if (!cw->damage)
+ {
+ xfree (ccw);
+ xfree (cw);
+ return BadAlloc;
+ }
+ if (wasMapped)
+ UnmapWindow (pWin, FALSE);
+
+ REGION_NULL (pScreen, &cw->borderClip);
+ cw->update = CompositeRedirectAutomatic;
+ cw->clients = 0;
+ cw->oldx = COMP_ORIGIN_INVALID;
+ cw->oldy = COMP_ORIGIN_INVALID;
+ cw->damageRegistered = FALSE;
+ cw->damaged = FALSE;
+ pWin->devPrivates[CompWindowPrivateIndex].ptr = cw;
+ }
+ ccw->next = cw->clients;
+ cw->clients = ccw;
+ if (!AddResource (ccw->id, CompositeClientWindowType, pWin))
+ return BadAlloc;
+ if (ccw->update == CompositeRedirectManual)
+ {
+ if (cw->damageRegistered)
+ {
+ DamageUnregister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = FALSE;
+ }
+ cw->update = CompositeRedirectManual;
+ }
+
+ if (!compCheckRedirect (pWin))
+ {
+ FreeResource (ccw->id, RT_NONE);
+ return BadAlloc;
+ }
+ if (wasMapped && !pWin->mapped)
+ {
+ Bool overrideRedirect = pWin->overrideRedirect;
+ pWin->overrideRedirect = TRUE;
+ MapWindow (pWin, pClient);
+ pWin->overrideRedirect = overrideRedirect;
+ }
+
+ return Success;
+}
+
+/*
+ * Free one of the per-client per-window resources, clearing
+ * redirect and the per-window pointer as appropriate
+ */
+void
+compFreeClientWindow (WindowPtr pWin, XID id)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompClientWindowPtr ccw, *prev;
+ Bool wasMapped = pWin->mapped;
+
+ if (!cw)
+ return;
+ for (prev = &cw->clients; (ccw = *prev); prev = &ccw->next)
+ {
+ if (ccw->id == id)
+ {
+ *prev = ccw->next;
+ if (ccw->update == CompositeRedirectManual)
+ cw->update = CompositeRedirectAutomatic;
+ xfree (ccw);
+ break;
+ }
+ }
+ if (!cw->clients)
+ {
+ if (wasMapped)
+ UnmapWindow (pWin, FALSE);
+
+ if (pWin->redirectDraw)
+ compFreePixmap (pWin);
+
+ if (cw->damage)
+ DamageDestroy (cw->damage);
+
+ REGION_UNINIT (pScreen, &cw->borderClip);
+
+ pWin->devPrivates[CompWindowPrivateIndex].ptr = 0;
+ xfree (cw);
+ }
+ else if (cw->update == CompositeRedirectAutomatic &&
+ !cw->damageRegistered && pWin->redirectDraw)
+ {
+ DamageRegister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = TRUE;
+ DamageDamageRegion (&pWin->drawable, &pWin->borderSize);
+ }
+ if (wasMapped && !pWin->mapped)
+ {
+ Bool overrideRedirect = pWin->overrideRedirect;
+ pWin->overrideRedirect = TRUE;
+ MapWindow (pWin, clients[CLIENT_ID(id)]);
+ pWin->overrideRedirect = overrideRedirect;
+ }
+}
+
+/*
+ * This is easy, just free the appropriate resource.
+ */
+
+int
+compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompClientWindowPtr ccw;
+
+ if (!cw)
+ return BadValue;
+
+ for (ccw = cw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index)
+ {
+ FreeResource (ccw->id, RT_NONE);
+ return Success;
+ }
+ return BadValue;
+}
+
+/*
+ * Redirect all subwindows for one client
+ */
+
+int
+compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin);
+ CompClientWindowPtr ccw;
+ WindowPtr pChild;
+
+ /*
+ * Only one Manual update is allowed
+ */
+ if (csw && update == CompositeRedirectManual)
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == CompositeRedirectManual)
+ return BadAccess;
+ /*
+ * Allocate per-client per-window structure
+ * The client *could* allocate multiple, but while supported,
+ * it is not expected to be common
+ */
+ ccw = xalloc (sizeof (CompClientWindowRec));
+ if (!ccw)
+ return BadAlloc;
+ ccw->id = FakeClientID (pClient->index);
+ ccw->update = update;
+ /*
+ * Now make sure there's a per-window structure to hang this from
+ */
+ if (!csw)
+ {
+ csw = xalloc (sizeof (CompSubwindowsRec));
+ if (!csw)
+ {
+ xfree (ccw);
+ return BadAlloc;
+ }
+ csw->update = CompositeRedirectAutomatic;
+ csw->clients = 0;
+ pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = csw;
+ }
+ /*
+ * Redirect all existing windows
+ */
+ for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+ {
+ int ret = compRedirectWindow (pClient, pChild, update);
+ if (ret != Success)
+ {
+ for (pChild = pChild->nextSib; pChild; pChild = pChild->nextSib)
+ (void) compUnredirectWindow (pClient, pChild, update);
+ if (!csw->clients)
+ {
+ xfree (csw);
+ pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0;
+ }
+ xfree (ccw);
+ return ret;
+ }
+ }
+ /*
+ * Hook into subwindows list
+ */
+ ccw->next = csw->clients;
+ csw->clients = ccw;
+ if (!AddResource (ccw->id, CompositeClientSubwindowsType, pWin))
+ return BadAlloc;
+ if (ccw->update == CompositeRedirectManual)
+ {
+ csw->update = CompositeRedirectManual;
+ /*
+ * tell damage extension that damage events for this client are
+ * critical output
+ */
+ DamageExtSetCritical (pClient, TRUE);
+ }
+ return Success;
+}
+
+/*
+ * Free one of the per-client per-subwindows resources,
+ * which frees one redirect per subwindow
+ */
+void
+compFreeClientSubwindows (WindowPtr pWin, XID id)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin);
+ CompClientWindowPtr ccw, *prev;
+ WindowPtr pChild;
+
+ if (!csw)
+ return;
+ for (prev = &csw->clients; (ccw = *prev); prev = &ccw->next)
+ {
+ if (ccw->id == id)
+ {
+ ClientPtr pClient = clients[CLIENT_ID(id)];
+
+ *prev = ccw->next;
+ if (ccw->update == CompositeRedirectManual)
+ {
+ /*
+ * tell damage extension that damage events for this client are
+ * critical output
+ */
+ DamageExtSetCritical (pClient, FALSE);
+ csw->update = CompositeRedirectAutomatic;
+ if (pWin->mapped)
+ (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, TRUE);
+ }
+
+ /*
+ * Unredirect all existing subwindows
+ */
+ for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+ (void) compUnredirectWindow (pClient, pChild, ccw->update);
+
+ xfree (ccw);
+ break;
+ }
+ }
+
+ /*
+ * Check if all of the per-client records are gone
+ */
+ if (!csw->clients)
+ {
+ pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0;
+ xfree (csw);
+ }
+}
+
+/*
+ * This is easy, just free the appropriate resource.
+ */
+
+int
+compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin);
+ CompClientWindowPtr ccw;
+
+ if (!csw)
+ return BadValue;
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index)
+ {
+ FreeResource (ccw->id, RT_NONE);
+ return Success;
+ }
+ return BadValue;
+}
+
+/*
+ * Add redirection information for one subwindow (during reparent)
+ */
+
+int
+compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pParent);
+ CompClientWindowPtr ccw;
+
+ if (!csw)
+ return Success;
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ {
+ int ret = compRedirectWindow (clients[CLIENT_ID(ccw->id)],
+ pWin, ccw->update);
+ if (ret != Success)
+ return ret;
+ }
+ return Success;
+}
+
+/*
+ * Remove redirection information for one subwindow (during reparent)
+ */
+
+int
+compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pParent);
+ CompClientWindowPtr ccw;
+
+ if (!csw)
+ return Success;
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ {
+ int ret = compUnredirectWindow (clients[CLIENT_ID(ccw->id)],
+ pWin, ccw->update);
+ if (ret != Success)
+ return ret;
+ }
+ return Success;
+}
+
+static PixmapPtr
+compNewPixmap (WindowPtr pWin, int x, int y, int w, int h)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pParent = pWin->parent;
+ PixmapPtr pPixmap;
+ GCPtr pGC;
+
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, pWin->drawable.depth);
+
+ if (!pPixmap)
+ return 0;
+
+ pPixmap->screen_x = x;
+ pPixmap->screen_y = y;
+
+ pGC = GetScratchGC (pWin->drawable.depth, pScreen);
+
+ /*
+ * Copy bits from the parent into the new pixmap so that it will
+ * have "reasonable" contents in case for background None areas.
+ */
+ if (pGC)
+ {
+ XID val = IncludeInferiors;
+
+ ValidateGC(&pPixmap->drawable, pGC);
+ dixChangeGC (serverClient, pGC, GCSubwindowMode, &val, NULL);
+ (*pGC->ops->CopyArea) (&pParent->drawable,
+ &pPixmap->drawable,
+ pGC,
+ x - pParent->drawable.x,
+ y - pParent->drawable.y,
+ w, h, 0, 0);
+ FreeScratchGC (pGC);
+ }
+ return pPixmap;
+}
+
+Bool
+compAllocPixmap (WindowPtr pWin)
+{
+ int bw = (int) pWin->borderWidth;
+ int x = pWin->drawable.x - bw;
+ int y = pWin->drawable.y - bw;
+ int w = pWin->drawable.width + (bw << 1);
+ int h = pWin->drawable.height + (bw << 1);
+ PixmapPtr pPixmap = compNewPixmap (pWin, x, y, w, h);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (!pPixmap)
+ return FALSE;
+ pWin->redirectDraw = TRUE;
+ compSetPixmap (pWin, pPixmap);
+ cw->oldx = COMP_ORIGIN_INVALID;
+ cw->oldy = COMP_ORIGIN_INVALID;
+ cw->damageRegistered = FALSE;
+ if (cw->update == CompositeRedirectAutomatic)
+ {
+ DamageRegister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = TRUE;
+ }
+ return TRUE;
+}
+
+void
+compFreePixmap (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pRedirectPixmap, pParentPixmap;
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (cw->damageRegistered)
+ {
+ DamageUnregister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = FALSE;
+ DamageEmpty (cw->damage);
+ }
+ /*
+ * Move the parent-constrained border clip region back into
+ * the window so that ValidateTree will handle the unmap
+ * case correctly. Unmap adds the window borderClip to the
+ * parent exposed area; regions beyond the parent cause crashes
+ */
+ REGION_COPY (pScreen, &pWin->borderClip, &cw->borderClip);
+ pRedirectPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ pParentPixmap = (*pScreen->GetWindowPixmap) (pWin->parent);
+ pWin->redirectDraw = FALSE;
+ compSetPixmap (pWin, pParentPixmap);
+ (*pScreen->DestroyPixmap) (pRedirectPixmap);
+}
+
+/*
+ * Make sure the pixmap is the right size and offset. Allocate a new
+ * pixmap to change size, adjust origin to change offset, leaving the
+ * old pixmap in cw->pOldPixmap so bits can be recovered
+ */
+Bool
+compReallocPixmap (WindowPtr pWin, int draw_x, int draw_y,
+ unsigned int w, unsigned int h, int bw)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pOld = (*pScreen->GetWindowPixmap) (pWin);
+ PixmapPtr pNew;
+ CompWindowPtr cw = GetCompWindow (pWin);
+ int pix_x, pix_y;
+ int pix_w, pix_h;
+
+ assert (cw && pWin->redirectDraw);
+ cw->oldx = pOld->screen_x;
+ cw->oldy = pOld->screen_y;
+ pix_x = draw_x - bw;
+ pix_y = draw_y - bw;
+ pix_w = w + (bw << 1);
+ pix_h = h + (bw << 1);
+ if (pix_w != pOld->drawable.width || pix_h != pOld->drawable.height)
+ {
+ pNew = compNewPixmap (pWin, pix_x, pix_y, pix_w, pix_h);
+ if (!pNew)
+ return FALSE;
+ cw->pOldPixmap = pOld;
+ compSetPixmap (pWin, pNew);
+ }
+ else
+ {
+ pNew = pOld;
+ cw->pOldPixmap = 0;
+ }
+ pNew->screen_x = pix_x;
+ pNew->screen_y = pix_y;
+ return TRUE;
+}
diff --git a/composite/compinit.c b/composite/compinit.c
new file mode 100644
index 000000000..5109a74fa
--- /dev/null
+++ b/composite/compinit.c
@@ -0,0 +1,389 @@
+/*
+ * $Id$
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "compint.h"
+
+int CompScreenPrivateIndex;
+int CompWindowPrivateIndex;
+int CompSubwindowsPrivateIndex;
+int CompGeneration;
+
+static Bool
+compCloseScreen (int index, ScreenPtr pScreen)
+{
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret;
+
+ pScreen->CloseScreen = cs->CloseScreen;
+ pScreen->BlockHandler = cs->BlockHandler;
+ pScreen->InstallColormap = cs->InstallColormap;
+ pScreen->ReparentWindow = cs->ReparentWindow;
+ pScreen->MoveWindow = cs->MoveWindow;
+ pScreen->ResizeWindow = cs->ResizeWindow;
+ pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
+
+ pScreen->ClipNotify = cs->ClipNotify;
+ pScreen->PaintWindowBackground = cs->PaintWindowBackground;
+ pScreen->UnrealizeWindow = cs->UnrealizeWindow;
+ pScreen->RealizeWindow = cs->RealizeWindow;
+ pScreen->DestroyWindow = cs->DestroyWindow;
+ pScreen->CreateWindow = cs->CreateWindow;
+ pScreen->CopyWindow = cs->CopyWindow;
+ pScreen->PositionWindow = cs->PositionWindow;
+ xfree (cs);
+ pScreen->devPrivates[CompScreenPrivateIndex].ptr = 0;
+ ret = (*pScreen->CloseScreen) (index, pScreen);
+ return ret;
+}
+
+static void
+compInstallColormap (ColormapPtr pColormap)
+{
+ VisualPtr pVisual = pColormap->pVisual;
+ ScreenPtr pScreen = pColormap->pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int a;
+
+ for (a = 0; a < NUM_COMP_ALTERNATE_VISUALS; a++)
+ if (pVisual->vid == cs->alternateVisuals[a])
+ return;
+ pScreen->InstallColormap = cs->InstallColormap;
+ (*pScreen->InstallColormap) (pColormap);
+ cs->InstallColormap = pScreen->InstallColormap;
+ pScreen->InstallColormap = compInstallColormap;
+}
+
+static void
+compScreenUpdate (ScreenPtr pScreen)
+{
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ compCheckTree (pScreen);
+ if (cs->damaged)
+ {
+ compWindowUpdate (WindowTable[pScreen->myNum]);
+ cs->damaged = FALSE;
+ }
+}
+
+static void
+compBlockHandler (int i,
+ pointer blockData,
+ pointer pTimeout,
+ pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[i];
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->BlockHandler = cs->BlockHandler;
+ compScreenUpdate (pScreen);
+ (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
+ cs->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = compBlockHandler;
+}
+
+/*
+ * Add alternate visuals -- always expose an ARGB32 and RGB24 visual
+ */
+
+static DepthPtr
+compFindVisuallessDepth (ScreenPtr pScreen, int d)
+{
+ int i;
+
+ for (i = 0; i < pScreen->numDepths; i++)
+ {
+ DepthPtr depth = &pScreen->allowedDepths[i];
+ if (depth->depth == d)
+ {
+ /*
+ * Make sure it doesn't have visuals already
+ */
+ if (depth->numVids)
+ return 0;
+ /*
+ * looks fine
+ */
+ return depth;
+ }
+ }
+ /*
+ * If there isn't one, then it's gonna be hard to have
+ * an associated visual
+ */
+ return 0;
+}
+
+typedef struct _alternateVisual {
+ int depth;
+ CARD32 format;
+} CompAlternateVisual;
+
+static CompAlternateVisual altVisuals[NUM_COMP_ALTERNATE_VISUALS] = {
+#if COMP_INCLUDE_RGB24_VISUAL
+ { 24, PICT_r8g8b8 },
+#endif
+ { 32, PICT_a8r8g8b8 },
+};
+
+static Bool
+compAddAlternateVisuals (ScreenPtr pScreen, CompScreenPtr cs)
+{
+ VisualPtr visuals;
+ DepthPtr depths[NUM_COMP_ALTERNATE_VISUALS];
+ PictFormatPtr pPictFormats[NUM_COMP_ALTERNATE_VISUALS];
+ int i;
+ int numVisuals;
+ VisualID *vids[NUM_COMP_ALTERNATE_VISUALS];
+ XID *installedCmaps;
+ ColormapPtr installedCmap;
+ int numInstalledCmaps;
+ int numAlternate = 0;
+ int alt;
+
+ memset (cs->alternateVisuals, '\0', sizeof (cs->alternateVisuals));
+
+ for (alt = 0; alt < NUM_COMP_ALTERNATE_VISUALS; alt++)
+ {
+ DepthPtr depth;
+ PictFormatPtr pPictFormat;
+
+ depth = compFindVisuallessDepth (pScreen, altVisuals[alt].depth);
+ if (!depth)
+ continue;
+ /*
+ * Find the right picture format
+ */
+ pPictFormat = PictureMatchFormat (pScreen, altVisuals[alt].depth,
+ altVisuals[alt].format);
+ if (!pPictFormat)
+ continue;
+
+ /*
+ * Allocate vid list for this depth
+ */
+ vids[numAlternate] = xalloc (sizeof (VisualID));
+ if (!vids[numAlternate])
+ continue;
+ depths[numAlternate] = depth;
+ pPictFormats[numAlternate] = pPictFormat;
+ numAlternate++;
+ }
+
+ if (!numAlternate)
+ return TRUE;
+
+ /*
+ * Find the installed colormaps
+ */
+ installedCmaps = xalloc (pScreen->maxInstalledCmaps * sizeof (XID));
+ if (!installedCmaps)
+ {
+ for (alt = 0; alt < numAlternate; alt++)
+ xfree (vids[alt]);
+ return FALSE;
+ }
+ numInstalledCmaps = (*pScreen->ListInstalledColormaps) (pScreen,
+ installedCmaps);
+
+ /*
+ * realloc the visual array to fit the new one in place
+ */
+ numVisuals = pScreen->numVisuals;
+ visuals = xrealloc (pScreen->visuals,
+ (numVisuals + numAlternate) * sizeof (VisualRec));
+ if (!visuals)
+ {
+ for (alt = 0; alt < numAlternate; alt++)
+ xfree (vids[alt]);
+ xfree (installedCmaps);
+ return FALSE;
+ }
+
+ /*
+ * Fix up any existing installed colormaps -- we'll assume that
+ * the only ones created so far have been installed. If this
+ * isn't true, we'll have to walk the resource database looking
+ * for all colormaps.
+ */
+ for (i = 0; i < numInstalledCmaps; i++)
+ {
+ int j;
+
+ installedCmap = LookupIDByType (installedCmaps[i], RT_COLORMAP);
+ if (!installedCmap)
+ continue;
+ j = installedCmap->pVisual - pScreen->visuals;
+ installedCmap->pVisual = &visuals[j];
+ }
+
+ xfree (installedCmaps);
+
+ pScreen->visuals = visuals;
+ pScreen->numVisuals = numVisuals + numAlternate;
+
+ for (alt = 0; alt < numAlternate; alt++)
+ {
+ DepthPtr depth = depths[alt];
+ PictFormatPtr pPictFormat = pPictFormats[alt];
+ VisualPtr visual = &visuals[numVisuals + alt];
+ unsigned long alphaMask;
+
+ /*
+ * Initialize the visual
+ */
+ visual->class = TrueColor;
+ visual->bitsPerRGBValue = 8;
+
+ visual->vid = FakeClientID (0);
+ visual->redMask = (((unsigned long) pPictFormat->direct.redMask) <<
+ pPictFormat->direct.red);
+ visual->greenMask = (((unsigned long) pPictFormat->direct.greenMask) <<
+ pPictFormat->direct.green);
+ visual->blueMask = (((unsigned long) pPictFormat->direct.blueMask) <<
+ pPictFormat->direct.blue);
+ alphaMask = (((unsigned long) pPictFormat->direct.alphaMask) <<
+ pPictFormat->direct.alpha);
+ visual->offsetRed = pPictFormat->direct.red;
+ visual->offsetGreen = pPictFormat->direct.green;
+ visual->offsetBlue = pPictFormat->direct.blue;
+ /*
+ * Include A bits in this (unlike GLX which includes only RGB)
+ * This lets DIX compute suitable masks for colormap allocations
+ */
+ visual->nplanes = Ones (visual->redMask |
+ visual->greenMask |
+ visual->blueMask |
+ alphaMask);
+ /*
+ * find widest component
+ */
+ visual->ColormapEntries = (1 << max (Ones (visual->redMask),
+ max (Ones (visual->greenMask),
+ Ones (visual->blueMask))));
+
+ /*
+ * remember the visual ID to detect auto-update windows
+ */
+ cs->alternateVisuals[alt] = visual->vid;
+
+ /*
+ * Fix up the depth
+ */
+ vids[alt][0] = visual->vid;
+ depth->numVids = 1;
+ depth->vids = vids[alt];
+ }
+ return TRUE;
+}
+
+Bool
+compScreenInit (ScreenPtr pScreen)
+{
+ CompScreenPtr cs;
+
+ if (CompGeneration != serverGeneration)
+ {
+ CompScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (CompScreenPrivateIndex == -1)
+ return FALSE;
+ CompWindowPrivateIndex = AllocateWindowPrivateIndex ();
+ if (CompWindowPrivateIndex == -1)
+ return FALSE;
+ CompSubwindowsPrivateIndex = AllocateWindowPrivateIndex ();
+ if (CompSubwindowsPrivateIndex == -1)
+ return FALSE;
+ CompGeneration = serverGeneration;
+ }
+ if (!AllocateWindowPrivate (pScreen, CompWindowPrivateIndex, 0))
+ return FALSE;
+
+ if (!AllocateWindowPrivate (pScreen, CompSubwindowsPrivateIndex, 0))
+ return FALSE;
+
+ if (GetCompScreen (pScreen))
+ return TRUE;
+ cs = (CompScreenPtr) xalloc (sizeof (CompScreenRec));
+ if (!cs)
+ return FALSE;
+
+ cs->damaged = FALSE;
+
+ if (!compAddAlternateVisuals (pScreen, cs))
+ {
+ xfree (cs);
+ return FALSE;
+ }
+
+ cs->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = compPositionWindow;
+
+ cs->CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = compCopyWindow;
+
+ cs->CreateWindow = pScreen->CreateWindow;
+ pScreen->CreateWindow = compCreateWindow;
+
+ cs->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = compDestroyWindow;
+
+ cs->RealizeWindow = pScreen->RealizeWindow;
+ pScreen->RealizeWindow = compRealizeWindow;
+
+ cs->UnrealizeWindow = pScreen->UnrealizeWindow;
+ pScreen->UnrealizeWindow = compUnrealizeWindow;
+
+ cs->PaintWindowBackground = pScreen->PaintWindowBackground;
+ pScreen->PaintWindowBackground = compPaintWindowBackground;
+
+ cs->ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = compClipNotify;
+
+ cs->MoveWindow = pScreen->MoveWindow;
+ pScreen->MoveWindow = compMoveWindow;
+
+ cs->ResizeWindow = pScreen->ResizeWindow;
+ pScreen->ResizeWindow = compResizeWindow;
+
+ cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
+ pScreen->ChangeBorderWidth = compChangeBorderWidth;
+
+ cs->ReparentWindow = pScreen->ReparentWindow;
+ pScreen->ReparentWindow = compReparentWindow;
+
+ cs->InstallColormap = pScreen->InstallColormap;
+ pScreen->InstallColormap = compInstallColormap;
+
+ cs->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = compBlockHandler;
+
+ cs->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = compCloseScreen;
+
+ pScreen->devPrivates[CompScreenPrivateIndex].ptr = (pointer) cs;
+ return TRUE;
+}
diff --git a/composite/compint.h b/composite/compint.h
new file mode 100644
index 000000000..81b4027ec
--- /dev/null
+++ b/composite/compint.h
@@ -0,0 +1,256 @@
+/*
+ * $Id$
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _COMPINT_H_
+#define _COMPINT_H_
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "dixevents.h"
+#include "globals.h"
+#include "picturestr.h"
+#include "extnsionst.h"
+#include "mi.h"
+#include "damage.h"
+#include "damageextint.h"
+#include "xfixes.h"
+#include <X11/extensions/compositeproto.h>
+#include <assert.h>
+
+/*
+ * enable this for debugging
+
+ #define COMPOSITE_DEBUG
+ */
+
+typedef struct _CompClientWindow {
+ struct _CompClientWindow *next;
+ XID id;
+ int update;
+} CompClientWindowRec, *CompClientWindowPtr;
+
+typedef struct _CompWindow {
+ RegionRec borderClip;
+ DamagePtr damage; /* for automatic update mode */
+ Bool damageRegistered;
+ Bool damaged;
+ int update;
+ CompClientWindowPtr clients;
+ int oldx;
+ int oldy;
+ PixmapPtr pOldPixmap;
+ int borderClipX, borderClipY;
+} CompWindowRec, *CompWindowPtr;
+
+#define COMP_ORIGIN_INVALID 0x80000000
+
+typedef struct _CompSubwindows {
+ int update;
+ CompClientWindowPtr clients;
+} CompSubwindowsRec, *CompSubwindowsPtr;
+
+#ifndef COMP_INCLUDE_RGB24_VISUAL
+#define COMP_INCLUDE_RGB24_VISUAL 0
+#endif
+
+#if COMP_INCLUDE_RGB24_VISUAL
+#define NUM_COMP_ALTERNATE_VISUALS 2
+#else
+#define NUM_COMP_ALTERNATE_VISUALS 1
+#endif
+
+typedef struct _CompScreen {
+ PositionWindowProcPtr PositionWindow;
+ CopyWindowProcPtr CopyWindow;
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ PaintWindowProcPtr PaintWindowBackground;
+ ClipNotifyProcPtr ClipNotify;
+ /*
+ * Called from ConfigureWindow, these
+ * three track changes to the offscreen storage
+ * geometry
+ */
+ MoveWindowProcPtr MoveWindow;
+ ResizeWindowProcPtr ResizeWindow;
+ ChangeBorderWidthProcPtr ChangeBorderWidth;
+ /*
+ * Reparenting has an effect on Subwindows redirect
+ */
+ ReparentWindowProcPtr ReparentWindow;
+
+ /*
+ * Colormaps for new visuals better not get installed
+ */
+ InstallColormapProcPtr InstallColormap;
+
+ ScreenBlockHandlerProcPtr BlockHandler;
+ CloseScreenProcPtr CloseScreen;
+ Bool damaged;
+ XID alternateVisuals[NUM_COMP_ALTERNATE_VISUALS];
+} CompScreenRec, *CompScreenPtr;
+
+extern int CompScreenPrivateIndex;
+extern int CompWindowPrivateIndex;
+extern int CompSubwindowsPrivateIndex;
+
+#define GetCompScreen(s) ((CompScreenPtr) ((s)->devPrivates[CompScreenPrivateIndex].ptr))
+#define GetCompWindow(w) ((CompWindowPtr) ((w)->devPrivates[CompWindowPrivateIndex].ptr))
+#define GetCompSubwindows(w) ((CompSubwindowsPtr) ((w)->devPrivates[CompSubwindowsPrivateIndex].ptr))
+
+extern RESTYPE CompositeClientWindowType;
+extern RESTYPE CompositeClientSubwindowsType;
+
+/*
+ * compalloc.c
+ */
+
+void
+compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure);
+
+Bool
+compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
+
+void
+compFreeClientWindow (WindowPtr pWin, XID id);
+
+int
+compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
+
+int
+compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
+
+void
+compFreeClientSubwindows (WindowPtr pWin, XID id);
+
+int
+compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
+
+int
+compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
+
+int
+compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
+
+Bool
+compAllocPixmap (WindowPtr pWin);
+
+void
+compFreePixmap (WindowPtr pWin);
+
+Bool
+compReallocPixmap (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, int bw);
+
+/*
+ * compext.c
+ */
+
+void
+CompositeExtensionInit (void);
+
+/*
+ * compinit.c
+ */
+
+Bool
+compScreenInit (ScreenPtr pScreen);
+
+/*
+ * compwindow.c
+ */
+
+#ifdef COMPOSITE_DEBUG
+void
+compCheckTree (ScreenPtr pScreen);
+#else
+#define compCheckTree(s)
+#endif
+
+void
+compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap);
+
+Bool
+compCheckRedirect (WindowPtr pWin);
+
+Bool
+compPositionWindow (WindowPtr pWin, int x, int y);
+
+Bool
+compRealizeWindow (WindowPtr pWin);
+
+Bool
+compUnrealizeWindow (WindowPtr pWin);
+
+void
+compPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what);
+
+void
+compClipNotify (WindowPtr pWin, int dx, int dy);
+
+void
+compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind);
+
+void
+compResizeWindow (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib);
+
+void
+compChangeBorderWidth (WindowPtr pWin, unsigned int border_width);
+
+void
+compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent);
+
+Bool
+compCreateWindow (WindowPtr pWin);
+
+Bool
+compDestroyWindow (WindowPtr pWin);
+
+void
+compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion);
+
+RegionPtr
+compGetRedirectBorderClip (WindowPtr pWin);
+
+void
+compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
+void
+compWindowUpdate (WindowPtr pWin);
+
+#endif /* _COMPINT_H_ */
diff --git a/composite/compwindow.c b/composite/compwindow.c
new file mode 100644
index 000000000..c7ea98c13
--- /dev/null
+++ b/composite/compwindow.c
@@ -0,0 +1,754 @@
+/*
+ * $Id$
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "compint.h"
+
+#ifdef COMPOSITE_DEBUG
+static int
+compCheckWindow (WindowPtr pWin, pointer data)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pWinPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ PixmapPtr pParentPixmap = pWin->parent ? (*pScreen->GetWindowPixmap) (pWin->parent) : 0;
+ PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+
+ if (!pWin->parent)
+ {
+ assert (!pWin->redirectDraw);
+ assert (pWinPixmap == pScreenPixmap);
+ }
+ else if (pWin->redirectDraw)
+ {
+ assert (pWinPixmap != pParentPixmap);
+ assert (pWinPixmap != pScreenPixmap);
+ }
+ else
+ {
+ assert (pWinPixmap == pParentPixmap);
+ }
+ assert (0 < pWinPixmap->refcnt && pWinPixmap->refcnt < 3);
+ assert (0 < pScreenPixmap->refcnt && pScreenPixmap->refcnt < 3);
+ if (pParentPixmap)
+ assert (0 <= pParentPixmap->refcnt && pParentPixmap->refcnt < 3);
+ return WT_WALKCHILDREN;
+}
+
+void
+compCheckTree (ScreenPtr pScreen)
+{
+ WalkTree (pScreen, compCheckWindow, 0);
+}
+#endif
+
+typedef struct _compPixmapVisit {
+ WindowPtr pWindow;
+ PixmapPtr pPixmap;
+} CompPixmapVisitRec, *CompPixmapVisitPtr;
+
+static Bool
+compRepaintBorder (ClientPtr pClient, pointer closure)
+{
+ WindowPtr pWindow = LookupWindow ((XID) closure, pClient);
+
+ if (pWindow)
+ {
+ RegionRec exposed;
+
+ REGION_NULL(pScreen, &exposed);
+ REGION_SUBTRACT(pScreen, &exposed, &pWindow->borderClip, &pWindow->winSize);
+ (*pWindow->drawable.pScreen->PaintWindowBorder)(pWindow, &exposed, PW_BORDER);
+ REGION_UNINIT(pScreen, &exposed);
+ }
+ return TRUE;
+}
+
+static int
+compSetPixmapVisitWindow (WindowPtr pWindow, pointer data)
+{
+ CompPixmapVisitPtr pVisit = (CompPixmapVisitPtr) data;
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+
+ if (pWindow != pVisit->pWindow && pWindow->redirectDraw)
+ return WT_DONTWALKCHILDREN;
+ (*pScreen->SetWindowPixmap) (pWindow, pVisit->pPixmap);
+ /*
+ * Recompute winSize and borderSize. This is duplicate effort
+ * when resizing pixmaps, but necessary when changing redirection.
+ * Might be nice to fix this.
+ */
+ SetWinSize (pWindow);
+ SetBorderSize (pWindow);
+ if (HasBorder (pWindow))
+ QueueWorkProc (compRepaintBorder, serverClient,
+ (pointer) pWindow->drawable.id);
+ return WT_WALKCHILDREN;
+}
+
+void
+compSetPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
+{
+ CompPixmapVisitRec visitRec;
+
+ visitRec.pWindow = pWindow;
+ visitRec.pPixmap = pPixmap;
+ TraverseTree (pWindow, compSetPixmapVisitWindow, (pointer) &visitRec);
+ compCheckTree (pWindow->drawable.pScreen);
+}
+
+Bool
+compCheckRedirect (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ Bool should;
+
+ should = pWin->realized && (pWin->drawable.class != InputOnly) &&
+ (cw != NULL);
+
+ if (should != pWin->redirectDraw)
+ {
+ if (should)
+ return compAllocPixmap (pWin);
+ else
+ compFreePixmap (pWin);
+ }
+ return TRUE;
+}
+
+Bool
+compPositionWindow (WindowPtr pWin, int x, int y)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->PositionWindow = cs->PositionWindow;
+ /*
+ * "Shouldn't need this as all possible places should be wrapped
+ *
+ compCheckRedirect (pWin);
+ */
+#ifdef COMPOSITE_DEBUG
+ if (pWin->redirectDraw != (pWin->viewable && (GetCompWindow(pWin) != NULL)))
+ abort ();
+#endif
+ if (pWin->redirectDraw)
+ {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ int bw = wBorderWidth (pWin);
+ int nx = pWin->drawable.x - bw;
+ int ny = pWin->drawable.y - bw;
+
+ if (pPixmap->screen_x != nx || pPixmap->screen_y != ny)
+ {
+ pPixmap->screen_x = nx;
+ pPixmap->screen_y = ny;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ }
+
+ if (!(*pScreen->PositionWindow) (pWin, x, y))
+ ret = FALSE;
+ cs->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = compPositionWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compRealizeWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->RealizeWindow = cs->RealizeWindow;
+ compCheckRedirect (pWin);
+ if (!(*pScreen->RealizeWindow) (pWin))
+ ret = FALSE;
+ cs->RealizeWindow = pScreen->RealizeWindow;
+ pScreen->RealizeWindow = compRealizeWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compUnrealizeWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->UnrealizeWindow = cs->UnrealizeWindow;
+ compCheckRedirect (pWin);
+ if (!(*pScreen->UnrealizeWindow) (pWin))
+ ret = FALSE;
+ cs->UnrealizeWindow = pScreen->UnrealizeWindow;
+ pScreen->UnrealizeWindow = compUnrealizeWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+void
+compPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin);
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ if (csw && csw->update == CompositeRedirectManual)
+ return;
+ pScreen->PaintWindowBackground = cs->PaintWindowBackground;
+ (*pScreen->PaintWindowBackground) (pWin, pRegion, what);
+ cs->PaintWindowBackground = pScreen->PaintWindowBackground;
+ pScreen->PaintWindowBackground = compPaintWindowBackground;
+}
+
+/*
+ * Called after the borderClip for the window has settled down
+ * We use this to make sure our extra borderClip has the right origin
+ */
+
+void
+compClipNotify (WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (cw)
+ {
+ if (cw->borderClipX != pWin->drawable.x ||
+ cw->borderClipY != pWin->drawable.y)
+ {
+ REGION_TRANSLATE (pScreen, &cw->borderClip,
+ pWin->drawable.x - cw->borderClipX,
+ pWin->drawable.y - cw->borderClipY);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+ }
+ }
+ if (cs->ClipNotify)
+ {
+ pScreen->ClipNotify = cs->ClipNotify;
+ (*pScreen->ClipNotify) (pWin, dx, dy);
+ cs->ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = compClipNotify;
+ }
+}
+
+/*
+ * Returns TRUE if the window needs server-provided automatic redirect,
+ * which is true if the child and parent aren't both regular or ARGB visuals
+ */
+
+static Bool
+compIsAlternateVisual (ScreenPtr pScreen,
+ XID visual)
+{
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int i;
+
+ for (i = 0; i < NUM_COMP_ALTERNATE_VISUALS; i++)
+ if (cs->alternateVisuals[i] == visual)
+ return TRUE;
+ return FALSE;
+}
+
+static Bool
+compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
+{
+ if (pParent)
+ {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XID winVisual = wVisual (pWin);
+ XID parentVisual = wVisual (pParent);
+
+ if (winVisual != parentVisual &&
+ (compIsAlternateVisual (pScreen, winVisual) ||
+ compIsAlternateVisual (pScreen, parentVisual)))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void
+compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ compCheckTree (pScreen);
+ if (pWin->redirectDraw)
+ {
+ WindowPtr pParent;
+ int draw_x, draw_y;
+ unsigned int w, h, bw;
+
+ /* if this is a root window, can't be moved */
+ if (!(pParent = pWin->parent))
+ return;
+
+ bw = wBorderWidth (pWin);
+ draw_x = pParent->drawable.x + x + (int)bw;
+ draw_y = pParent->drawable.y + y + (int)bw;
+ w = pWin->drawable.width;
+ h = pWin->drawable.height;
+ compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
+ }
+ compCheckTree (pScreen);
+
+ pScreen->MoveWindow = cs->MoveWindow;
+ (*pScreen->MoveWindow) (pWin, x, y, pSib, kind);
+ cs->MoveWindow = pScreen->MoveWindow;
+ pScreen->MoveWindow = compMoveWindow;
+
+ if (pWin->redirectDraw)
+ {
+ CompWindowPtr cw = GetCompWindow (pWin);
+ if (cw->pOldPixmap)
+ {
+ (*pScreen->DestroyPixmap) (cw->pOldPixmap);
+ cw->pOldPixmap = NullPixmap;
+ }
+ }
+
+ compCheckTree (pScreen);
+}
+
+void
+compResizeWindow (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ compCheckTree (pScreen);
+ if (pWin->redirectDraw)
+ {
+ WindowPtr pParent;
+ int draw_x, draw_y;
+ unsigned int bw;
+
+ /* if this is a root window, can't be moved */
+ if (!(pParent = pWin->parent))
+ return;
+
+ bw = wBorderWidth (pWin);
+ draw_x = pParent->drawable.x + x + (int)bw;
+ draw_y = pParent->drawable.y + y + (int)bw;
+ compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
+ }
+ compCheckTree (pScreen);
+
+ pScreen->ResizeWindow = cs->ResizeWindow;
+ (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
+ cs->ResizeWindow = pScreen->ResizeWindow;
+ pScreen->ResizeWindow = compResizeWindow;
+ if (pWin->redirectDraw)
+ {
+ CompWindowPtr cw = GetCompWindow (pWin);
+ if (cw->pOldPixmap)
+ {
+ (*pScreen->DestroyPixmap) (cw->pOldPixmap);
+ cw->pOldPixmap = NullPixmap;
+ }
+ }
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compChangeBorderWidth (WindowPtr pWin, unsigned int bw)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ compCheckTree (pScreen);
+ if (pWin->redirectDraw)
+ {
+ WindowPtr pParent;
+ int draw_x, draw_y;
+ unsigned int w, h;
+
+ /* if this is a root window, can't be moved */
+ if (!(pParent = pWin->parent))
+ return;
+
+ draw_x = pWin->drawable.x;
+ draw_y = pWin->drawable.y;
+ w = pWin->drawable.width;
+ h = pWin->drawable.height;
+ compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
+ }
+ compCheckTree (pScreen);
+
+ pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
+ (*pScreen->ChangeBorderWidth) (pWin, bw);
+ cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
+ pScreen->ChangeBorderWidth = compChangeBorderWidth;
+ if (pWin->redirectDraw)
+ {
+ CompWindowPtr cw = GetCompWindow (pWin);
+ if (cw->pOldPixmap)
+ {
+ (*pScreen->DestroyPixmap) (cw->pOldPixmap);
+ cw->pOldPixmap = NullPixmap;
+ }
+ }
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->ReparentWindow = cs->ReparentWindow;
+ /*
+ * Remove any implicit redirect due to synthesized visual
+ */
+ if (compImplicitRedirect (pWin, pPriorParent))
+ compUnredirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+ /*
+ * Handle subwindows redirection
+ */
+ compUnredirectOneSubwindow (pPriorParent, pWin);
+ compRedirectOneSubwindow (pWin->parent, pWin);
+ /*
+ * Add any implict redirect due to synthesized visual
+ */
+ if (compImplicitRedirect (pWin, pWin->parent))
+ compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+
+ /*
+ * Allocate any necessary redirect pixmap
+ * (this actually should never be true; pWin is always unmapped)
+ */
+ compCheckRedirect (pWin);
+
+ /*
+ * Reset pixmap pointers as appropriate
+ */
+ if (pWin->parent && !pWin->redirectDraw)
+ compSetPixmap (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
+ /*
+ * Call down to next function
+ */
+ if (pScreen->ReparentWindow)
+ (*pScreen->ReparentWindow) (pWin, pPriorParent);
+ cs->ReparentWindow = pScreen->ReparentWindow;
+ pScreen->ReparentWindow = compReparentWindow;
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int dx = 0, dy = 0;
+
+ if (pWin->redirectDraw)
+ {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ assert (cw->oldx != COMP_ORIGIN_INVALID);
+ assert (cw->oldy != COMP_ORIGIN_INVALID);
+ if (cw->pOldPixmap)
+ {
+ /*
+ * Ok, the old bits are available in pOldPixmap and
+ * need to be copied to pNewPixmap.
+ */
+ RegionRec rgnDst;
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ GCPtr pGC;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+
+ REGION_NULL (pWin->drawable.pScreen, &rgnDst);
+
+ REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst,
+ &pWin->borderClip, prgnSrc);
+
+ REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
+ -pPixmap->screen_x, -pPixmap->screen_y);
+
+ dx = dx + pPixmap->screen_x - cw->oldx;
+ dy = dy + pPixmap->screen_y - cw->oldy;
+ pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+ if (pGC)
+ {
+ BoxPtr pBox = REGION_RECTS (&rgnDst);
+ int nBox = REGION_NUM_RECTS (&rgnDst);
+
+ ValidateGC(&pPixmap->drawable, pGC);
+ while (nBox--)
+ {
+ (void) (*pGC->ops->CopyArea) (&cw->pOldPixmap->drawable,
+ &pPixmap->drawable,
+ pGC,
+ pBox->x1 + dx, pBox->y1 + dy,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1,
+ pBox->x1, pBox->y1);
+ pBox++;
+ }
+ FreeScratchGC (pGC);
+ }
+ return;
+ }
+ dx = pPixmap->screen_x - cw->oldx;
+ dy = pPixmap->screen_y - cw->oldy;
+ ptOldOrg.x += dx;
+ ptOldOrg.y += dy;
+ }
+
+ pScreen->CopyWindow = cs->CopyWindow;
+ if (ptOldOrg.x != pWin->drawable.x || ptOldOrg.y != pWin->drawable.y)
+ {
+ if (dx || dy)
+ REGION_TRANSLATE (pScreen, prgnSrc, dx, dy);
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
+ if (dx || dy)
+ REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy);
+ }
+ else
+ {
+ ptOldOrg.x -= dx;
+ ptOldOrg.y -= dy;
+ REGION_TRANSLATE (prgnSrc, prgnSrc,
+ pWin->drawable.x - ptOldOrg.x,
+ pWin->drawable.y - ptOldOrg.y);
+ DamageDamageRegion (&pWin->drawable, prgnSrc);
+ }
+ cs->CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = compCopyWindow;
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+Bool
+compCreateWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret;
+
+ pScreen->CreateWindow = cs->CreateWindow;
+ ret = (*pScreen->CreateWindow) (pWin);
+ if (pWin->parent && ret)
+ {
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin->parent);
+ CompClientWindowPtr ccw;
+
+ (*pScreen->SetWindowPixmap) (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
+ if (csw)
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ compRedirectWindow (clients[CLIENT_ID(ccw->id)],
+ pWin, ccw->update);
+ if (compImplicitRedirect (pWin, pWin->parent))
+ compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+ }
+ cs->CreateWindow = pScreen->CreateWindow;
+ pScreen->CreateWindow = compCreateWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compDestroyWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw;
+ CompSubwindowsPtr csw;
+ Bool ret;
+
+ pScreen->DestroyWindow = cs->DestroyWindow;
+ while ((cw = GetCompWindow (pWin)))
+ FreeResource (cw->clients->id, RT_NONE);
+ while ((csw = GetCompSubwindows (pWin)))
+ FreeResource (csw->clients->id, RT_NONE);
+
+ if (pWin->redirectDraw)
+ compFreePixmap (pWin);
+ ret = (*pScreen->DestroyWindow) (pWin);
+ cs->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = compDestroyWindow;
+/* compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/
+ return ret;
+}
+
+void
+compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ RegionRec damage;
+
+ REGION_NULL (pScreen, &damage);
+ /*
+ * Align old border clip with new border clip
+ */
+ REGION_TRANSLATE (pScreen, &cw->borderClip,
+ pWin->drawable.x - cw->borderClipX,
+ pWin->drawable.y - cw->borderClipY);
+ /*
+ * Compute newly visible portion of window for repaint
+ */
+ REGION_SUBTRACT (pScreen, &damage, pRegion, &cw->borderClip);
+ /*
+ * Report that as damaged so it will be redrawn
+ */
+ DamageDamageRegion (&pWin->drawable, &damage);
+ REGION_UNINIT (pScreen, &damage);
+ /*
+ * Save the new border clip region
+ */
+ REGION_COPY (pScreen, &cw->borderClip, pRegion);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+}
+
+RegionPtr
+compGetRedirectBorderClip (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ return &cw->borderClip;
+}
+
+static VisualPtr
+compGetWindowVisual (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ VisualID vid = wVisual (pWin);
+ int i;
+
+ for (i = 0; i < pScreen->numVisuals; i++)
+ if (pScreen->visuals[i].vid == vid)
+ return &pScreen->visuals[i];
+ return 0;
+}
+
+static PictFormatPtr
+compWindowFormat (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ return PictureMatchVisual (pScreen, pWin->drawable.depth,
+ compGetWindowVisual (pWin));
+}
+
+static void
+compWindowUpdateAutomatic (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pParent = pWin->parent;
+ PixmapPtr pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ PictFormatPtr pSrcFormat = compWindowFormat (pWin);
+ PictFormatPtr pDstFormat = compWindowFormat (pWin->parent);
+ int error;
+ RegionPtr pRegion = DamageRegion (cw->damage);
+ PicturePtr pSrcPicture = CreatePicture (0, &pSrcPixmap->drawable,
+ pSrcFormat,
+ 0, 0,
+ serverClient,
+ &error);
+ XID subwindowMode = IncludeInferiors;
+ PicturePtr pDstPicture = CreatePicture (0, &pParent->drawable,
+ pDstFormat,
+ CPSubwindowMode,
+ &subwindowMode,
+ serverClient,
+ &error);
+
+ /*
+ * First move the region from window to screen coordinates
+ */
+ REGION_TRANSLATE (pScreen, pRegion,
+ pWin->drawable.x, pWin->drawable.y);
+
+ /*
+ * Clip against the "real" border clip
+ */
+ REGION_INTERSECT (pScreen, pRegion, pRegion, &cw->borderClip);
+
+ /*
+ * Now translate from screen to dest coordinates
+ */
+ REGION_TRANSLATE (pScreen, pRegion,
+ -pParent->drawable.x, -pParent->drawable.y);
+
+ /*
+ * Clip the picture
+ */
+ SetPictureClipRegion (pDstPicture, 0, 0, pRegion);
+
+ /*
+ * And paint
+ */
+ CompositePicture (PictOpSrc,
+ pSrcPicture,
+ 0,
+ pDstPicture,
+ 0, 0, /* src_x, src_y */
+ 0, 0, /* msk_x, msk_y */
+ pSrcPixmap->screen_x - pParent->drawable.x,
+ pSrcPixmap->screen_y - pParent->drawable.y,
+ pSrcPixmap->drawable.width,
+ pSrcPixmap->drawable.height);
+ FreePicture (pSrcPicture, 0);
+ FreePicture (pDstPicture, 0);
+ /*
+ * Empty the damage region. This has the nice effect of
+ * rendering the translations above harmless
+ */
+ DamageEmpty (cw->damage);
+}
+
+void
+compWindowUpdate (WindowPtr pWin)
+{
+ WindowPtr pChild;
+
+ for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+ compWindowUpdate (pChild);
+ if (pWin->redirectDraw)
+ {
+ CompWindowPtr cw = GetCompWindow(pWin);
+
+ if (cw->damaged)
+ {
+ compWindowUpdateAutomatic (pWin);
+ cw->damaged = FALSE;
+ }
+ }
+}
diff --git a/dbe/dbe.c b/dbe/dbe.c
index aa3dad193..4135d7876 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/dbe/dbe.c,v 1.1.4.3.2.2 2004/03/04 17:47:26 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/dbe/dbe.c,v 1.2 2004/04/23 19:03:43 eich Exp $ */
/* $Xorg: dbe.c,v 1.3 2000/08/17 19:48:16 cpqbld Exp $ */
/******************************************************************************
*
diff --git a/dix/colormap.c b/dix/colormap.c
index 306ff941f..28677d53e 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/dix/colormap.c,v 1.1.4.4.2.3 2004/03/04 20:16:04 kaleb Exp $ */
+/* $XdotOrg: xc/programs/Xserver/dix/colormap.c,v 1.5 2004/08/13 08:16:14 keithp Exp $ */
/* $XFree86: xc/programs/Xserver/dix/colormap.c,v 3.11 2003/11/03 05:10:59 tsi Exp $ */
/***********************************************************
@@ -190,7 +190,14 @@ static void FindColorInRootCmap (
#define NUMRED(vis) ((vis->redMask >> vis->offsetRed) + 1)
#define NUMGREEN(vis) ((vis->greenMask >> vis->offsetGreen) + 1)
#define NUMBLUE(vis) ((vis->blueMask >> vis->offsetBlue) + 1)
-#define RGBMASK(vis) (vis->redMask | vis->greenMask | vis->blueMask)
+#if COMPOSITE
+#define ALPHAMASK(vis) ((vis)->nplanes < 32 ? 0 : \
+ (CARD32) ~((vis)->redMask|(vis)->greenMask|(vis)->blueMask))
+#else
+#define ALPHAMASK(vis) 0
+#endif
+
+#define RGBMASK(vis) (vis->redMask | vis->greenMask | vis->blueMask | ALPHAMASK(vis))
/* GetNextBitsOrBreak(bits, mask, base) --
* (Suggestion: First read the macro, then read this explanation.
@@ -865,7 +872,9 @@ AllocColor (pmap, pred, pgreen, pblue, pPix, client)
pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP);
*pPix = (pixR << pVisual->offsetRed) |
(pixG << pVisual->offsetGreen) |
- (pixB << pVisual->offsetBlue);
+ (pixB << pVisual->offsetBlue) |
+ ALPHAMASK(pVisual);
+
*pred = pmap->red[pixR].co.local.red;
*pgreen = pmap->green[pixG].co.local.green;
*pblue = pmap->blue[pixB].co.local.blue;
@@ -955,7 +964,8 @@ AllocColor (pmap, pred, pgreen, pblue, pPix, client)
(void)FreeCo(pmap, client, REDMAP, 1, &pixR, (Pixel)0);
return (BadAlloc);
}
- *pPix = pixR | pixG | pixB;
+ *pPix = pixR | pixG | pixB | ALPHAMASK(pVisual);
+
break;
}
@@ -1929,6 +1939,10 @@ AllocDirect (client, pmap, c, r, g, b, contig, pixels, prmask, pgmask, pbmask)
pmap->numPixelsBlue[client] += npixB;
pmap->freeBlue -= npixB;
+
+ for (pDst = pixels; pDst < pixels + c; pDst++)
+ *pDst |= ALPHAMASK(pmap->pVisual);
+
DEALLOCATE_LOCAL(ppixBlue);
DEALLOCATE_LOCAL(ppixGreen);
DEALLOCATE_LOCAL(ppixRed);
diff --git a/dix/cursor.c b/dix/cursor.c
index fc81a5197..9e0724fb4 100644
--- a/dix/cursor.c
+++ b/dix/cursor.c
@@ -68,6 +68,10 @@ typedef struct _GlyphShare {
static GlyphSharePtr sharedGlyphs = (GlyphSharePtr)NULL;
+#ifdef XFIXES
+static CARD32 cursorSerial;
+#endif
+
static void
FreeCursorBits(CursorBitsPtr bits)
{
@@ -189,6 +193,10 @@ AllocCursorARGB(psrcbits, pmaskbits, argb, cm,
pCurs->bits = bits;
pCurs->refcnt = 1;
+#ifdef XFIXES
+ pCurs->serialNumber = ++cursorSerial;
+ pCurs->name = None;
+#endif
pCurs->foreRed = foreRed;
pCurs->foreGreen = foreGreen;
@@ -379,6 +387,10 @@ AllocGlyphCursor(source, sourceChar, mask, maskChar,
CheckForEmptyMask(bits);
pCurs->bits = bits;
pCurs->refcnt = 1;
+#ifdef XFIXES
+ pCurs->serialNumber = ++cursorSerial;
+ pCurs->name = None;
+#endif
pCurs->foreRed = foreRed;
pCurs->foreGreen = foreGreen;
diff --git a/dix/dispatch.c b/dix/dispatch.c
index e6602969a..be6f006b4 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/dix/dispatch.c,v 1.1.4.4.2.3 2004/03/08 00:36:56 alanc Exp $ */
+/* $XdotOrg: xc/programs/Xserver/dix/dispatch.c,v 1.5 2004/07/31 01:48:27 anholt Exp $ */
/* $Xorg: dispatch.c,v 1.5 2001/02/09 02:04:40 xorgcvs Exp $ */
/************************************************************
@@ -132,6 +132,7 @@ extern char *ConnectionInfo;
Selection *CurrentSelections;
int NumCurrentSelections;
+CallbackListPtr SelectionCallback = NULL;
static ClientPtr grabClient;
#define GrabNone 0
@@ -253,7 +254,7 @@ FlushClientCaches(id)
#define SMART_SCHEDULE_DEFAULT_INTERVAL 20 /* ms */
#define SMART_SCHEDULE_MAX_SLICE 200 /* ms */
-Bool SmartScheduleDisable;
+Bool SmartScheduleDisable = FALSE;
long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
@@ -463,6 +464,9 @@ Dispatch(void)
client->errorValue, result);
break;
}
+#ifdef DAMAGEEXT
+ FlushIfCriticalOutputPending ();
+#endif
}
FlushAllOutput();
#ifdef SMART_SCHEDULE
@@ -631,7 +635,7 @@ ProcChangeSaveSet(client)
return BadMatch;
if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete))
{
- result = AlterSaveSetForClient(client, pWin, stuff->mode);
+ result = AlterSaveSetForClient(client, pWin, stuff->mode, FALSE, TRUE);
if (client->noClientException != Success)
return(client->noClientException);
else
@@ -1044,6 +1048,14 @@ ProcSetSelectionOwner(client)
CurrentSelections[i].window = stuff->window;
CurrentSelections[i].pWin = pWin;
CurrentSelections[i].client = (pWin ? client : NullClient);
+ if (SelectionCallback)
+ {
+ SelectionInfoRec info;
+
+ info.selection = &CurrentSelections[i];
+ info.kind= SelectionSetOwner;
+ CallCallbacks(&SelectionCallback, &info);
+ }
return (client->noClientException);
}
else
@@ -2117,7 +2129,9 @@ DoGetImage(client, format, drawable, x, y, width, height, planemask, im_return)
Mask plane = 0;
char *pBuf;
xGetImageReply xgi;
+#ifdef XCSECURITY
RegionPtr pVisibleRegion = NULL;
+#endif
if ((format != XYPixmap) && (format != ZPixmap))
{
@@ -3724,7 +3738,7 @@ void InitClient(client, i, ospriv)
client->lastGC = (GCPtr) NULL;
client->lastGCID = INVALID;
client->numSaved = 0;
- client->saveSet = (pointer *)NULL;
+ client->saveSet = (SaveSetElt *)NULL;
client->noClientException = Success;
#ifdef DEBUG
client->requestLogIndex = 0;
@@ -4057,6 +4071,14 @@ DeleteWindowFromAnySelections(pWin)
for (i = 0; i< NumCurrentSelections; i++)
if (CurrentSelections[i].pWin == pWin)
{
+ if (SelectionCallback)
+ {
+ SelectionInfoRec info;
+
+ info.selection = &CurrentSelections[i];
+ info.kind = SelectionWindowDestroy;
+ CallCallbacks(&SelectionCallback, &info);
+ }
CurrentSelections[i].pWin = (WindowPtr)NULL;
CurrentSelections[i].window = None;
CurrentSelections[i].client = NullClient;
@@ -4072,6 +4094,14 @@ DeleteClientFromAnySelections(client)
for (i = 0; i< NumCurrentSelections; i++)
if (CurrentSelections[i].client == client)
{
+ if (SelectionCallback)
+ {
+ SelectionInfoRec info;
+
+ info.selection = &CurrentSelections[i];
+ info.kind = SelectionWindowDestroy;
+ CallCallbacks(&SelectionCallback, &info);
+ }
CurrentSelections[i].pWin = (WindowPtr)NULL;
CurrentSelections[i].window = None;
CurrentSelections[i].client = NullClient;
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 98f734f64..595a6bdf3 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/dix/dixfonts.c,v 1.1.4.4.2.4 2004/03/08 00:36:56 alanc Exp $ */
+/* $XdotOrg: xc/programs/Xserver/dix/dixfonts.c,v 1.2 2004/04/23 19:04:44 eich Exp $ */
/* $XFree86: xc/programs/Xserver/dix/dixfonts.c,v 3.28 2003/11/08 02:02:03 dawes Exp $ */
/************************************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
@@ -23,8 +23,7 @@ SOFTWARE.
************************************************************************/
/* The panoramix components contained the following notice */
-/*****************************************************************
-
+/*
Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -50,7 +49,6 @@ dealings in this Software without prior written authorization from Digital
Equipment Corporation.
******************************************************************/
-
/* $Xorg: dixfonts.c,v 1.4 2000/08/17 19:48:18 cpqbld Exp $ */
#define NEED_REPLIES
diff --git a/dix/dixutils.c b/dix/dixutils.c
index 40f80d348..5bd5841a9 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -152,6 +152,22 @@ ClientTimeToServerTime(c)
* beware of too-small buffers
*/
+static unsigned char
+ISOLatin1ToLower (unsigned char source)
+{
+ unsigned char dest;
+ if ((source >= XK_A) && (source <= XK_Z))
+ dest = source + (XK_a - XK_A);
+ else if ((source >= XK_Agrave) && (source <= XK_Odiaeresis))
+ dest = source + (XK_agrave - XK_Agrave);
+ else if ((source >= XK_Ooblique) && (source <= XK_Thorn))
+ dest = source + (XK_oslash - XK_Ooblique);
+ else
+ dest = source;
+ return dest;
+}
+
+
void
CopyISOLatin1Lowered(dest, source, length)
register unsigned char *dest, *source;
@@ -160,17 +176,27 @@ CopyISOLatin1Lowered(dest, source, length)
register int i;
for (i = 0; i < length; i++, source++, dest++)
+ *dest = ISOLatin1ToLower (*source);
+ *dest = '\0';
+}
+
+int
+CompareISOLatin1Lowered(unsigned char *s1, int s1len,
+ unsigned char *s2, int s2len)
+{
+ unsigned char c1, c2;
+
+ for (;;)
{
- if ((*source >= XK_A) && (*source <= XK_Z))
- *dest = *source + (XK_a - XK_A);
- else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis))
- *dest = *source + (XK_agrave - XK_Agrave);
- else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn))
- *dest = *source + (XK_oslash - XK_Ooblique);
- else
- *dest = *source;
+ /* note -- compare against zero so that -1 ignores len */
+ c1 = s1len-- ? *s1++ : '\0';
+ c2 = s2len-- ? *s2++ : '\0';
+ if (!c1 ||
+ (c1 != c2 &&
+ (c1 = ISOLatin1ToLower (c1)) != (c2 = ISOLatin1ToLower (c2))))
+ break;
}
- *dest = '\0';
+ return (int) c1 - (int) c2;
}
#ifdef XCSECURITY
@@ -321,13 +347,14 @@ LookupClient(rid, client)
int
-AlterSaveSetForClient(client, pWin, mode)
- ClientPtr client;
- WindowPtr pWin;
- unsigned mode;
+AlterSaveSetForClient(ClientPtr client,
+ WindowPtr pWin,
+ unsigned mode,
+ Bool toRoot,
+ Bool remap)
{
int numnow;
- pointer *pTmp = NULL;
+ SaveSetElt *pTmp = NULL;
int j;
numnow = client->numSaved;
@@ -335,7 +362,7 @@ AlterSaveSetForClient(client, pWin, mode)
if (numnow)
{
pTmp = client->saveSet;
- while ((j < numnow) && (pTmp[j] != (pointer)pWin))
+ while ((j < numnow) && (SaveSetWindow(pTmp[j]) != (pointer)pWin))
j++;
}
if (mode == SetModeInsert)
@@ -343,12 +370,14 @@ AlterSaveSetForClient(client, pWin, mode)
if (j < numnow) /* duplicate */
return(Success);
numnow++;
- pTmp = (pointer *)xrealloc(client->saveSet, sizeof(pointer) * numnow);
+ pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow);
if (!pTmp)
return(BadAlloc);
client->saveSet = pTmp;
client->numSaved = numnow;
- client->saveSet[numnow - 1] = (pointer)pWin;
+ SaveSetAssignWindow(client->saveSet[numnow - 1], pWin);
+ SaveSetAssignToRoot(client->saveSet[numnow - 1], toRoot);
+ SaveSetAssignRemap(client->saveSet[numnow - 1], remap);
return(Success);
}
else if ((mode == SetModeDelete) && (j < numnow))
@@ -361,15 +390,14 @@ AlterSaveSetForClient(client, pWin, mode)
numnow--;
if (numnow)
{
- pTmp = (pointer *)xrealloc(client->saveSet,
- sizeof(pointer) * numnow);
+ pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow);
if (pTmp)
client->saveSet = pTmp;
}
else
{
xfree(client->saveSet);
- client->saveSet = (pointer *)NULL;
+ client->saveSet = (SaveSetElt *)NULL;
}
client->numSaved = numnow;
return(Success);
@@ -388,7 +416,7 @@ DeleteWindowFromAnySaveSet(pWin)
{
client = clients[i];
if (client && client->numSaved)
- (void)AlterSaveSetForClient(client, pWin, SetModeDelete);
+ (void)AlterSaveSetForClient(client, pWin, SetModeDelete, FALSE, TRUE);
}
}
diff --git a/dix/events.c b/dix/events.c
index 11cdca280..17b5d4182 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1,3 +1,4 @@
+/* $XdotOrg: xc/programs/Xserver/dix/events.c,v 1.6 2004/08/09 02:08:35 kem Exp $ */
/* $XFree86: xc/programs/Xserver/dix/events.c,v 3.51 2004/01/12 17:04:52 tsi Exp $ */
/************************************************************
@@ -105,6 +106,20 @@ extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
#include "security.h"
#endif
+#ifdef XEVIE
+extern WindowPtr *WindowTable;
+extern int xevieFlag;
+extern int xevieClientIndex;
+extern DeviceIntPtr xeviemouse;
+extern DeviceIntPtr xeviekb;
+extern Mask xevieMask;
+extern Mask xevieFilters[128];
+extern int xevieEventSent;
+extern int xevieKBEventSent;
+int xeviegrabState = 0;
+xEvent *xeviexE;
+#endif
+
#include "XIproto.h"
#include "exevents.h"
#include "extnsionst.h"
@@ -181,11 +196,6 @@ static WindowPtr *spriteTrace = (WindowPtr *)NULL;
static int spriteTraceSize = 0;
static int spriteTraceGood;
-typedef struct {
- int x, y;
- ScreenPtr pScreen;
-} HotSpot;
-
static struct {
CursorPtr current;
BoxRec hotLimits; /* logical constraints of hot spot */
@@ -206,6 +216,11 @@ static struct {
#endif
} sprite; /* info about the cursor sprite */
+#ifdef XEVIE
+WindowPtr xeviewin;
+HotSpot xeviehot;
+#endif
+
static void DoEnterLeaveEvents(
WindowPtr /*fromWin*/,
WindowPtr /*toWin*/,
@@ -2035,6 +2050,46 @@ WindowsRestructured()
(void) CheckMotion((xEvent *)NULL);
}
+#ifdef PANORAMIX
+/* This was added to support reconfiguration under Xdmx. The problem is
+ * that if the 0th screen (i.e., WindowTable[0]) is moved to an origin
+ * other than 0,0, the information in the private sprite structure must
+ * be updated accordingly, or XYToWindow (and other routines) will not
+ * compute correctly. */
+void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
+{
+ ScreenPtr pScreen = win->drawable.pScreen;
+ GrabPtr grab;
+
+ if (noPanoramiXExtension) return;
+
+ sprite.hot.x -= xoff;
+ sprite.hot.y -= yoff;
+
+ sprite.hotPhys.x -= xoff;
+ sprite.hotPhys.y -= yoff;
+
+ sprite.hotLimits.x1 -= xoff;
+ sprite.hotLimits.y1 -= yoff;
+ sprite.hotLimits.x2 -= xoff;
+ sprite.hotLimits.y2 -= yoff;
+
+ if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg1))
+ REGION_TRANSLATE(sprite.screen, &sprite.Reg1, xoff, yoff);
+ if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg2))
+ REGION_TRANSLATE(sprite.screen, &sprite.Reg2, xoff, yoff);
+
+ /* FIXME: if we call ConfineCursorToWindow, must we do anything else? */
+ if ((grab = inputInfo.pointer->grab) && grab->confineTo) {
+ if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
+ sprite.hotPhys.x = sprite.hotPhys.y = 0;
+ ConfineCursorToWindow(grab->confineTo, TRUE, TRUE);
+ } else
+ ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum],
+ TRUE, FALSE);
+}
+#endif
+
void
DefineInitialRootWindow(win)
register WindowPtr win;
@@ -2637,6 +2692,52 @@ ProcessKeyboardEvent (xE, keybd, count)
GrabPtr grab = keybd->grab;
Bool deactivateGrab = FALSE;
register KeyClassPtr keyc = keybd->key;
+#ifdef XEVIE
+ static Window rootWin = 0;
+
+ if(!xeviegrabState && xevieFlag && clients[xevieClientIndex] &&
+ (xevieMask & xevieFilters[xE->u.u.type])) {
+ key = xE->u.u.detail;
+ kptr = &keyc->down[key >> 3];
+ bit = 1 << (key & 7);
+ if((xE->u.u.type == KeyPress && (*kptr & bit)) ||
+ (xE->u.u.type == KeyRelease && !(*kptr & bit)))
+ {} else {
+#ifdef XKB
+ if(!noXkbExtension)
+ xevieKBEventSent = 0;
+#endif
+ if(!xevieKBEventSent)
+ {
+ xeviekb = keybd;
+ if(!rootWin) {
+ WindowPtr pWin = xeviewin->parent;
+ while(pWin) {
+ if(!pWin->parent) {
+ rootWin = pWin->drawable.id;
+ break;
+ }
+ pWin = pWin->parent;
+ };
+ }
+ xE->u.keyButtonPointer.event = xeviewin->drawable.id;
+ xE->u.keyButtonPointer.root = rootWin;
+ xE->u.keyButtonPointer.child = (xeviewin->firstChild) ? xeviewin->firstChild->
+drawable.id:0;
+ xE->u.keyButtonPointer.rootX = xeviehot.x;
+ xE->u.keyButtonPointer.rootY = xeviehot.y;
+ xE->u.keyButtonPointer.state = keyc->state;
+ WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE);
+#ifdef XKB
+ if(noXkbExtension)
+#endif
+ return;
+ }else {
+ xevieKBEventSent = 0;
+ }
+ }
+ }
+#endif
if (!syncEvents.playingEvents)
{
@@ -2782,6 +2883,18 @@ ProcessPointerEvent (xE, mouse, count)
#ifdef XKB
XkbSrvInfoPtr xkbi= inputInfo.keyboard->key->xkbInfo;
#endif
+#ifdef XEVIE
+ if(xevieFlag && clients[xevieClientIndex] && !xeviegrabState &&
+ (xevieMask & xevieFilters[xE->u.u.type])) {
+ if(xevieEventSent)
+ xevieEventSent = 0;
+ else {
+ xeviemouse = mouse;
+ WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE);
+ return;
+ }
+ }
+#endif
if (!syncEvents.playingEvents)
NoticeTime(xE)
diff --git a/dix/globals.c b/dix/globals.c
index 0ffedc828..4b62e4867 100644
--- a/dix/globals.c
+++ b/dix/globals.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/dix/globals.c,v 1.1.4.3.4.2 2004/03/04 20:16:04 kaleb Exp $ */
+/* $XdotOrg: xc/programs/Xserver/dix/globals.c,v 1.2 2004/04/23 19:04:44 eich Exp $ */
/* $XFree86: xc/programs/Xserver/dix/globals.c,v 1.12tsi Exp $ */
/************************************************************
diff --git a/dix/main.c b/dix/main.c
index ed6b6f6e1..0d0842215 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/dix/main.c,v 1.1.4.5.2.4 2004/03/08 00:36:56 alanc Exp $ */
+/* $XdotOrg: xc/programs/Xserver/dix/main.c,v 1.3 2004/06/30 20:06:53 kem Exp $ */
/* $XFree86: xc/programs/Xserver/dix/main.c,v 3.43 2003/10/30 21:21:02 herrb Exp $ */
/***********************************************************
@@ -251,6 +251,8 @@ main(int argc, char *argv[], char *envp[])
display = "0";
+ InitGlobals();
+
/* Quartz support on Mac OS X requires that the Cocoa event loop be in
* the main thread. This allows the X server main to be called again
* from another thread. */
@@ -498,6 +500,21 @@ main(int argc, char *argv[], char *envp[])
return(0);
}
+static int VendorRelease = VENDOR_RELEASE;
+static char *VendorString = VENDOR_STRING;
+
+void
+SetVendorRelease(int release)
+{
+ VendorRelease = release;
+}
+
+void
+SetVendorString(char *string)
+{
+ VendorString = string;
+}
+
static int padlength[4] = {0, 3, 2, 1};
#ifndef PANORAMIX
@@ -521,7 +538,7 @@ CreateConnectionBlock()
/* Leave off the ridBase and ridMask, these must be sent with
connection */
- setup.release = VENDOR_RELEASE;
+ setup.release = VendorRelease;
/*
* per-server image and bitmap parameters are defined in Xmd.h
*/
@@ -533,7 +550,7 @@ CreateConnectionBlock()
setup.bitmapBitOrder = screenInfo.bitmapBitOrder;
setup.motionBufferSize = NumMotionEvents();
setup.numRoots = screenInfo.numScreens;
- setup.nbytesVendor = strlen(VENDOR_STRING);
+ setup.nbytesVendor = strlen(VendorString);
setup.numFormats = screenInfo.numPixmapFormats;
setup.maxRequestSize = MAX_REQUEST_SIZE;
QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode);
@@ -550,7 +567,7 @@ CreateConnectionBlock()
sizesofar = sizeof(xConnSetup);
pBuf = ConnectionInfo + sizeof(xConnSetup);
- memmove(pBuf, VENDOR_STRING, (int)setup.nbytesVendor);
+ memmove(pBuf, VendorString, (int)setup.nbytesVendor);
sizesofar += setup.nbytesVendor;
pBuf += setup.nbytesVendor;
i = padlength[setup.nbytesVendor & 3];
diff --git a/dix/privates.c b/dix/privates.c
index 64d705e24..672738f29 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -358,7 +358,7 @@ InitCmapPrivFunc initPrivFunc;
pColormap->devPrivates = privs;
- if (!privs || !(*initPrivFunc)(pColormap))
+ if (!privs || !(*initPrivFunc)(pColormap,index))
{
colormapPrivateCount--;
return -1;
diff --git a/dix/resource.c b/dix/resource.c
index 7984f01ac..e394fdd57 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -74,7 +74,7 @@ Equipment Corporation.
******************************************************************/
/* $Xorg: resource.c,v 1.5 2001/02/09 02:04:40 xorgcvs Exp $ */
-/* $XdotOrg: xc/programs/Xserver/dix/resource.c,v 1.1.4.4.2.3 2004/03/08 00:36:56 alanc Exp $ */
+/* $XdotOrg: xc/programs/Xserver/dix/resource.c,v 1.3 2004/04/25 22:42:09 gisburn Exp $ */
/* $TOG: resource.c /main/41 1998/02/09 14:20:31 kaleb $ */
/* Routines to manage various kinds of resources:
@@ -559,7 +559,7 @@ FreeResource(id, skipDeleteFuncType)
}
}
if (!gotOne)
- FatalError("Freeing resource id=%lX which isn't there",
+ ErrorF("Freeing resource id=%lX which isn't there.\n",
(unsigned long)id);
}
diff --git a/dix/window.c b/dix/window.c
index 36289db5b..6660bfbd6 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/dix/window.c,v 1.1.4.4.2.3 2004/03/08 00:36:56 alanc Exp $ */
+/* $XdotOrg: xc/programs/Xserver/dix/window.c,v 1.6 2004/07/31 08:24:13 anholt Exp $ */
/* $Xorg: window.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */
/*
@@ -291,6 +291,9 @@ SetWindowToDefaults(register WindowPtr pWin)
pWin->srcBuffer = DBE_FRONT_BUFFER;
pWin->dstBuffer = DBE_FRONT_BUFFER;
#endif
+#ifdef COMPOSITE
+ pWin->redirectDraw = 0;
+#endif
}
static void
@@ -1661,6 +1664,19 @@ void
SetWinSize (pWin)
register WindowPtr pWin;
{
+#ifdef COMPOSITE
+ if (pWin->redirectDraw)
+ {
+ BoxRec box;
+
+ box.x1 = pWin->drawable.x;
+ box.y1 = pWin->drawable.y;
+ box.x2 = pWin->drawable.x + pWin->drawable.width;
+ box.y2 = pWin->drawable.y + pWin->drawable.height;
+ REGION_RESET (pScreen, &pWin->winSize, &box);
+ }
+ else
+#endif
ClippedRegionFromBox(pWin->parent, &pWin->winSize,
pWin->drawable.x, pWin->drawable.y,
(int)pWin->drawable.width,
@@ -1691,6 +1707,19 @@ SetBorderSize (pWin)
if (HasBorder (pWin)) {
bw = wBorderWidth (pWin);
+#ifdef COMPOSITE
+ if (pWin->redirectDraw)
+ {
+ BoxRec box;
+
+ box.x1 = pWin->drawable.x - bw;
+ box.y1 = pWin->drawable.y - bw;
+ box.x2 = pWin->drawable.x + pWin->drawable.width + bw;
+ box.y2 = pWin->drawable.y + pWin->drawable.height + bw;
+ REGION_RESET (pScreen, &pWin->borderSize, &box);
+ }
+ else
+#endif
ClippedRegionFromBox(pWin->parent, &pWin->borderSize,
pWin->drawable.x - bw, pWin->drawable.y - bw,
(int)(pWin->drawable.width + (bw<<1)),
@@ -3152,10 +3181,17 @@ HandleSaveSet(client)
for (j=0; j<client->numSaved; j++)
{
- pWin = (WindowPtr)client->saveSet[j];
- pParent = pWin->parent;
- while (pParent && (wClient (pParent) == client))
- pParent = pParent->parent;
+ pWin = SaveSetWindow(client->saveSet[j]);
+#ifdef XFIXES
+ if (SaveSetToRoot(client->saveSet[j]))
+ pParent = WindowTable[pWin->drawable.pScreen->myNum];
+ else
+#endif
+ {
+ pParent = pWin->parent;
+ while (pParent && (wClient (pParent) == client))
+ pParent = pParent->parent;
+ }
if (pParent)
{
if (pParent != pWin->parent)
@@ -3167,12 +3203,15 @@ HandleSaveSet(client)
if(!pWin->realized && pWin->mapped)
pWin->mapped = FALSE;
}
- MapWindow(pWin, client);
+#ifdef XFIXES
+ if (SaveSetRemap (client->saveSet[j]))
+#endif
+ MapWindow(pWin, client);
}
}
xfree(client->saveSet);
client->numSaved = 0;
- client->saveSet = (pointer *)NULL;
+ client->saveSet = (SaveSetElt *)NULL;
}
Bool
@@ -3227,8 +3266,9 @@ SendVisibilityNotify(pWin)
WindowPtr pWin;
{
xEvent event;
+#ifndef NO_XINERAMA_PORT
unsigned int visibility = pWin->visibility;
-
+#endif
#ifdef PANORAMIX
/* This is not quite correct yet, but it's close */
if(!noPanoramiXExtension) {
diff --git a/fb/fb.h b/fb/fb.h
index 9eb27eab2..0f24303f8 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -22,6 +22,8 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
+/* $XdotOrg: xc/programs/Xserver/fb/fb.h,v 1.6 2004/08/11 21:14:17 kem Exp $ */
+
#ifndef _FB_H_
#define _FB_H_
@@ -103,9 +105,10 @@ typedef unsigned __int64 FbBits;
# else
# if defined(__alpha__) || defined(__alpha) || \
defined(ia64) || defined(__ia64__) || \
- defined(__sparc64__) || \
+ defined(__sparc64__) || defined(_LP64) || \
defined(__s390x__) || \
defined(amd64) || defined (__amd64__) || \
+ defined (__powerpc64__) || \
(defined(sgi) && (_MIPS_SZLONG == 64))
typedef unsigned long FbBits;
# else
@@ -562,9 +565,13 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data);
} \
}
+/* XXX fb*PrivateIndex should be static, but it breaks the ABI */
+
extern int fbGCPrivateIndex;
+extern int fbGetGCPrivateIndex(void);
#ifndef FB_NO_WINDOW_PIXMAPS
extern int fbWinPrivateIndex;
+extern int fbGetWinPrivateIndex(void);
#endif
extern const GCOps fbGCOps;
extern const GCFuncs fbGCFuncs;
@@ -575,6 +582,7 @@ extern const GCFuncs fbGCFuncs;
#endif
#ifdef FB_OLD_SCREEN
+# define FB_OLD_MISCREENINIT /* miScreenInit requires 14 args, not 13 */
extern WindowPtr *WindowTable;
#endif
@@ -584,6 +592,7 @@ extern WindowPtr *WindowTable;
#ifdef FB_SCREEN_PRIVATE
extern int fbScreenPrivateIndex;
+extern int fbGetScreenPrivateIndex(void);
/* private field of a screen */
typedef struct {
@@ -592,7 +601,7 @@ typedef struct {
} FbScreenPrivRec, *FbScreenPrivPtr;
#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
- (pScreen)->devPrivates[fbScreenPrivateIndex].ptr)
+ (pScreen)->devPrivates[fbGetScreenPrivateIndex()].ptr)
#endif
/* private field of GC */
@@ -616,7 +625,7 @@ typedef struct {
} FbGCPrivRec, *FbGCPrivPtr;
#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
- (pGC)->devPrivates[fbGCPrivateIndex].ptr)
+ (pGC)->devPrivates[fbGetGCPrivateIndex()].ptr)
#ifdef FB_OLD_GC
#define fbGetCompositeClip(pGC) (fbGetGCPrivate(pGC)->pCompositeClip)
@@ -635,7 +644,7 @@ typedef struct {
#define fbGetWindowPixmap(d) fbGetScreenPixmap(((DrawablePtr) (d))->pScreen)
#else
#define fbGetWindowPixmap(pWin) ((PixmapPtr)\
- ((WindowPtr) (pWin))->devPrivates[fbWinPrivateIndex].ptr)
+ ((WindowPtr) (pWin))->devPrivates[fbGetWinPrivateIndex()].ptr)
#endif
#if defined(__DARWIN__)||defined(__CYGWIN__)
diff --git a/fb/fballpriv.c b/fb/fballpriv.c
index e7fcfd45b..29e98ae9f 100644
--- a/fb/fballpriv.c
+++ b/fb/fballpriv.c
@@ -27,10 +27,22 @@
#ifdef FB_SCREEN_PRIVATE
int fbScreenPrivateIndex;
+int fbGetScreenPrivateIndex(void)
+{
+ return fbScreenPrivateIndex;
+}
#endif
int fbGCPrivateIndex;
+int fbGetGCPrivateIndex(void)
+{
+ return fbGCPrivateIndex;
+}
#ifndef FB_NO_WINDOW_PIXMAPS
int fbWinPrivateIndex;
+int fbGetWinPrivateIndex(void)
+{
+ return fbWinPrivateIndex;
+}
#endif
int fbGeneration;
diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index e374de692..181a85f4f 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -1,5 +1,5 @@
/*
- * $XdotOrg: xc/programs/Xserver/fb/fbcompose.c,v 1.1.4.2.4.2 2004/03/04 20:16:09 kaleb Exp $
+ * $XdotOrg: xc/programs/Xserver/fb/fbcompose.c,v 1.3 2004/05/12 01:49:46 anholt Exp $
* $XFree86: xc/programs/Xserver/fb/fbcompose.c,v 1.17tsi Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
@@ -191,15 +191,15 @@ fbCombineMaskAlphaC (FbCompositeOperand *src,
a = (*msk->fetcha) (msk);
if (!a)
return 0;
-
- x = (*src->fetcha) (src);
- if (a == 0xffffffff)
- return x;
-
- m = FbInC(x,0,a,t);
- n = FbInC(x,8,a,t);
- o = FbInC(x,16,a,t);
- p = FbInC(x,24,a,t);
+
+ x = (*src->fetch) (src) >> 24;
+ if (x == 0xff)
+ return a;
+
+ m = FbInU(a,0,x,t);
+ n = FbInU(a,8,x,t);
+ o = FbInU(a,16,x,t);
+ p = FbInU(a,24,x,t);
return m|n|o|p;
}
@@ -608,7 +608,7 @@ fbCombineAtopC (FbCompositeOperand *src,
cs = fbCombineMaskC (src, msk);
d = (*dst->fetch) (dst);
s = cs.value;
- ad = cs.alpha;
+ ad = ~cs.alpha;
as = d >> 24;
m = FbGen(s,d,0,as,FbGet8(ad,0),t,u,v);
n = FbGen(s,d,8,as,FbGet8(ad,8),t,u,v);
@@ -698,10 +698,10 @@ fbCombineXorC (FbCompositeOperand *src,
s = cs.value;
ad = ~cs.alpha;
as = ~d >> 24;
- m = FbGen(s,d,0,as,ad,t,u,v);
- n = FbGen(s,d,8,as,ad,t,u,v);
- o = FbGen(s,d,16,as,ad,t,u,v);
- p = FbGen(s,d,24,as,ad,t,u,v);
+ m = FbGen(s,d,0,as,FbGet8(ad,0),t,u,v);
+ n = FbGen(s,d,8,as,FbGet8(ad,8),t,u,v);
+ o = FbGen(s,d,16,as,FbGet8(ad,16),t,u,v);
+ p = FbGen(s,d,24,as,FbGet8(ad,24),t,u,v);
(*dst->store) (dst, m|n|o|p);
}
@@ -763,10 +763,9 @@ fbCombineSaturateU (FbCompositeOperand *src,
FbCompositeOperand *dst)
{
CARD32 s = fbCombineMaskU (src, msk), d;
-#if 0
CARD16 sa, da;
CARD16 ad, as;
- CARD16 t;
+ CARD16 t, u, v;
CARD32 m,n,o,p;
d = (*dst->fetch) (dst);
@@ -789,16 +788,6 @@ fbCombineSaturateU (FbCompositeOperand *src,
p = FbGen(s,d,24,as,ad,t,u,v);
}
(*dst->store) (dst, m|n|o|p);
-#else
- if ((s >> 24) == 0xff)
- (*dst->store) (dst, s);
- else
- {
- d = (*dst->fetch) (dst);
- if ((s >> 24) > (d >> 24))
- (*dst->store) (dst, s);
- }
-#endif
}
void
@@ -831,7 +820,7 @@ fbCombineSaturateC (FbCompositeOperand *src,
else
n = FbGen (s, d, 8, (da << 8) / sg, 0xff, t, u, v);
- if (sr < da)
+ if (sr <= da)
o = FbAdd(s,d,16,t);
else
o = FbGen (s, d, 16, (da << 8) / sr, 0xff, t, u, v);
@@ -972,8 +961,8 @@ fbCombineDisjointGeneralC (FbCompositeOperand *src,
FbCompSrc cs;
CARD32 s, d;
CARD32 m,n,o,p;
- CARD32 Fa;
- CARD16 Fb, t, u, v;
+ CARD32 Fa, Fb;
+ CARD16 t, u, v;
CARD32 sa;
CARD8 da;
@@ -996,10 +985,10 @@ fbCombineDisjointGeneralC (FbCompositeOperand *src,
Fa = m|n|o|p;
break;
case CombineAIn:
- m = fbCombineDisjointOutPart ((CARD8) (sa >> 0), da);
- n = fbCombineDisjointOutPart ((CARD8) (sa >> 8), da) << 8;
- o = fbCombineDisjointOutPart ((CARD8) (sa >> 16), da) << 16;
- p = fbCombineDisjointOutPart ((CARD8) (sa >> 24), da) << 24;
+ m = fbCombineDisjointInPart ((CARD8) (sa >> 0), da);
+ n = fbCombineDisjointInPart ((CARD8) (sa >> 8), da) << 8;
+ o = fbCombineDisjointInPart ((CARD8) (sa >> 16), da) << 16;
+ p = fbCombineDisjointInPart ((CARD8) (sa >> 24), da) << 24;
Fa = m|n|o|p;
break;
case CombineA:
@@ -1012,19 +1001,27 @@ fbCombineDisjointGeneralC (FbCompositeOperand *src,
Fb = 0;
break;
case CombineBOut:
- Fb = fbCombineDisjointOutPart (da, sa);
+ m = fbCombineDisjointOutPart (da, (CARD8) (sa >> 0));
+ n = fbCombineDisjointOutPart (da, (CARD8) (sa >> 8)) << 8;
+ o = fbCombineDisjointOutPart (da, (CARD8) (sa >> 16)) << 16;
+ p = fbCombineDisjointOutPart (da, (CARD8) (sa >> 24)) << 24;
+ Fb = m|n|o|p;
break;
case CombineBIn:
- Fb = fbCombineDisjointInPart (da, sa);
+ m = fbCombineDisjointInPart (da, (CARD8) (sa >> 0));
+ n = fbCombineDisjointInPart (da, (CARD8) (sa >> 8)) << 8;
+ o = fbCombineDisjointInPart (da, (CARD8) (sa >> 16)) << 16;
+ p = fbCombineDisjointInPart (da, (CARD8) (sa >> 24)) << 24;
+ Fb = m|n|o|p;
break;
case CombineB:
- Fb = 0xff;
+ Fb = 0xffffffff;
break;
}
- m = FbGen (s,d,0,FbGet8(Fa,0),Fb,t,u,v);
- n = FbGen (s,d,8,FbGet8(Fa,8),Fb,t,u,v);
- o = FbGen (s,d,16,FbGet8(Fa,16),Fb,t,u,v);
- p = FbGen (s,d,24,FbGet8(Fa,24),Fb,t,u,v);
+ m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t,u,v);
+ n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t,u,v);
+ o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t,u,v);
+ p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t,u,v);
s = m|n|o|p;
(*dst->store) (dst, s);
}
@@ -1065,21 +1062,6 @@ fbCombineDisjointOverC (FbCompositeOperand *src,
fbCombineDisjointGeneralC (src, msk, dst, CombineAOver);
}
-void
-fbCombineDisjointOverReverseU (FbCompositeOperand *src,
- FbCompositeOperand *msk,
- FbCompositeOperand *dst)
-{
- fbCombineDisjointGeneralU (src, msk, dst, CombineBOver);
-}
-
-void
-fbCombineDisjointOverReverseC (FbCompositeOperand *src,
- FbCompositeOperand *msk,
- FbCompositeOperand *dst)
-{
- fbCombineDisjointGeneralC (src, msk, dst, CombineBOver);
-}
void
fbCombineDisjointInU (FbCompositeOperand *src,
@@ -1281,8 +1263,8 @@ fbCombineConjointGeneralC (FbCompositeOperand *src,
FbCompSrc cs;
CARD32 s, d;
CARD32 m,n,o,p;
- CARD32 Fa;
- CARD16 Fb, t, u, v;
+ CARD32 Fa, Fb;
+ CARD16 t, u, v;
CARD32 sa;
CARD8 da;
@@ -1305,10 +1287,10 @@ fbCombineConjointGeneralC (FbCompositeOperand *src,
Fa = m|n|o|p;
break;
case CombineAIn:
- m = fbCombineConjointOutPart ((CARD8) (sa >> 0), da);
- n = fbCombineConjointOutPart ((CARD8) (sa >> 8), da) << 8;
- o = fbCombineConjointOutPart ((CARD8) (sa >> 16), da) << 16;
- p = fbCombineConjointOutPart ((CARD8) (sa >> 24), da) << 24;
+ m = fbCombineConjointInPart ((CARD8) (sa >> 0), da);
+ n = fbCombineConjointInPart ((CARD8) (sa >> 8), da) << 8;
+ o = fbCombineConjointInPart ((CARD8) (sa >> 16), da) << 16;
+ p = fbCombineConjointInPart ((CARD8) (sa >> 24), da) << 24;
Fa = m|n|o|p;
break;
case CombineA:
@@ -1321,19 +1303,27 @@ fbCombineConjointGeneralC (FbCompositeOperand *src,
Fb = 0;
break;
case CombineBOut:
- Fb = fbCombineConjointOutPart (da, sa);
+ m = fbCombineConjointOutPart (da, (CARD8) (sa >> 0));
+ n = fbCombineConjointOutPart (da, (CARD8) (sa >> 8)) << 8;
+ o = fbCombineConjointOutPart (da, (CARD8) (sa >> 16)) << 16;
+ p = fbCombineConjointOutPart (da, (CARD8) (sa >> 24)) << 24;
+ Fb = m|n|o|p;
break;
case CombineBIn:
- Fb = fbCombineConjointInPart (da, sa);
+ m = fbCombineConjointInPart (da, (CARD8) (sa >> 0));
+ n = fbCombineConjointInPart (da, (CARD8) (sa >> 8)) << 8;
+ o = fbCombineConjointInPart (da, (CARD8) (sa >> 16)) << 16;
+ p = fbCombineConjointInPart (da, (CARD8) (sa >> 24)) << 24;
+ Fb = m|n|o|p;
break;
case CombineB:
- Fb = 0xff;
+ Fb = 0xffffffff;
break;
}
- m = FbGen (s,d,0,FbGet8(Fa,0),Fb,t,u,v);
- n = FbGen (s,d,8,FbGet8(Fa,8),Fb,t,u,v);
- o = FbGen (s,d,16,FbGet8(Fa,16),Fb,t,u,v);
- p = FbGen (s,d,24,FbGet8(Fa,24),Fb,t,u,v);
+ m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t,u,v);
+ n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t,u,v);
+ o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t,u,v);
+ p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t,u,v);
s = m|n|o|p;
(*dst->store) (dst, s);
}
@@ -1519,14 +1509,14 @@ FbCombineFunc fbCombineFuncU[] = {
fbCombineAtopReverseU,
fbCombineXorU,
fbCombineAddU,
- fbCombineDisjointOverU, /* Saturate */
+ fbCombineSaturateU,
0,
0,
fbCombineClear,
fbCombineSrcU,
fbCombineDst,
fbCombineDisjointOverU,
- fbCombineDisjointOverReverseU,
+ fbCombineSaturateU, /* DisjointOverReverse */
fbCombineDisjointInU,
fbCombineDisjointInReverseU,
fbCombineDisjointOutU,
@@ -1566,14 +1556,14 @@ FbCombineFunc fbCombineFuncC[] = {
fbCombineAtopReverseC,
fbCombineXorC,
fbCombineAddC,
- fbCombineDisjointOverC, /* Saturate */
+ fbCombineSaturateC,
0,
0,
fbCombineClear, /* 0x10 */
fbCombineSrcC,
fbCombineDst,
fbCombineDisjointOverC,
- fbCombineDisjointOverReverseC,
+ fbCombineSaturateC, /* DisjointOverReverse */
fbCombineDisjointInC,
fbCombineDisjointInReverseC,
fbCombineDisjointOutC,
diff --git a/fb/fbedge.c b/fb/fbedge.c
new file mode 100644
index 000000000..7a383020b
--- /dev/null
+++ b/fb/fbedge.c
@@ -0,0 +1,134 @@
+/*
+ * $Id$
+ *
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "fb.h"
+
+#ifdef RENDER
+
+#include "picturestr.h"
+#include "mipict.h"
+#include "renderedge.h"
+#include "fbpict.h"
+
+/*
+ * 8 bit alpha
+ */
+
+#define N_BITS 8
+#define rasterizeEdges fbRasterizeEdges8
+
+#define DefineAlpha(line,x) \
+ CARD8 *__ap = (CARD8 *) line + (x)
+
+#define StepAlpha __ap++
+
+#define AddAlpha(a) { \
+ CARD16 __a = a + *__ap; \
+ *__ap = ((CARD8) ((__a) | (0 - ((__a) >> 8)))); \
+}
+
+#include "fbedgeimp.h"
+
+#undef AddAlpha
+#undef StepAlpha
+#undef DefineAlpha
+#undef rasterizeEdges
+#undef N_BITS
+
+/*
+ * 4 bit alpha
+ */
+
+#define N_BITS 4
+#define rasterizeEdges fbRasterizeEdges4
+
+#if BITMAP_BIT_ORDER == LSBFirst
+#define Shift4(o) ((o) << 2)
+#else
+#define Shift4(o) ((1-(o)) << 2)
+#endif
+
+#define Get4(x,o) (((x) >> Shift4(o)) & 0xf)
+#define Put4(x,o,v) (((x) & ~(0xf << Shift4(o))) | (((v) & 0xf) << Shift4(o)))
+
+#define DefineAlpha(line,x) \
+ CARD8 *__ap = (CARD8 *) line + ((x) >> 1); \
+ int __ao = (x) & 1
+
+#define StepAlpha ((__ap += __ao), (__ao ^= 1))
+
+#define AddAlpha(a) { \
+ CARD8 __o = *__ap; \
+ CARD8 __a = (a) + Get4(__o, __ao); \
+ *__ap = Put4 (__o, __ao, __a | (0 - ((__a) >> 4))); \
+}
+
+#include "fbedgeimp.h"
+
+#undef AddAlpha
+#undef StepAlpha
+#undef DefineAlpha
+#undef rasterizeEdges
+#undef N_BITS
+
+
+/*
+ * 1 bit alpha
+ */
+
+#define N_BITS 1
+#define rasterizeEdges fbRasterizeEdges1
+
+#include "fbedgeimp.h"
+
+#undef rasterizeEdges
+#undef N_BITS
+
+void
+fbRasterizeEdges (FbBits *buf,
+ int bpp,
+ int width,
+ int stride,
+ RenderEdge *l,
+ RenderEdge *r,
+ xFixed t,
+ xFixed b)
+{
+ switch (bpp) {
+ case 1:
+ fbRasterizeEdges1 (buf, width, stride, l, r, t, b);
+ break;
+ case 4:
+ fbRasterizeEdges4 (buf, width, stride, l, r, t, b);
+ break;
+ case 8:
+ fbRasterizeEdges8 (buf, width, stride, l, r, t, b);
+ break;
+ }
+}
+
+#endif /* RENDER */
diff --git a/fb/fbedgeimp.h b/fb/fbedgeimp.h
new file mode 100644
index 000000000..4a91adc19
--- /dev/null
+++ b/fb/fbedgeimp.h
@@ -0,0 +1,134 @@
+/*
+ * $Id$
+ *
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef rasterizeSpan
+#endif
+
+static void
+rasterizeEdges (FbBits *buf,
+ int width,
+ int stride,
+ RenderEdge *l,
+ RenderEdge *r,
+ xFixed t,
+ xFixed b)
+{
+ xFixed y = t;
+ FbBits *line;
+
+ line = buf + xFixedToInt (y) * stride;
+
+ for (;;)
+ {
+ xFixed lx, rx;
+ int lxi, rxi;
+
+ /* clip X */
+ lx = l->x;
+ if (lx < 0)
+ lx = 0;
+ rx = r->x;
+ if (xFixedToInt (rx) >= width)
+ rx = IntToxFixed (width);
+
+ /* Skip empty (or backwards) sections */
+ if (rx > lx)
+ {
+
+ /* Find pixel bounds for span */
+ lxi = xFixedToInt (lx);
+ rxi = xFixedToInt (rx);
+
+#if N_BITS == 1
+ {
+ FbBits *a = line;
+ FbBits startmask, endmask;
+ int nmiddle;
+ int width = rxi - lxi;
+ int x = lxi;
+
+ a += x >> FB_SHIFT;
+ x &= FB_MASK;
+
+ FbMaskBits (x, width, startmask, nmiddle, endmask);
+ if (startmask)
+ *a++ |= startmask;
+ while (nmiddle--)
+ *a++ = FB_ALLONES;
+ if (endmask)
+ *a |= endmask;
+ }
+#else
+ {
+ DefineAlpha(line,lxi);
+ int lxs, rxs;
+
+ /* Sample coverage for edge pixels */
+ lxs = RenderSamplesX (lx, N_BITS);
+ rxs = RenderSamplesX (rx, N_BITS);
+
+ /* Add coverage across row */
+ if (lxi == rxi)
+ {
+ AddAlpha (rxs - lxs);
+ }
+ else
+ {
+ int xi;
+
+ AddAlpha (N_X_FRAC(N_BITS) - lxs);
+ StepAlpha;
+ for (xi = lxi + 1; xi < rxi; xi++)
+ {
+ AddAlpha (N_X_FRAC(N_BITS));
+ StepAlpha;
+ }
+ AddAlpha (rxs);
+ }
+ }
+#endif
+ }
+
+ if (y == b)
+ break;
+
+#if N_BITS > 1
+ if (xFixedFrac (y) != Y_FRAC_LAST(N_BITS))
+ {
+ RenderEdgeStepSmall (l);
+ RenderEdgeStepSmall (r);
+ y += STEP_Y_SMALL(N_BITS);
+ }
+ else
+#endif
+ {
+ RenderEdgeStepBig (l);
+ RenderEdgeStepBig (r);
+ y += STEP_Y_BIG(N_BITS);
+ line += stride;
+ }
+ }
+}
+
+#undef rasterizeSpan
diff --git a/fb/fbfill.c b/fb/fbfill.c
index d03bc6461..f5842c252 100644
--- a/fb/fbfill.c
+++ b/fb/fbfill.c
@@ -24,6 +24,7 @@
/* $XFree86: xc/programs/Xserver/fb/fbfill.c,v 1.5 2003/01/29 00:43:33 torrey Exp $ */
#include "fb.h"
+#include "fbmmx.h"
void
fbFill (DrawablePtr pDrawable,
@@ -43,6 +44,11 @@ fbFill (DrawablePtr pDrawable,
switch (pGC->fillStyle) {
case FillSolid:
+#ifdef USE_GCC34_MMX
+ if (!pPriv->and && fbHaveMMX())
+ if (fbSolidFillmmx (pDrawable, x, y, width, height, pPriv->xor))
+ return;
+#endif
fbSolid (dst + (y + dstYoff) * dstStride,
dstStride,
(x + dstXoff) * dstBpp,
diff --git a/fb/fbgc.c b/fb/fbgc.c
index a3d1b0bc6..f854afc78 100644
--- a/fb/fbgc.c
+++ b/fb/fbgc.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XdotOrg: xc/programs/Xserver/fb/fbgc.c,v 1.1.4.1.4.2 2004/03/04 20:16:09 kaleb Exp $ */
+/* $XdotOrg: xc/programs/Xserver/fb/fbgc.c,v 1.2 2004/04/23 19:05:14 eich Exp $ */
/* $XFree86: xc/programs/Xserver/fb/fbgc.c,v 1.14 2003/12/18 15:22:32 alanh Exp $ */
#include "fb.h"
diff --git a/fb/fbglyph.c b/fb/fbglyph.c
index 1e13f76d1..128abc4bf 100644
--- a/fb/fbglyph.c
+++ b/fb/fbglyph.c
@@ -1,5 +1,5 @@
/*
- * $XdotOrg: xc/programs/Xserver/fb/fbglyph.c,v 1.1.4.1.4.2 2004/03/04 20:16:09 kaleb Exp $
+ * $XdotOrg: xc/programs/Xserver/fb/fbglyph.c,v 1.2 2004/04/23 19:05:14 eich Exp $
* $XFree86: xc/programs/Xserver/fb/fbglyph.c,v 1.12tsi Exp $
*
* Copyright 1998 Keith Packard
diff --git a/fb/fboverlay.c b/fb/fboverlay.c
index 28068db83..e9ac14eda 100644
--- a/fb/fboverlay.c
+++ b/fb/fboverlay.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/programs/Xserver/fb/fboverlay.c,v 1.6tsi Exp $
+ * $XFree86: xc/programs/Xserver/fb/fboverlay.c,v 1.7 2003/11/10 18:21:47 tsi Exp $
*
* Copyright 2000 SuSE, Inc.
*
@@ -23,12 +23,19 @@
* Author: Keith Packard, SuSE, Inc.
*/
+/* $XdotOrg: xc/programs/Xserver/fb/fboverlay.c,v 1.4 2004/07/30 20:30:51 ajax Exp $ */
+
#include "fb.h"
#include "fboverlay.h"
int fbOverlayGeneration;
int fbOverlayScreenPrivateIndex = -1;
+int fbOverlayGetScreenPrivateIndex(void)
+{
+ return fbOverlayScreenPrivateIndex;
+}
+
/*
* Replace this if you want something supporting
* multiple overlays with the same depth
@@ -402,7 +409,7 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
if (! miScreenInit(pScreen, 0, xsize, ysize, dpix, dpiy, 0,
depth1, ndepths, depths,
defaultVisual, nvisuals, visuals
-#ifdef FB_OLD_SCREEN
+#ifdef FB_OLD_MISCREENINIT
, (miBSFuncPtr) 0
#endif
))
diff --git a/fb/fboverlay.h b/fb/fboverlay.h
index 72891ece3..aecb3856f 100644
--- a/fb/fboverlay.h
+++ b/fb/fboverlay.h
@@ -27,7 +27,8 @@
#define _FBOVERLAY_H_
extern int fbOverlayGeneration;
-extern int fbOverlayScreenPrivateIndex;
+extern int fbOverlayScreenPrivateIndex; /* XXX should be static */
+extern int fbOverlayGetScreenPrivateIndex(void);
#ifndef FB_OVERLAY_MAX
#define FB_OVERLAY_MAX 2
@@ -58,8 +59,8 @@ typedef struct _fbOverlayScrPriv {
} FbOverlayScrPrivRec, *FbOverlayScrPrivPtr;
#define fbOverlayGetScrPriv(s) \
- ((fbOverlayScreenPrivateIndex != -1) ? \
- (s)->devPrivates[fbOverlayScreenPrivateIndex].ptr : NULL)
+ ((fbOverlayGetScreenPrivateIndex() != -1) ? \
+ (s)->devPrivates[fbOverlayGetScreenPrivateIndex()].ptr : NULL)
Bool
fbOverlayCreateWindow(WindowPtr pWin);
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 533f08d01..ff638e5ce 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -30,34 +30,8 @@
#include "picturestr.h"
#include "mipict.h"
#include "fbpict.h"
+#include "fbmmx.h"
-#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \
- (((s) >> 5) & 0x07e0) | \
- (((s) >> 8) & 0xf800))
-#define cvt0565to8888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
- ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
- ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
-
-#if IMAGE_BYTE_ORDER == MSBFirst
-#define Fetch24(a) ((unsigned long) (a) & 1 ? \
- ((*(a) << 16) | *((CARD16 *) ((a)+1))) : \
- ((*((CARD16 *) (a)) << 8) | *((a)+2)))
-#define Store24(a,v) ((unsigned long) (a) & 1 ? \
- ((*(a) = (CARD8) ((v) >> 16)), \
- (*((CARD16 *) ((a)+1)) = (CARD16) (v))) : \
- ((*((CARD16 *) (a)) = (CARD16) ((v) >> 8)), \
- (*((a)+2) = (CARD8) (v))))
-#else
-#define Fetch24(a) ((unsigned long) (a) & 1 ? \
- ((*(a)) | (*((CARD16 *) ((a)+1)) << 8)) : \
- ((*((CARD16 *) (a))) | (*((a)+2) << 16)))
-#define Store24(a,v) ((unsigned long) (a) & 1 ? \
- ((*(a) = (CARD8) (v)), \
- (*((CARD16 *) ((a)+1)) = (CARD16) ((v) >> 8))) : \
- ((*((CARD16 *) (a)) = (CARD16) (v)),\
- (*((a)+2) = (CARD8) ((v) >> 16))))
-#endif
-
CARD32
fbOver (CARD32 x, CARD32 y)
{
@@ -99,43 +73,6 @@ fbIn (CARD32 x, CARD8 y)
return m|n|o|p;
}
-#define fbComposeGetSolid(pict, bits) { \
- FbBits *__bits__; \
- FbStride __stride__; \
- int __bpp__; \
- int __xoff__,__yoff__; \
-\
- fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
- switch (__bpp__) { \
- case 32: \
- (bits) = *(CARD32 *) __bits__; \
- break; \
- case 24: \
- (bits) = Fetch24 ((CARD8 *) __bits__); \
- break; \
- case 16: \
- (bits) = *(CARD16 *) __bits__; \
- (bits) = cvt0565to8888(bits); \
- break; \
- default: \
- return; \
- } \
- /* manage missing src alpha */ \
- if ((pict)->pFormat->direct.alphaMask == 0) \
- (bits) |= 0xff000000; \
-}
-
-#define fbComposeGetStart(pict,x,y,type,stride,line,mul) {\
- FbBits *__bits__; \
- FbStride __stride__; \
- int __bpp__; \
- int __xoff__,__yoff__; \
-\
- fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
- (stride) = __stride__ * sizeof (FbBits) / sizeof (type); \
- (line) = ((type *) __bits__) + (stride) * ((y) - __yoff__) + (mul) * ((x) - __xoff__); \
-}
-
/*
* Naming convention:
*
@@ -168,7 +105,7 @@ fbCompositeSolidMask_nx8x8888 (CARD8 op,
srca = src >> 24;
if (src == 0)
return;
-
+
fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
@@ -940,7 +877,12 @@ fbComposite (CARD8 op,
switch (pDst->format) {
case PICT_r5g6b5:
case PICT_b5g6r5:
- func = fbCompositeSolidMask_nx8x0565;
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8x0565mmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8x0565;
break;
case PICT_r8g8b8:
case PICT_b8g8r8:
@@ -950,7 +892,12 @@ fbComposite (CARD8 op,
case PICT_x8r8g8b8:
case PICT_a8b8g8r8:
case PICT_x8b8g8r8:
- func = fbCompositeSolidMask_nx8x8888;
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8x8888mmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8x8888;
break;
}
break;
@@ -959,10 +906,20 @@ fbComposite (CARD8 op,
switch (pDst->format) {
case PICT_a8r8g8b8:
case PICT_x8r8g8b8:
- func = fbCompositeSolidMask_nx8888x8888C;
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x8888Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x8888C;
break;
case PICT_r5g6b5:
- func = fbCompositeSolidMask_nx8888x0565C;
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x0565Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x0565C;
break;
}
}
@@ -972,10 +929,20 @@ fbComposite (CARD8 op,
switch (pDst->format) {
case PICT_a8b8g8r8:
case PICT_x8b8g8r8:
- func = fbCompositeSolidMask_nx8888x8888C;
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x8888Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x8888C;
break;
case PICT_b5g6r5:
- func = fbCompositeSolidMask_nx8888x0565C;
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x0565Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x0565C;
break;
}
}
@@ -993,57 +960,145 @@ fbComposite (CARD8 op,
func = fbCompositeSolidMask_nx1xn;
break;
}
+ break;
+ }
+ }
+ }
+ else /* has mask and non-repeating source */
+ {
+ if (pSrc->pDrawable == pMask->pDrawable &&
+ xSrc == xMask && ySrc == yMask &&
+ !pMask->componentAlpha)
+ {
+ switch (pSrc->format) {
+ case PICT_x8b8g8r8:
+ switch (pMask->format) {
+ case PICT_a8r8g8b8:
+ case PICT_a8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx8888mmx;
+#endif
+ break;
+ case PICT_r5g6b5:
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx0565mmx;
+#endif
+ break;
+ }
+ break;
+ }
+ break;
+ case PICT_x8r8g8b8:
+ switch (pMask->format) {
+ case PICT_a8r8g8b8:
+ case PICT_a8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx8888mmx;
+#endif
+ break;
+ case PICT_r5g6b5:
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx0565mmx;
+#endif
+ break;
+ }
+ break;
+ }
+ break;
}
+ break;
}
}
}
else
{
- switch (pSrc->format) {
- case PICT_a8r8g8b8:
- case PICT_x8r8g8b8:
- switch (pDst->format) {
+ if (srcRepeat &&
+ pSrc->pDrawable->width == 1 &&
+ pSrc->pDrawable->height == 1)
+ {
+ /* no mask and repeating source */
+ switch (pSrc->format) {
case PICT_a8r8g8b8:
- case PICT_x8r8g8b8:
- func = fbCompositeSrc_8888x8888;
- break;
- case PICT_r8g8b8:
- func = fbCompositeSrc_8888x0888;
- break;
- case PICT_r5g6b5:
- func = fbCompositeSrc_8888x0565;
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ {
+ srcRepeat = FALSE;
+ func = fbCompositeSolid_nx8888mmx;
+ }
+#endif
+ break;
+ case PICT_r5g6b5:
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ {
+ srcRepeat = FALSE;
+ func = fbCompositeSolid_nx0565mmx;
+ }
+#endif
+ break;
+ }
break;
}
- break;
- case PICT_a8b8g8r8:
- case PICT_x8b8g8r8:
- switch (pDst->format) {
- case PICT_a8b8g8r8:
- case PICT_x8b8g8r8:
- func = fbCompositeSrc_8888x8888;
- break;
- case PICT_b8g8r8:
- func = fbCompositeSrc_8888x0888;
+ }
+ else
+ {
+ switch (pSrc->format) {
+ case PICT_a8r8g8b8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+ func = fbCompositeSrc_8888x8888;
+ break;
+ case PICT_r8g8b8:
+ func = fbCompositeSrc_8888x0888;
+ break;
+ case PICT_r5g6b5:
+ func = fbCompositeSrc_8888x0565;
+ break;
+ }
break;
- case PICT_b5g6r5:
- func = fbCompositeSrc_8888x0565;
+ case PICT_a8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+ func = fbCompositeSrc_8888x8888;
+ break;
+ case PICT_b8g8r8:
+ func = fbCompositeSrc_8888x0888;
+ break;
+ case PICT_b5g6r5:
+ func = fbCompositeSrc_8888x0565;
+ break;
+ }
break;
- }
- break;
- case PICT_r5g6b5:
- switch (pDst->format) {
case PICT_r5g6b5:
- func = fbCompositeSrc_0565x0565;
+ switch (pDst->format) {
+ case PICT_r5g6b5:
+ func = fbCompositeSrc_0565x0565;
+ break;
+ }
break;
- }
- break;
- case PICT_b5g6r5:
- switch (pDst->format) {
case PICT_b5g6r5:
- func = fbCompositeSrc_0565x0565;
+ switch (pDst->format) {
+ case PICT_b5g6r5:
+ func = fbCompositeSrc_0565x0565;
+ break;
+ }
break;
}
- break;
}
}
break;
@@ -1054,21 +1109,36 @@ fbComposite (CARD8 op,
case PICT_a8r8g8b8:
switch (pDst->format) {
case PICT_a8r8g8b8:
- func = fbCompositeSrcAdd_8888x8888;
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrcAdd_8888x8888mmx;
+ else
+#endif
+ func = fbCompositeSrcAdd_8888x8888;
break;
}
break;
case PICT_a8b8g8r8:
switch (pDst->format) {
case PICT_a8b8g8r8:
- func = fbCompositeSrcAdd_8888x8888;
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrcAdd_8888x8888mmx;
+ else
+#endif
+ func = fbCompositeSrcAdd_8888x8888;
break;
}
break;
case PICT_a8:
switch (pDst->format) {
case PICT_a8:
- func = fbCompositeSrcAdd_8000x8000;
+#ifdef USE_GCC34_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrcAdd_8000x8000mmx;
+ else
+#endif
+ func = fbCompositeSrcAdd_8000x8000;
break;
}
break;
@@ -1160,6 +1230,8 @@ fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
ps->Glyphs = miGlyphs;
ps->CompositeRects = miCompositeRects;
ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
+ ps->AddTraps = fbAddTraps;
+ ps->AddTriangles = fbAddTriangles;
#endif /* RENDER */
diff --git a/fb/fbpict.h b/fb/fbpict.h
index 9ecc7a909..82f722c41 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -25,6 +25,8 @@
#ifndef _FBPICT_H_
#define _FBPICT_H_
+#include "renderedge.h"
+
#define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
#define FbIntDiv(a,b) (((CARD16) (a) * 255) / (b))
@@ -70,6 +72,70 @@ typedef void (*CompositeFunc) (CARD8 op,
CARD16 width,
CARD16 height);
+#define fbComposeGetSolid(pict, bits) { \
+ FbBits *__bits__; \
+ FbStride __stride__; \
+ int __bpp__; \
+ int __xoff__,__yoff__; \
+\
+ fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
+ switch (__bpp__) { \
+ case 32: \
+ (bits) = *(CARD32 *) __bits__; \
+ break; \
+ case 24: \
+ (bits) = Fetch24 ((CARD8 *) __bits__); \
+ break; \
+ case 16: \
+ (bits) = *(CARD16 *) __bits__; \
+ (bits) = cvt0565to8888(bits); \
+ break; \
+ default: \
+ return; \
+ } \
+ /* manage missing src alpha */ \
+ if ((pict)->pFormat->direct.alphaMask == 0) \
+ (bits) |= 0xff000000; \
+}
+
+#define fbComposeGetStart(pict,x,y,type,stride,line,mul) {\
+ FbBits *__bits__; \
+ FbStride __stride__; \
+ int __bpp__; \
+ int __xoff__,__yoff__; \
+\
+ fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
+ (stride) = __stride__ * sizeof (FbBits) / sizeof (type); \
+ (line) = ((type *) __bits__) + (stride) * ((y) - __yoff__) + (mul) * ((x) - __xoff__); \
+}
+#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \
+ (((s) >> 5) & 0x07e0) | \
+ (((s) >> 8) & 0xf800))
+#define cvt0565to8888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
+ ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
+ ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define Fetch24(a) ((unsigned long) (a) & 1 ? \
+ ((*(a) << 16) | *((CARD16 *) ((a)+1))) : \
+ ((*((CARD16 *) (a)) << 8) | *((a)+2)))
+#define Store24(a,v) ((unsigned long) (a) & 1 ? \
+ ((*(a) = (CARD8) ((v) >> 16)), \
+ (*((CARD16 *) ((a)+1)) = (CARD16) (v))) : \
+ ((*((CARD16 *) (a)) = (CARD16) ((v) >> 8)), \
+ (*((a)+2) = (CARD8) (v))))
+#else
+#define Fetch24(a) ((unsigned long) (a) & 1 ? \
+ ((*(a)) | (*((CARD16 *) ((a)+1)) << 8)) : \
+ ((*((CARD16 *) (a))) | (*((a)+2) << 16)))
+#define Store24(a,v) ((unsigned long) (a) & 1 ? \
+ ((*(a) = (CARD8) (v)), \
+ (*((CARD16 *) ((a)+1)) = (CARD16) ((v) >> 8))) : \
+ ((*((CARD16 *) (a)) = (CARD16) (v)),\
+ (*((a)+2) = (CARD8) ((v) >> 16))))
+#endif
+
+
typedef struct _FbCompositeOperand FbCompositeOperand;
typedef CARD32 (*FbCompositeFetch)(FbCompositeOperand *op);
@@ -333,15 +399,8 @@ fbCombineDisjointOverC (FbCompositeOperand *src,
FbCompositeOperand *msk,
FbCompositeOperand *dst);
-void
-fbCombineDisjointOverReverseU (FbCompositeOperand *src,
- FbCompositeOperand *msk,
- FbCompositeOperand *dst);
-
-void
-fbCombineDisjointOverReverseC (FbCompositeOperand *src,
- FbCompositeOperand *msk,
- FbCompositeOperand *dst);
+#define fbCombineDisjointOverReverseU fbCombineSaturateU
+#define fbCombineDisjointOverReverseC fbCombineSaturateC
void
fbCombineDisjointInU (FbCompositeOperand *src,
@@ -760,6 +819,17 @@ fbCompositeGeneral (CARD8 op,
CARD16 height);
+/* fbedge.c */
+void
+fbRasterizeEdges (FbBits *buf,
+ int bpp,
+ int width,
+ int stride,
+ RenderEdge *l,
+ RenderEdge *r,
+ xFixed t,
+ xFixed b);
+
/* fbpict.c */
CARD32
fbOver (CARD32 x, CARD32 y);
@@ -967,10 +1037,25 @@ fbComposite (CARD8 op,
CARD16 height);
/* fbtrap.c */
+
+void
+fbAddTraps (PicturePtr pPicture,
+ INT16 xOff,
+ INT16 yOff,
+ int ntrap,