A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.
1. Field
Embodiments relate to efficient line drawing on a video display. More particularly, embodiments relate to drawing anti-aliased lines in any direction using a single prerendered line texture.
2. Background
Conventional set top boxes display lines on a video display, such as a television screen by rendering the lines directly to a frame buffer using the CPU or by creating a large line texture that stores the entire length of the line. Rendering a line directly using the CPU diverts CPU processing from other tasks that it might otherwise perform.
Storing a large line texture can require significant amounts of scarce memory resources. For example, to store a texture required to render a line across an entire 1920×1080 high definition screen requires 2,073,600 bytes of memory. Four times that amount is required to store a full color rendering of the line. As a result, storage of large line textures can be wasteful of available memory resources.
Another issue is that drawing must be to the frame buffer as the frame buffer is what is displayed on the screen. However, such drawing typically requires pixel-by-pixel drawing to the frame buffer. This requires constantly moving memory between user-space memory and kernel-space memory, which can be very costly in terms of performance.
To overcome the aforementioned problems, a prerendered line texture stored in memory is used to generate an anti-aliased destination line in any direction to be displayed on a screen. A combination of tiling, stretching, and/or mirroring is used to generate the anti-aliased destination line. In one or more embodiments, a blitter blits a rectangle in the prerendered line texture to a destination rectangle in the frame buffer that is displayed on the screen.
In one or more embodiments, a system for rendering a line on a screen display includes a memory and a frame buffer to store data to be displayed on the screen display, a processor to create a prerendered line texture comprising a plurality of pixels to store in the memory, the processor to generate a source rectangle in the memory and a destination rectangle in a frame buffer that corresponds to at least a portion of a destination line, and a blitter to blit the prerendered line texture from the source rectangle in the memory to the destination rectangle in the frame buffer. In one or more embodiments, the destination line may be a destination diagonal line having a vertical component and a horizontal component, wherein the blitter stretches the prerendered line texture in a direction corresponding to the longer of the vertical and horizontal components and tiles the prerendered line texture in a direction corresponding to the shorter of the vertical and horizontal components.
In one or more embodiments, a method for rendering a line on a screen display includes storing a prerendered line texture having a plurality of pixels in a memory, generating a source rectangle in the memory, generating a destination rectangle in a frame buffer that corresponds to at least a portion of a destination line to be displayed on the screen display, and blitting the prerendered line texture from the source rectangle in the memory to the destination rectangle in the frame buffer. In some embodiments, the destination line may be a destination diagonal line having a vertical component and a horizontal component, and the method may further include stretching the prerendered line texture in a direction corresponding to the longer of the vertical and horizontal components and tiling the prerendered line texture in a direction corresponding to the shorter of the vertical and horizontal components.
Additional features and embodiments will be evident in view of the following detailed description.
a is a flowchart for generating a prerendered line texture in accordance with one or more embodiments.
b is a flowchart for determining pixel intensity in accordance with one or more embodiments.
a is an exemplary stretch blit of a vertical line using a single pixel line pixel width from a prerendered line texture.
b is an exemplary stretch blit of a horizontal line using a single pixel line pixel width from a prerendered line texture.
a illustrates creating a destination diagonal line from a prerendered line texture in accordance with one or more embodiments.
b illustrates creating a destination diagonal line in accordance with one or more embodiments.
Data sources 108 receive and/or generate video, audio, and/or audiovisual programming including, for example, television programming, movies, sporting events, news, music, pay-per-view programs, advertisement(s), game(s), etc. In the illustrated example, data sources 108 receive programming from, for example, television broadcasting networks, cable networks, advertisers, and/or other content distributors. Further, example data sources 108 may include a source of program guide data that is used to display an interactive program guide (e.g., a grid guide that informs users of particular programs available on particular channels at particular times and information associated therewith) to an audience. Users can manipulate the program guide (e.g., via a remote control) to, for example, select a highlighted program for viewing and/or to activate an interactive feature (e.g., a program information screen, a recording process, a future showing list, etc.) associated with an entry of the program guide. Further, example data sources 108 include a source of on-demand programming to facilitate an on-demand service.
An example head-end 116 includes a decoder 122 and compression system 123, a transport processing system (TPS) 103 and an uplink module 118. Decoder 122 decodes the information by, for example, converting the information into data streams. Compression system 123 compresses the bit streams into a format for transmission, for example, MPEG-2 or MPEG-4. In some cases, AC-3 audio is not decoded, but passed directly through without first decoding. In such cases, only the video portion of the source data is decoded.
In some embodiments, multiplexer 124 multiplexes the data streams generated by compression system 123 into a transport stream so that, for example, different channels are multiplexed into one transport. Further, in some cases a header is attached to each data packet within the packetized data stream to facilitate identification of the contents of the data packet. In other cases, the data may be received already transport packetized.
TPS 103 receives the multiplexed data from multiplexer 124 and prepares the same for submission to uplink module 118. TPS 103 includes a loudness data collector 119 to collect and store audio loudness data in audio provided by data sources 108, and provide the data to a TPS monitoring system in response to requests for the data. TPS 103 also includes a loudness data control module 121 to perform loudness control (e.g., audio automatic gain control (AGC)) on audio data received from data source 108. Generally, example metadata inserter 120 associates the content with certain information such as, for example, identifying information related to media content and/or instructions and/or parameters specifically dedicated to an operation of one or more audio loudness operations. For example, in an embodiment, metadata inserter 120 replaces scale factor data in the MPEG-1, layer II audio data header and dialnorm in the AC-3 audio data header in accordance with adjustments made by loudness data control module 121.
In the illustrated example, the data packet(s) are encrypted by an encrypter 126 using any suitable technique capable of protecting the data packet(s) from unauthorized entities.
Uplink module 118 prepares the data for transmission to satellite/relay 104. In an embodiment, uplink module 118 includes a modulator 128 and a converter 130. During operation, encrypted data packet(s) are conveyed to modulator 128, which modulates a carrier wave with the encoded information. The modulated carrier wave is conveyed to converter 130, which, in the illustrated example, is an uplink frequency converter that converts the modulated, encoded bit stream to a frequency band suitable for reception by satellite/relay 104. The modulated, encoded bit stream is then routed from uplink frequency converter 130 to an uplink antenna 132 where it is conveyed to satellite/relay 104.
Satellite/relay 104 receives the modulated, encoded bit stream from the transmission station 102 and broadcasts it downward toward an area on earth including receiver station 106. Example receiver station 106 is located at a subscriber premises 134 having a reception antenna 136 installed thereon that is coupled to a low-noise-block downconverter (LNB) 138. LNB 138 amplifies and, in some embodiments, downconverts the received bitstream. In the illustrated example of
Example set-top box 140 receives the signals originating at head-end 116 and includes a downlink module 142 to process the bitstream included in the received signals. Example downlink module 142 demodulates, decrypts, demultiplexes, decodes, and/or otherwise processes the bitstream such that the content (e.g., audiovisual content) represented by the bitstream can be presented on a display device of, for example, a media presentation system 144. Example media presentation system 144 includes a television 146, an AV receiver 148 coupled to a sound system 150, and one or more audio sources 152. As shown in
Further, in one or more embodiments, example set-top box 140 includes a recorder 154 capable of recording information on a storage device such as, for example, analog media (e.g., video tape), computer readable digital media (e.g., a hard disk drive, a digital versatile disc (DVD), a compact disc (CD), flash memory, etc.), and/or any other suitable storage device.
A processor 202 controls operation of STB 140. Processor 202 can be any processor that can be configured to perform the operations described herein for processor 202. Processor 202 has accessible to it a memory 204. As will be described in detail below, memory 204 is used to store a prerendered line texture. For example, in an embodiment, the prerendered line texture is a small segment of a line that will be tiled, stretched, and mirrored according to embodiments. Memory 204 can also be used as storage space for recorder 154 (described above). Further, memory 204 can be used to store programs to be run by processor 202 as well as used by processor 202 for other functions necessary for the operation of STB 140 as well as the functions described herein. In alternate embodiments, one or more additional memories may be implemented in STB 140 to perform one or more of the foregoing memory functions.
A blitter 206 performs block image transfer (BLIT or blit) operations. BLIT operations include stretch, tile, and mirror operations. In embodiments, blitter 206 performs BLIT operations on a prerendered line texture stored in memory 204 across a frame buffer 208. In an embodiment, blitter 206 is a co-processor that provides hardware accelerated anti-aliased line drawing. Blitter 206 renders destination lines using reduced memory resources and does not require direct access to the frame buffer. A suitable blitter for use in embodiments is the blitter found in the DIRECTV HR2x family of STBs.
Frame buffer 208 stores an image or partial image to be displayed on media presentation system 144. In an embodiment, frame buffer 208 is a part of memory 204. A compositor 214 receives data stored in frame buffer 208 and video surface 212. In an embodiment, compositor 214 blends the data it receives from frame buffer 208 with the data it receives from video surface 212 and forwards the blended video stream to media presentation 144 for presentation.
In an embodiment, the prerendered line is a small image that is drawn during an initialization process prior to operational use of STB 140 and stored in memory 204. In an embodiment, for example, processor 202 draws the small line segment and stores it in memory 204 prior to a user using STB 140 for entertainment purposes. In an embodiment, the prerendered line texture is 62×62 pixels. However, in practice, the prerendered line texture can be any size, the size being a tradeoff between memory usage and number of BLIT operations required to draw the destination line. In an embodiment, the texture is owned by the system and not modifiable by the user.
In an embodiment, the prerendered line texture is essentially an anti-aliased line at a 45 degree angle. Other angles can be used in alternate embodiments. In an embodiment, lines of different widths are provided by providing different prerendered line textures having different widths.
To save memory, in an embodiment, the texture contains only the alpha color of the pixel. As a result, each pixel requires only one byte to store color information. Not only is memory saved, but true anti-aliasing is performed over live video because color blending is performed by the STB graphic and composition hardware rather than processor 202.
In operation, blitter 208 loads the prerendered line texture into the memory space of the graphics driver, for example frame buffer 208 and performs BLIT operations on the prerendered line texture to render the destination line across the frame buffer 208. In an embodiment, for example, if the line is longer vertically than horizontally, the line is stretched vertically and tiled horizontally. Combining tiling and stretching in this manner allows creation of a smooth destination line of any length and angle. To render lines pointing in a different direction than the prerendered line, processor 202 mirrors the prerendered line texture so that blitter 208 will render the destination line in the correct direction.
The rendered lines can be used anywhere a line is required on a screen. For example, such lines may be used to provide a user interface on a screen, including, for example, boundaries around text, separators between text, grids, and any other lines required to create the user interface.
Black pixels in prerendered line texture 300 represent opaque pixels. Gray pixels in prerendered line texture 300 represent semi-transparent pixels. The semi-transparent pixels provide the anti-aliasing effect when the blitter renders the destination line over a background by rendering the destination line to the frame buffer. Prerendered line texture 300 has a line width of 1.5 pixels. Other widths can be used. In addition, there may be additional layer(s) of semi-transparent pixels with lines having greater widths.
In an embodiment, prerendered line textures of different widths can be provided by different textures. If the destination line is pointing in a different direction than the prerendered line texture, the destination line may be rendered using a mirroring operation that logically flips the prerendered line texture about its vertical axis at the center of the prerendered line texture so that it will cause rendering in the direction of the destination line. As an alternative, multiple line textures pointing in different directions may be stored.
a is a flowchart 400 for generating a prerendered texture, such as prerendered texture 300, according to an embodiment. In step 402, the number of pixels that occur in the texture before the center of the prerendered line is determined. In step 404, the texture is padded to provide room for pixels that occur left, right, up, or down from the center pixel. In step 406, the intensity of each pixel in the texture is determined. In an embodiment, pixel intensity ranges from 0 to 255. In an embodiment, the steps in flowchart 400 are performed by a processor such as processor 202.
b is a flowchart 410 for determining pixel intensity in step 406 according to an embodiment. In step 412, a determination is made as to whether the line width is greater than 1. If the line width is less than or equal to 1, processing continues in step 414, where a determination is made as to the pixel's distance from the line. If the distance is 0, processing continues in step 416, where intensity is determined as a function of line width. For example, in an embodiment, the intensity is determined as the ratio of the line width to 1. If the determined distance is not 0 in step 414, processing continues in step 418 where the pixel's intensity is set to 0.
If in step 412, the line width is determined to be greater than 1, processing continues in step 420 where a pixel value intensity is calculated for the pixel. In an embodiment, the pixel intensity calculation is based on the pixel's distance from the line. In an embodiment, the calculated value is used to set pixels further away from the line with lower intensity values.
Processing continues in step 422 where a determination is made as to whether the calculated intensity is greater than or equal to 1. If so, the pixel's intensity is set to 0xFF (hexadecimal representation of 255). If the intensity calculated in step 422 is less than one, processing continues in step 426 where a determination is made as to whether the intensity calculated in step 422 is less than 0. If so, processing continues in step 428 where the pixel's intensity is set to 0. If the intensity calculated in step 422 is greater than or equal to 0 as determined in step 426, processing continues in step 430 where the pixel's intensity is set to the ratio of the intensity calculated in step 422 over 1.
Pseudo code for generating a prerendered texture according to an embodiment is provided below in Listing 1. In the embodiment, the pseudocode uses fixed point math. For the example pseudo code, Texture_size, size of the texture, is 16 and Line_width, width of the line, is 1.5. The ‘fixed’ is fixed point number with a 16 bit shift value. i.e. 1=0x10000 and 1.5=0x18000. In an embodiment, this is done to accommodate floating point math using a fixed point processor. In an embodiment, a floating point processor can be used.
To render a line, that is to draw the line in the screen, the line texture is blitted in specific ways to create a destination line of the correct length and angle. To accomplish this, a combination of stretching, tiling, and/or mirroring is performed on the line texture by the blitter to transfer the line texture onto the screen to create a destination line having the desired characteristics in the desired direction. For destination diagonal lines, stretching controls the slope of the destination diagonal line to create lines of different angles. Tiling the stretched line prevents the line from losing its smooth edge or becoming blocky. In a preferred embodiment, if the destination diagonal line is longer vertically than horizontally, then the prerendered line texture is stretched vertically and tiled horizontally. If, on the other hand, the destination diagonal line is longer horizontally than vertically, the prerendered line texture is stretched horizontally and tiled vertically. This is done because stretching is a more efficient operation than tiling. Further, in an embodiment, because the pixels are being rendered in the alpha channel, the blitter automatically alpha blends the line with whatever is appearing on the screen behind the line.
The destination line is the line the user desires to be displayed on the screen. In an embodiment, the user specifies where the line is to appear on the screen by providing the coordinates of the line. In an embodiment, the coordinates are provided as a begin point and an end point in the screen (frame buffer) space. For example, a destination line may be defined by the start point (x1, y1) and the end point (x2, y2). In pixels, the horizontal component of the destination line is abs(x2-x1) and the vertical component is abs(y2−y1), where abs is the absolute value function. Where abs(x2−x1) is 0, the destination line is vertical. Where abs(y2−y1) is 0, the destination line is horizontal. Where neither abs(x2−x1) or abs(y2−y1) is 0, the destination line is diagonal and referred to herein as a destination diagonal line.
In an embodiment, purely horizontal or purely vertical lines are created by stretch blitting a single line pixel width slice of the prerendered line texture onto the screen the desired horizontal or vertical distance. In an embodiment, because the prerendered line texture has built-in anti-aliasing using the alpha component, the anti-aliased portion of the line needs to be blit as well.
a is an exemplary stretch blit 500 of a vertical line using a single pixel line pixel width from prerendered line texture 300. Pseudo code for rendering a horizontal line according to an embodiment is provided in Listing 2.
b is an exemplary stretch blit 510 of a horizontal line using a single pixel line pixel width from prerendered line texture 300. Pseudo code for rendering a vertical line according to an embodiment is provided in Listing 3.
In an embodiment, destination diagonal lines, that is lines having a non-zero horizontal component and a non-zero vertical component, are created by a combination of tiling, stretching, and, in some cases, mirroring the prerendered line texture. Because, in an embodiment, stretching is a more efficient operation than tiling, when creating a destination diagonal line, stretching is used for the longer component, and tiling is used for the shorter component. Thus, if the destination diagonal line to be created has a longer vertical component than horizontal component, the destination diagonal line is created by stretching the prerendered line texture vertically and tiling the stretched prerendered line texture horizontally. If, on the other hand, the destination diagonal line to be created has a longer horizontal component than vertical component, the destination diagonal line is created by stretching the prerendered texture horizontally and tiling the stretched prerendered line texture in the vertical direction.
a illustrates creating a destination diagonal line 702 from a prerendered line texture 704 according to an embodiment. Exemplary prerendered line texture 704 has dimensions of 8×8 pixels. In the example, of
Because, in the example illustrated in
b illustrates creating a destination diagonal line 710 according to another embodiment. In the embodiment of
In an embodiment, a destination diagonal line that is longer than the line of the prerendered line texture is generated using multiple blits of the prerendered line texture to destination rectangles in the frame buffer. For each blit, the coordinates of the destination rectangle in the frame buffer is changed to generate a smooth destination diagonal line. As described in more detail below, the size of the destination rectangles is determined as a function of the size of the prerendered line texture in pixels in the direction of the shorter component of the destination diagonal line and the number of blits required. When the destination diagonal line is shorter than the line of the prerendered line texture, in an embodiment, the prerendered line texture is only stretched to generate the destination diagonal line.
In step 808, a destination rectangle is determined. The destination rectangle is determined as having the additional pixels required to effectuate the stretching operation described above. In an embodiment, the blitter, such as blitter 206 performs the stretching described above as part of its functionality. As a result, the stretching need not be programmed independently. Thus, the destination rectangle in the example of
In step 812, coordinates for the next destination rectangle for the next blit (tile) are determined to make the destination line continuous. In step 814, the source rectangle, the line texture, is blitted to the destination rectangle defined by the new coordinates. In step 816, steps 812 and 814 are repeated for the number of blits (tiles).
For example, in the illustration in
Pseudocode for creating a destination diagonal line having a longer vertical component and in the same direction as the prerendered line texture as described in flow chart 800 according to an embodiment is provided in listing 4.
Pseudocode for creating a destination diagonal line having a longer horizontal component and in the same direction as the prerendered line texture as described in flow chart 800 according to an embodiment is provided in listing 5.
In an embodiment, lines can be drawn in any direction, not just the direction of the prerendered line texture. In one embodiment, this is handled by having two prerendered line textures, one in one direction, and one in the other direction. A determination is made as to the direction of the destination diagonal line, and the appropriate prerendered line texture is used depending on the direction of the destination line. This approach can be somewhat wasteful of scarce memory resources. As a result, a second approach using mirroring can be employed.
To avoid having to store two prerendered line textures, mirroring is used. In mirroring, the stored prerendered line texture is logically flipped about the vertical axis at its center so that the effective line is being drawn in the other direction.
Psuedo code for creating a destination diagonal line having a longer horizontal component and in the opposite direction from the prerendered line texture as described in flow chart 800 according to an embodiment is provided in listing 6.
Psuedo code for creating a destination diagonal line having a longer horizontal component and in the opposite direction from the prerendered line texture as described in flow chart 800 according to an embodiment is provided in listing 7.
Pseudocode for creating a destination diagonal line having a longer vertical component for a single blit rendering as described in flow chart 800 according to an embodiment is provided in listing 8.
Pseudocode for creating a destination diagonal line having a longer horizontal component for a single blit rendering as described in flow chart 800 according to an embodiment is provided in listing 9.
Pseudo code for a wrapper for invoking the above-described functions according to an embodiment is provided in listing 10.
In an embodiment, adjustments are made to handle boundary conditions depending upon whether a first blit, a last blit, or a middle blit is being processing for rendering a particular destination diagonal line. As a result first blits, last blits and middle blits may be handled somewhat differently. Such processing is described in listings 4-7.
In an embodiment, if the line the destination diagonal line is shorter than the prerendered line texture, no tiling is performed. In such a case, the line is stretched only to make the desired angle.
In an embodiment, additional memory savings is obtained by using only the alpha channel color for the pixels in the prerendered line texture. In an embodiment, the color provided for the alpha channel is a default color set for the alpha channel. Consequently, only one byte per pixel is required for color in the prerendered line texture. This also provides true anti-aliasing over live video as color blending is performed by native STB graphic and composition hardware rather than the CPU.
The foregoing disclosure of the preferred embodiments of the present invention has been presented for purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise forms disclosed. Many variations and modifications of the embodiments described herein will be apparent to one of ordinary skill in the art in light of the above disclosure. The scope of the invention is to be defined only by the claims appended hereto, and by their equivalents.
Further, in describing representative embodiments of the present invention, the specification may have presented the method and/or process of the present invention as a particular sequence of steps. However, to the extent that the method or process does not rely on the particular order of steps set forth herein, the method or process should not be limited to the particular sequence of steps described. As one of ordinary skill in the art would appreciate, other sequences of steps may be possible. Therefore, the particular order of the steps set forth in the specification should not be construed as limitations on the claims. In addition, the claims directed to the method and/or process of the present invention should not be limited to the performance of their steps in the order written, and one skilled in the art can readily appreciate that the sequences may be varied and still remain within the spirit and scope of the present invention.
Number | Date | Country | |
---|---|---|---|
Parent | 13294146 | Nov 2011 | US |
Child | 14812824 | US |