1. Technical Field
The present invention relates generally to an improved data processing system, and in particular a method and apparatus for processing graphics data. Still more particularly, the present invention provides a method, apparatus, and computer instructions for storing color maps in a data processing system.
2. Description of Related Art
Computer graphics concerns the synthesis or display of real or imaginary objects from computer-based models. In computer graphics systems, images are displayed on a display device to a user in two dimensional and three dimensional forms. These images are displayed using pixels. A pixel is short for a picture element. One spot in a rectilinear grid of thousands of such spots that are individually “painted” to form an image produced on the screen by a computer or on paper by a printer. A pixel is the smallest element that display or print hardware and software can manipulate in creating letters, numbers, or graphics. These pixels and information relating to these pixels are stored in a buffer. The information describing a pixel is identified using a window ID (WID). A WID is used as an index into a window attribute table (WAT). The WAT contains information describing how a pixel will be displayed on the screen. For example, a WAT identifies depth, color map, buffer, and gamma for a pixel.
In displaying pixels, a color table, also referred to as a “color lookup table,” is a piece of hardware in which pixel values or colors may be stored. A color map is a list of colors used to display pixels in a window or application. This list of colors must be loaded into a color table to be used. Presently, color tables on a graphics adapter are defined as fixed size tables with the most common size being 256 entries. This size color table is one required to support a fully populated 8-bit color map.
The present invention recognizes that many applications create color maps and only populate the first few entries, leaving many unused color table entries. Typically, each application will use a single color table for its color map. Most adapters provide very few color tables, resulting in the sharing of entries within a color table by applications. Such a sharing of color tables results in technicolor, which causes a window to be displayed with the wrong color map values. In other words, a window may be displayed with the incorrect colors due to a sharing of the color table with multiple applications.
Thus, it would be advantageous to have an improved method, apparatus, and computer instructions for storing and managing colors in a color table.
The present invention provides a method, apparatus, and computer instructions for managing color maps in a data processing system. Responsive to a request to add a color map to a color table, a determination is made as to whether the color map is already installed in the color table. If the color map is not already installed in the color table, a decision is made as to whether a free block of color table entries sufficient to hold the color map is present in the color table. A determination is made as to whether existing blocks of color table entries in the color table can be rearranged to form a new free block of color table entries, if the free block of color table entries is insufficient to hold the color map. The existing blocks of color table entries in the color table are rearranged if the existing blocks of color table entries can be rearranged to form the new free block of color table entries. The color map is installed in the new free block of color table entries after the block of color table entries has been formed by rearranging the existing blocks of color table entries.
The novel features believed characteristic of the invention are set forth in the appended claims. The invention itself, however, as well as a preferred mode of use, further objectives and advantages thereof, will best be understood by reference to the following detailed description of an illustrative embodiment when read in conjunction with the accompanying drawings, wherein:
With reference now to the figures and in particular with reference to
With reference now to
Expansion bus interface 214 provides a connection for a keyboard and mouse adapter 220, modem 222, and additional memory 224. SCSI host bus adapter 212 provides a connection for hard disk drive 226, tape drive 228, and CD-ROM drive 230. Typical PCI local bus implementations will support three or four PCI expansion slots or add-in connectors.
An operating system runs on processor 202 and is used to coordinate and provide control of various components within data processing system 200 in FIG. 2. The operating system may be a commercially available operating system such as Windows XP, which is available from Microsoft Corporation. Instructions for the operating system and applications or programs are located on storage devices, such as hard disk drive 226, and may be loaded into main memory 204 for execution by processor 202.
Those of ordinary skill in the art will appreciate that the hardware in
For example, data processing system 200, if optionally configured as a network computer, may not include SCSI host bus adapter 212, hard disk drive 226, tape drive 228, and CD-ROM 230. In that case, the computer, to be properly called a client computer, must include some type of network communication interface, such as LAN adapter 210, modem 222, or the like. As another example, data processing system 200 may be a stand-alone system configured to be bootable without relying on some type of network communication interface, whether or not data processing system 200 comprises some type of network communication interface. As a further example, data processing system 200 may be a Personal Digital Assistant (PDA) device which is configured with ROM and/or flash ROM in order to provide non-volatile memory for storing operating system files and/or user-generated data.
The depicted example in FIG. 2 and above-described examples are not meant to imply architectural limitations. For example, data processing system 200 also may be a notebook computer or hand held computer in addition to taking the form of a PDA. Data processing system 200 also may be a kiosk or a Web appliance.
Turning next to
In this example, graphics adapter 300 includes an adapter memory 302 and a random access memory digital to analog converter (RAMDAC) 304. Adapter memory 302 contains window ID (WID) buffer 305, color frame buffer 306, and overlay frame buffer 308. RAMDAC 304 includes window attribute table (WAT) table 310 and dynamically sizeable color table 312, which includes color table registers 314 and color table 316. The two frame buffers, color frame buffer 306 and overlay frame buffer 308, contain pixels, which are sent to RAMDAC 304 for output to a display device, such as screen 318. RAMDAC 304 is a graphics controller chip that maintains the color palette and converts data from memory into analog signals for a display device. The color palette takes the form of color maps and is maintained within dynamically sizable color table 312.
In these examples, a dynamic color table is provided, dynamically sizeable color table 312, to facilitate a more efficient use of space within this color table. The mechanism of the present invention allows for dynamically changing the entries provided for color maps. The size and location of different sets of entries for different color maps are controlled through color table registers 314. Through the use of color table registers 314 and color table 316, a single color table may be employed to hold or contain multiple color maps in which the color maps are assigned only the space needed.
In this manner, problems, such as technicolor, may be avoided with limited numbers of color tables in a graphics adapter. For example, if a single color map uses only eight colors, only eight color table entries are needed instead of a full 256 entry color table. Previously, such a color map would require the use of the entire 256 color table because no mechanism was provided for dynamically sizing within the color table. With the present invention, the remaining entries in the color table are available for use by other color maps.
Additionally, the present invention also recognizes that with this ability to allocate different sizes of entries to color maps, the location of color maps and the amount of space in the color table, a result in inefficient color table usage if the allocation of color maps is not properly managed. A mechanism of the present invention includes an ability to manage and rearrange color maps to allow for efficient use of space within the color tables and to maximize the number of color maps that may be placed into the color table.
Turning next to
Application 400 and application 402 may generate requests to install color maps in graphics adapter 404 to display colors for windows. These requests are sent to Xserver 406 and are processed by install color map function 408 in Xserver 406. An Xserver is a graphics device driver that displays an application, such as application 400 or 402 on a display device. In this example, Xserver 406 processes requests from both local and remote applications. The results of this processing are displayed on a screen by this driver.
The requests are processed to identify the number of entries needed in a color table for each color map. In response to identifying the number of entries needed, install color map function 408 sets the appropriate registers within color table registers 410, which is located within RAMDAC 412 in graphics adapter 404. Based on the location and size set for the color map in color table registers 410, install color map function 408 then loads the colors into color table 414 in RAMDAC 412. Additionally, install color map function 408 also includes management processes for managing the space within color table 414.
For example, install color map function 408 may check to see if a color map is already installed in response to a request to install a color map in color table 414. This component also checks to see whether a large enough block of empty color table entries is present if the color map is not already installed. If a large enough block is present, the color block is loaded.
Otherwise, install color map function 408 may rearrange the color maps located within color table 414 so that sufficient entries within color table 414 are contiguous to each other. If install color map function 408 is unable to rearrange or defragment color table 414 to provide sufficient empty entries for the new color map, one or more color maps may be removed for the new color map.
In this manner, the mechanism of the present invention allows for multiple color maps of different sizes to be placed into color table 414 through dynamic sizing within color table 414, as well as managing the use of space within color table 414. As a result, color table 414 is in essence multiple color tables in which each of these color tables have sizes that are created to support different sized color maps.
With reference next to
Start registers 502 are used to identify the starting points for entries within color table 506. Size registers 504 are used to define the number of color table entries that will be dynamically allocated for a first color map. For example, start register 508 indicates that the starting address for a color map is at address 0, with a size of 2, as shown in register 510. This corresponds to section 512 within color table 506. Another color map is defined by registers 514 and 516. Register 514 indicates that the color map will start at address 2, while register 516 indicates that 206 entries are used for this color map. Section 518 in color table 506 is defined by these registers. Register 520 indicates a starting address of 513, while register 522 indicates that 254 entries are used for this third color map. These two registers define the third color map as being located within section 524 in color table 506. In another example, register 526 indicates that a fourth color map begins at address 767, while register 528 indicates that this color map contains 256 entries. These registers define section 530 in color table 506 for this fourth color map.
Turning now to
The process begins by receiving a request to install a color map (step 600). This request is typically received from an application or window manager and usually includes a number of entries required for the color map. The application or window manager passes in a color map identifier to the process. With this identifier, internal color map structures may be accessed to see how many colors the color map has, the actual colors, and if the colors are already loaded into the color table. Based on the requests received, a number of colors for the color maps is identified (step 602). A color map location and size is set based upon the number of colors identified (step 604). In these examples, the number of colors equals the number of entries needed in the color table. The location and size is set by setting registers within the graphics adapter. These are registers that are specifically designed for setting a location and size for a color map within a color table. Thereafter, the colors for the color map are loaded into the color table (step 606) with the process terminating thereafter.
Turning next to
With reference now to
The process begins by receiving a request to store colors into a color map (step 800). Thereafter, the process stores the colors (step 802), with the process terminating thereafter. In step 802, the last color stored in the color map also is saved in a last color field. For example, if the application requests color indices 0, 1, 2, and 10 to be stored in the color map, the last color field in the color map structure is set equal to 10. This field is later used to determine whether sufficient free space is present in the color table for this color map. If the last color field is equal to 10, then 11 free entries are needed in the color table. A color map structure is a software data structure that contains control data. This control data is used for managing the color map, including storing the colors into the color table. The color map structure itself resides in the Xserver and is not stored in the color table. Only the colors for the color map are actually stored in the color table.
The “last color” field indicates how many entries are required for the color map. For example, within an 8-bit color map, this map may contain up to 256 colors. If the application stores only 4 colors in the color map, such as red in index 0, blue in index 1, green in index 2, and yellow in index 10, then 11 free entries are needed in the color table for this color map. What is important is not the actual number of colors that are in the color map, but the last color index used, in this case 10. Index 10 requires 11 free entries because the data is 0 based; 0,1,2,3,4,5,6,7,8,9, and 10. Almost all applications allocate the colors starting at index 0 and work their way up, such that the number of colors and the last index used are almost always the same.
Turning now to
The process begins by receiving a request to install a color map (step 900). Thereafter, a determination is made as to whether the color map requested has already been installed (step 902). If the color map has already been installed, the process terminates, otherwise a determination is made as to whether a large enough block of empty color table entries are present to store the color map (step 904). If sufficient entries are present, a color map location and size registers are set (step 906). Thereafter, the colors for the color map are loaded into the color table (step 908), with the process terminating thereafter.
With reference again to step 904, if a block of empty color table entries is not sufficient to store the color map, the number of free entries in the color table are calculated (step 910). A determination is then made as to whether enough free entries are present to store the color map (step 912). If sufficient free entries are present in the color table, the currently stored color maps are rearranged to generate a block of contiguous entries sufficient to hold the new color map (step 914), with the process then proceeding to step 906 as described above.
Turning back to step 912, if insufficient free entries are present in the color table to store the color map, then one or more currently stored color maps are removed to make room for the new color map (step 916), with the process then proceeding to step 906. In step 916, various processes and algorithms may be used to determine which color map or color maps should be removed. For example, a color map may be removed to free up entries in the color table by selecting the color map to be removed as a color map that has been least recently used. Another mechanism involved may be identifying a color map to be removed as one that was first installed in the color table.
The last color field is used in steps 904, 912, 914, and 916, but not in 910. All of these steps need to know what number of entries are required.
In step 910, only the number of available entries are calculated. For step 910, the number of free entries is calculated by knowing the total number of entries available in the hardware and knowing the number of entries that are in use. The number of entries in use can be calculated by reading the start and size registers in the RAMDAC. Further, the number of consecutive free entries that are available are identified by reading the start and size registers. For example, looking back at
Thus, the present invention provides a method, apparatus, and computer instructions for managing color maps in a graphics adapter. The mechanism of the present invention allows for dynamic sizing within a color table to allow for multiple color maps to be placed within the color table. Each color map is allocated only with as much space as needed for a particular color map, rather than a set allocation. For example, if a color map only includes two colors, only two entries are allocated, while a color map having 256 colors is allocated 256 entries. This mechanism does not require any changes or modifications to applications requesting color maps. Instead, a set of registers are included within the graphics adapter in which these registers are used to set locations and sizes of color maps within a color table.
The mechanism of the present invention also allows for management of color maps within a color table. When a request to install a color map is received, a check is made to determine whether the color map has already been installed in the color table. If the color map has not already been installed, a determination is made as to whether a large enough block of empty color table entries is present to hold the color map. If a large enough block is present, the color map is loaded. Otherwise, color maps within the color table are rearranged to create contiguous empty slots. A determination is made as to whether these contiguous empty slots provide enough color table entries for the color map. If insufficient entries are still present, then one or more color maps may be removed to make room for the new color map. With this mechanism, improved efficiency in color table usage is provided, reducing the need to implement large numbers of expensive color tables. Further, this mechanism provides improved usability over current color tables, reducing the occurrence of technicolor.
It is important to note that while the present invention has been described in the context of a fully functioning data processing system, those of ordinary skill in the art will appreciate that the processes of the present invention are capable of being distributed in the form of a computer readable medium of instructions and a variety of forms and that the present invention applies equally regardless of the particular type of signal bearing media actually used to carry out the distribution. Examples of computer readable media include recordable-type media, such as a floppy disk, a hard disk drive, a RAM, CD-ROMs, DVD-ROMs, and transmission-type media, such as digital and analog communications links, wired or wireless communications links using transmission forms, such as, for example, radio frequency and light wave transmissions. The computer readable media may take the form of coded formats that are decoded for actual use in a particular data processing system.
The description of the present invention has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiment was chosen and described in order to best explain the principles of the invention, the practical application, and to enable others of ordinary skill in the art to understand the invention for various embodiments with various modifications as are suited to the particular use contemplated.
The present invention is related to the following applications entitled: “Method and Apparatus for Dynamically Sizing Color Tables,” Ser. No. 10/402,110; all filed even date hereof, assigned to the same assignee, and incorporated herein by reference.
Number | Name | Date | Kind |
---|---|---|---|
4847604 | Doyle | Jul 1989 | A |
5025249 | Seiler et al. | Jun 1991 | A |
5195403 | Sani et al. | Mar 1993 | A |
5218431 | Gleicher et al. | Jun 1993 | A |
5278678 | Harrington | Jan 1994 | A |
5406310 | Aschenbrenner et al. | Apr 1995 | A |
5430465 | Sabella et al. | Jul 1995 | A |
5459486 | Iverson et al. | Oct 1995 | A |
5629723 | West et al. | May 1997 | A |
5673065 | DeLeeuw | Sep 1997 | A |
5703627 | Young | Dec 1997 | A |
5748176 | Gondek | May 1998 | A |
5828779 | Maggioni | Oct 1998 | A |
5874967 | West et al. | Feb 1999 | A |
5990864 | DeAguiar et al. | Nov 1999 | A |
6011540 | Berlin et al. | Jan 2000 | A |
6038374 | Jacob et al. | Mar 2000 | A |
6326974 | Satoh et al. | Dec 2001 | B1 |
6466224 | Nagata et al. | Oct 2002 | B1 |
6518981 | Zhao et al. | Feb 2003 | B2 |
6573904 | Chun et al. | Jun 2003 | B1 |
20020044150 | Sato et al. | Apr 2002 | A1 |
Number | Date | Country | |
---|---|---|---|
20040189659 A1 | Sep 2004 | US |