Scaled Window Support in DMX : Possible Solutions
Previous: Previous Work
Next: Conclusion and Recommendations

3. Possible Solutions

This section briefly discusses possible solutions, including major advantages and disadvantages from both the implementation and the end-user programmer standpoint.

3.1. VNC-like Scaling

3.1.1. Software Scaling

The vncviewer application could be modified to provide software scaling. This is not a general solution, but it does solve one of the goals of this work.

A prototype of this solution was implemented and a patch against vnc-3.3.7-unixsrc is available in the dmx/external directory. Because of limited time available for this work, all of the edge cases were not considered and the solution works well mainly for integer scaling.

Currently, vncviewer writes to the X display with XPutImage, XCopyArea, and XFillRectangle. All instances of these calls have to be aware of scaling and must round correctly. In the prototype solution, rounding is incorrect and can cause artifacts.

A better solution would be to cache all updates to the desktop image in vncviewer and only send the damaged area to the X display with XPutImage. This would allow the damaged area to be computed so that rounding errors do not create artifacts. This method is probably similar to what is used in the Window client. (The whole VNC suite is being re-written in C++ and the forthcoming version 4 has not been evaluated.)

3.1.2. Scaling with the X Video Extension

The scaling in the Windows vncviewer application makes use of a scaled blit that is supplied by the underlying system library. Several video cards currently provide support for a scaled blit, and some X servers (including XFree86) expose this capability to applications via the XvPutImage interface of the X Video Extension. The capability exposed by XvPutImage results in the scaled image being drawn to an overlay plane. Most video cards also provide support for a scaled blit into the normal output planes, but this is not exposed via XvPutImage.

The vncviewer program could be modified to use the X Video Extension to provide scaling under X11 that is similar to the scaling currently provided under Windows. Unfortunately, Xdmx does not currently export the X Video Extension, so this would not provide an immediate solution usable with DMX.

A very early-stage proof-of-concept prototype was implemented and a preliminary patch against vnc-3.3.7-unixsrc is available in the dmx/external directory. This prototype was implemented to better understand the problems that must be solved to make this solution viable:

3.1.2.1. Implementing the X Video Extension for DMX

The user-level API for X Video is fairly simple, but the underlying support required for the full specification is large. However, since the API provides a method to query supported capabilities, a usable subset of X Video can be implemented that would support XvPutImage and little else. This would require support for the following:

3.1.2.2. Supporting RGB formats for the X Video Extension

Assuming an XFree86 driver already supports the X Video Extension, and assuming the target hardware supports an RGB format, then adding support for that format is relatively simple and straightforward.

3.1.3. Scaling with an XPutImageScaled Extension

Instead of (or in addition to) implementing the X Video Extension in DMX, one obvious solution would be to implement a new extension that provides access to hardware-assisted scaled blits, similar to the StretchBlt call available under Windows. This call would scale RGB images and would not use the overlay plane (unlike the X Video Extension).

This approach has many of the same advantages and disadvantages as the XCopyAreaScaled Extension, discussed in the next section. Discussion of XPutImageScaled is deferred in favor of XCopyAreaScaled for the following reasons:

3.1.4. Scaling with an XCopyAreaScaled Extension

As noted in the previous section, because XCopyAreaScaled provides a superset of the functionality provided by XPutImageScaled, we will consider this extension instead.

First, XCopyAreaScaled would provide for RGB scaling between pixmaps (i.e., on-screen or off-screen areas of memory that reside on the video card). Unlike the X Video Extension, which writes into an overlay plane, XCopyAreaScaled would write into the non-overlay areas of the screen. Key points to consider are as follows:

3.1.5. Scaling with OpenGL

Another general solution to the scaling problem is to use the texture scaling found in all 3D hardware. This ability is already exposed through OpenGL and can be exploited by clients without X server modification (i.e., other than the ability to support OpenGL). An application using OpenGL would transmit the non-scaled image to the X server as a texture, and would then display a single non-transformed rect using that texture. This also works around the single overlay problem with the X Video Extension as well as the need to implement additional scaled primitive extensions.

The downside is that most OpenGL implementations require power of 2 texture sizes and this can be very wasteful of memory if, for example, the application needs to scale a 1025x1025 image, which would require a 2048x2048 texture area (even a 640x480 image would require a 1024x512 texture). Another downside is that some OpenGL implementations have a limited about of texture memory and cannot handle textures that are very large. For example, they might limit the texture size to 1024x1024.

3.2. Application-transparent Scaling for DMX

3.2.1. Back-end Scaling Without Disconnect/Reconnect

VNC does scaling on the client side (in the vncviewer application). Implementing a similar solution for DMX would require support in the back-end X servers and, therefore, is not a general solution.

XFree86 already implements some support for "scaling" that could be used with DMX: if, in the XF86Config file, multiple Modes are listed in the Display Subsection of the Screen Section, then pressing Ctrl-Alt-Plus and Ctrl-Alt-Minus can be used to iterate through the listed modes. The display dimensions will change to the dimensions in the Modes line, but the logical dimensions of the X server (i.e., the dimensions that Xdmx knows about) will not change.

Further, the dimensions of the XFree86 display are under software control (via the XFree86-VidModeExtension), so the Xdmx server could change the screen dimensions on a per-display basis, thereby scaling the information on part of that display.

However, this scaling appears to have limited use. For example, assume a 4 by 4 display wall consisting of 16 1280x1024 displays. If all of the back-end servers were simultaneously configured to display 640x480, the left hand corner of each display would be magnified, but the composite result would be unreadable. Magnifying one display at a time could be usable, but could have limited utility, since the result would still be no larger than a single display.

3.2.2. Back-end Scaling With Disconnect/Reconnect

Disconnect and reconnect features are not currently supported in DMX, but are scheduled to be implemented in the future. These features, combined with the XFree86-VidModeExtension Extension, would allow an application to do the following:

For example, consider a display wall consisting of 16 1280x1024 displays with a total resolution of 5120x4096. All of the screens could be disconnected, repositioned, and reconnected each at a resolution of 640x480. The total resolution of the display wall would be 2560x1920, allowing a view of a selected area approximately one-fourth of the size of the DMX display. This change would be completely application independent (except, perhaps, for a DMX-aware window manager). When work at the increased resolution was completed, the back-end servers could be disconnected, reconfigured, and reconnected for the original 5120x4096 view.

Support for this type of scaling can be implemented in a DMX-aware X11 client assuming the DMX server support arbitrary disconnect and reconnect semantics. Because this application cannot be written before disconnect/reconnect is implemented, this solution will not be discussed further in this paper.

3.2.3. Server-side Scaling

In earlier versions of DMX, a frame buffer was maintained on the server side, and XPutImage was used to move the information from the server to the client (similar to some early VNC implementations). The use of a server-side frame buffer would allow the server to do scaling, but is not a recommended solution because of overall performance issues and server-side memory issues (i.e., the frame buffer would be very large for large display walls).

Exploration of this path is not recommended.

3.3. XCreateScaledWindow API

The implementation of X Video Extension in DMX, and the use of XvPutImage by applications requiring scaling requires significant changes in DMX Further, XvPutImage is, essentially a scaled blit, and it is only useful for applications which are already using (or can be modified to use) XPutImage. Therefore, a more general API will be discussed as another possibility.

X applications typically create windows with the XCreateWindow call. A new extension could provide an XCreateScaledWindow call that could be used in place of the XCreateWindow call and be otherwise transparent to the application. This would allow applications, even those that do not depend on XPutImage, to take advantage of window scaling. In this section we describe how the call would work, what transparency it provides, and how to solve the potential problems that transparency creates.

3.3.1. XCreateWindow

The XCreateWindow call takes width and height as parameters. An XCreateScaledWindow call could take all the same parameters, with the addition of a scaling factor.

3.3.2. XSetWindowAttributes

An X11 window has several attributes that would have to be scaled:

3.3.3. XGetWindowAttributes, XGetGeometry

For transparency, calls that query the window attributes should return unscaled information. This suggests that all unscaled pixmaps and window attributes should be cached.

Unfortunately, a window manager requires the scaled geometry to properly decorate the window. The X server can probably determine which client is acting as the window manager (e.g., because that client will select events that are used exclusively by the window manager). However, other Scaled Window Extension aware clients may also need to determine the scaled geometry. Therefore, at least two additional extension calls should be implemented: XGetScaledWindowAttributes and XGetScaledGeometry.

3.3.4. Popup and Child window positions

Some applications may position popup and child windows based on an unscaled notion of the main window geometry. In this case, additional modifications to the client would be required.

3.3.5. Events

Most events (e.g., for mouse motion) return information about the coordinates at which the even occurred. These coordinates would have to be modified so that unscaled values were presented to the client.

3.3.6. Implementation

There are many implementation issues, some of which are similar to the issues involved in implementing the X Video Extension for DMX. The window contents must be scaled, either by performing all operations to a frame buffer and then writing the image to the display (perhaps using hardware scaling support), or by modifying all of the various drawing operations to perform scaling. Because of the complexity involved, the frame buffer option is recommended.


Scaled Window Support in DMX : Possible Solutions
Previous: Previous Work
Next: Conclusion and Recommendations