Systems and methods provide for non-multisampled anti-aliasing for clipping paths, in which a non-multisampled texture is employed to store anti-aliasing data. In some configurations, clipping paths applied to an input object are processed successively using a non-multi-sampled buffer and non-multisampled texture. Each clipping path is processed by incrementing a stencil buffer value for each pixel covered by the clipping path, computing clipping path coverage data, and storing the clipping path coverage data in the non-multisampled texture. An object is rendered by performing a stencil test and multiplying color values for retained pixels by corresponding texture values from the non-multisampled texture to provide anti-aliasing. Further configurations operate without a stencil buffer but employ a logical stack of non-multisampled textures, one for each clipping path.

BACKGROUND

Clipping paths are used by many image/vector editing applications to cut out objects from input objects (e.g., images, vectors, Bezier paths, gradients, patterns, etc.). When a clipping path is applied to an input object, any portion of the input object within the clipping path is included while any portion of the input object outside the clipping path is excluded (or vice versa). For instance, clipping paths can be used on an image of a product to remove the background surrounding the product and thereby provide an image of the product by itself.

Clipping paths can result in aliased renderings in which clipped objects have jagged edges. To address this issue, anti-aliasing is often used to smooth out the appearance of edges from clipping paths. Traditional GPU-based techniques used for anti-aliasing rely on multisample anti-aliasing (MSAA). MSAA uses a multisampled color buffer in conjunction with a multisampled stencil buffer to achieve the desired clipping effect. However, this approach has memory and performance implications making the technique inefficient in rendering complicated artwork. In particular, MSAA is dependent upon multisampling, which means that every pixel is treated as “N” subpixels (“N” being the multisampling factor). This effectively increases the storage requirement for the entire screen (and any associated textures/buffers like stencil and depth buffers) by “N” times. The pixels to be processed may also grow “N” times, which drastically decreases rendering performance. The problem is further complicated when an input object includes multiple clipping paths that must be processed. In some instances, the memory and performance issues from MSAA prevent some complicated artworks from being rendered (especially when the underlying color space is CMYK or N-Channel, which inherently need more memory than RGB).

SUMMARY

Embodiments of the present invention relate to, among other things, anti-aliased rendering of objects from clipping paths that does not rely on multisampling. By not using multisampling, techniques described herein reduce memory requirements and improve performance when compared to MSAA. In accordance with some configurations, anti-aliasing is achieved using a non-multisampled stencil buffer and non-multisampled texture. Clipping paths applied to an input object are processed successively. For each clipping path, a stencil value in the non-multisampled stencil buffer is incremented for pixels covered at least partially by the current clipping path. Additionally, a clipping path coverage value is computed for each pixel for the current clipping path based on an extent to which the clipping path covers each pixel. A texture value in the non-multisampled texture for each pixel is updated by multiplying the texture value for each pixel by the clipping path coverage value for each pixel for the current clipping path. When drawing an object, a stencil test is performed such that only pixels whose stencil value equals a count of the current clipping value are retained, and the color value for each retained pixel is multiplied by a corresponding texture value in the non-multisampled texture to thereby provide anti-aliasing. Further configurations provide anti-aliased rendering without use of a stencil buffer. In such configurations, a logical stack of non-multisampled textures is used to store anti-aliasing data.

DETAILED DESCRIPTION

Embodiments of the present invention address the technical challenge of anti-aliased rendering of clipping paths by providing an approach that does not rely on multisampling. As used herein, a “clipping path” is a closed shape or path used to cut out an object from an input object, such as a path drawn around a portion of an image to thereby cut out that portion from the image. As used herein, “objects refer to images, vectors, Bezier paths, gradients, patterns, or other mechanisms used to generate a rendering for display. Because multisampling is not employed, the techniques described herein consume much less memory and provide improved performance when compared with MSAA. Generally, some configurations herein provide anti-aliased rendering of multiple clipping paths on an input object by using a non-multisampled frame buffer with a non-multisampled stencil buffer for storing depth of clipping path nesting and a non-multisampled texture for storing anti-aliasing values for pixels. As used herein, a “frame buffer” refers to a portion of memory (e.g., on a graphics processing unit (GPU)) that stores pixel data used for rendering an image on a display device. A “stencil buffer” refers to a portion of memory that stores data on a per-pixel basis to limit the area of rendering. For instance, based on stencil buffer values, some pixels are rendered while other pixels are not rendered. A “texture” refers to a portion of memory used to store image data on a per-pixel basis using a single image format. The frame buffer, stencil buffer, and texture are non-multisampled in that each pixel is treated as a single unit and not divided into subpixels.

More particularly, to process clipping paths for an input object, some embodiments create a non-multisampled frame buffer with a non-multisampled stencil buffer and non-multisampled texture by allocating a portion of memory for each. The clipping paths are successively processed with each clipping path being processed as follows. The non-multisampled texture is set as the output color attachment for the non-multisampled frame buffer such that pixel values derived from rendering the current clipping path are written to the non-multisampled texture. The rendering includes incrementing a stencil buffer value in the non-multisampled stencil buffer for each pixel of the input object covered at least partially by the current clipping path. Additionally, a clipping path coverage value is computed for each pixel, and a texture value in the non-multisampled texture for each pixel is updated by multiplying the texture value for each pixel by the clipping path coverage value determined for each respective pixel. This provides an anti-aliasing value for each pixel for the current clipping path and each previously processed clipping path. Objects are drawn by restoring the color buffer as the output color attachment for the non-multisampled frame buffer, discarding pixels whose stencil value does not equal the count of the current clipping path, and drawing remaining pixels by multiplying each remaining pixel's color value by a corresponding texture value in the non-multisampled texture. As used herein, a “color buffer” refers to a portion of memory used to store a color value on a per-pixel basis. A “color value” corresponds with data used to control the color of a pixel on a display screen when outputting a displayed rendering of an object.

Further configurations described herein provide another technique for rendering anti-aliased clipping paths that does not rely on multisampling and also does not use a stencil buffer. Generally, such embodiments use a logical stack of textures, one for each level of nested clipping path, to store anti-aliasing values for each level of clipping path. More particularly, the clipping paths are successively processed with each clipping path processed as follows. A non-multisampled texture is set as a current texture for the current clipping path, and the current texture is set as the output color attachment for a non-multisampled frame buffer. The current clipping path is rendered to the current texture, which includes determining a clipping path coverage value for each pixel and writing that value to the current texture. The clipping path coverage values from the current texture for each pixel are multiplied by texture values in a previous texture used to store clipping path coverage values for pixels from previously processed clipping paths. The resulting texture values are then stored in the current texture. This provides an anti-aliasing value for each pixel for the current clipping path and each previously processed clipping path. It should be understood that there are various permutations of textures and other memory buffers that can be used in accordance with embodiments of the present invention. Objects are drawn by restoring the color buffer as the output color attachment for the non-multisampled frame buffer, and drawing pixels by multiplying each pixel's color value by a corresponding texture value in the current texture.

The system100is an example of a suitable architecture for implementing certain aspects of the present disclosure. Among other components, the system100includes an image/vector processing engine104that processes clipping paths applied to input object102to provide a clipped object106. As shown inFIG. 1, the image/vector processing engine104employs a frame buffer108with a stencil buffer110, texture112, and color buffer114in rendering the clipped object106from the input object102. The frame buffer108, stencil buffer110, texture112, and color buffer114are non-multisampled, such that each pixel is treated as a single unit and not divided into subpixels. Although not shown inFIG. 1, it should be understood that the frame buffer108may include additional components (e.g., a depth buffer).

The image/vector processing engine104successively processes each of a number of clipping paths applied to the input object102, for instance, using the method200described below with reference toFIG. 2. For a given clipping path, the image/vector processing engine104sets the texture112as the output color attachment for the frame buffer108. This allows for anti-aliasing data to be written to the texture112. In particular, the image/vector processing engine104tessellates the current clipping path into triangles, and the triangles are written to the frame buffer108. As known in the art, tessellating decomposes an area of an object by dividing into it into a set of triangles suitable for rendering. A current stencil value in the stencil buffer110is incremented for each pixel at least partially covered by the triangles. Additionally, a clipping path coverage value is computed for each pixel based on the extent to which the triangles cover each pixel, and a current texture value in the texture112is multiplied by the clipping path coverage value for each pixel. The current texture value in the texture112for each pixel can be a value of one when the initial clipping path is being processed or can be a value resulting from the multiplication of clipping path coverage values from previously-processed clipping paths when a subsequent clipping path is being processed. The clipping path coverage value can be computed using any of a variety of known techniques. For instance, the clipping path coverage value for a pixel can be computed using the technique described in Loop, C., and Blinn, J., 2005, Resolution Independent Curve Rendering using Programmable Graphics Hardware, ACM Transactions on Graphics (TOG)—Proceedings of ACM SIGGRAPH 2005, Volume 24 Issue 3, July 2005, Pages 1000-1009 (available online at http://research.microsoft.com/en-us/um/people/cloop/LoopBlinn05.pdf). It should be understood that other known approaches for computing clipping path coverage are available and can be used within embodiments of the present invention.

Objects at the level of the current clipping path (i.e., objects under the current clipping path in conjunction with any previous clipping paths) are drawn by returning the color buffer114as the output color attachment for the frame buffer108. A stencil test is used to identify pixels covered by each of the clipping paths processed at the current level. In particular, pixels with a stencil buffer value equal to the count of the current clipping path are retained. For instance, if the current clipping path is the third clipping path processed, only pixels whose stencil buffer value is equal to three are retained as selected pixels. This captures pixels that are covered by all three clipping paths. To draw the objects, the color value for each selected pixel passing the stencil test is multiplied by a respective texture value in the texture112for each pixel. This multiplication provides the desired anti-aliasing effect. The resulting values are written to the color buffer114, and a clipped object106is output for display.

With reference now toFIG. 2, a flow diagram is provided illustrating a method200for providing anti-aliased rendering for a group of clipping paths without multisampling. Each block of the method200and any other methods described herein comprises a computing process performed using any combination of hardware, firmware, and/or software. For instance, various functions can be carried out by a processor executing instructions stored in memory. The methods can also be embodied as computer-usable instructions stored on computer storage media. The methods can be provided by a standalone application, a service or hosted service (standalone or in combination with another hosted service), or a plug-in to another product, to name a few. The method200may be performed at least in part, for instance, by the image/vector processing engine104ofFIG. 1.

As shown at block202, a non-multisampled frame buffer, a non-multisampled stencil buffer, and a non-multisampled texture are created. The non-multisampled texture could be in GL_R16F format, for instance, with every pixel in the texture taking two bytes. The non-multisampled stencil buffer includes a stencil value for each pixel, and the non-multisampled texture includes a texture value for each pixel. As shown at block204, the stencil values in the non-multisampled stencil buffer are initialized with zeroes. Additionally, the texture values in the non-multisampled texture are initialized with ones. In other configurations, this initialization can be optimized away. For instance, as discussed below, if the non-multisampled texture is not initialized with all ones, a first pass replaces texture values in the non-multisampled texture as opposed to using a multiplication function.

An initial clipping path is selected and set as a current clipping path for processing, as shown at block206. The non-multisampled texture is set as the output color attachment for the non-multisampled frame buffer, as shown at block208. This allows for anti-aliasing data to be written to the non-multisampled texture (a color buffer is not needed at this time, so the non-multisampled texture is temporarily put in place of the color buffer). The current clipping path is tessellated into triangles, and the triangles are written to the non-multisampled frame buffer, as shown at block210. A current stencil value in the non-multisampled stencil buffer is incremented by one for each pixel covered at least partially by an area defined by the current clipping path, as shown at block212. Additionally, a clipping path coverage value is determined for each pixel for the current clipping path, as shown at block214. The clipping path coverage value for a given pixel represents an extent to which the clipping path covers the given pixel. As noted previously, the clipping path coverage value can be computed using any of a variety of known techniques.

As shown at block216, a current texture value in the non-multisampled texture for each pixel is multiplied by the clipping path coverage value determined for each respective pixel. In some embodiments, if the current clipping path being processed is the initial clipping path and if the texture was not initialized to all ones at block204, the current texture value in the non-multisampled texture for each pixel is overwritten with the clipping path coverage value determined for each respective pixel as opposed to using a multiplication function. This works because all subsequent/nested clipping paths are installed only at those pixels where stencil test passes.

Objects at the level of the current clipping path (i.e., objects under the current clipping path in conjunction with any previous clipping paths) are drawn at block218. In some configurations, the objects are drawn using the method300shown inFIG. 3. The process includes returning the color buffer as the output color attachment for the non-multisampled frame buffer, as shown at block302. A stencil test is performed to retain selected pixels whose stencil buffer value is equal to the count of the current clipping path, as shown at block304. To draw the objects, the color value for each selected pixel passing the stencil test is multiplied by a respective texture value in the non-multisampled texture for each pixel, as shown at block306. This multiplication provides the desired anti-aliasing effect.

Returning toFIG. 2, a determination is made at block220regarding whether the current clipping path is the last clipping path. If it is determined that the current clipping path is not the last clipping path, a next clipping path is selected and processed using the approach of blocks206through218as shown by the return to block206. Alternatively, if it is determined that the current clipping path is the last clipping path, the process ends, as shown at block222.

The above process of drawing objects for clipping paths using the non-multisampled frame buffer, non-multisampled stencil buffer, and non-multisampled texture can be performed using the OpenGL calls provided below. While OpenGL calls are provided herein, it should be understood that the calls are provided by way of example only and not limitation. Any of a variety of alternatives to OpenGL can be employed to implement embodiments of the present invention (e.g., DirectX, Mantle, Vulkan, Metal, etc.).

Run OpenGL shader to install clip path ‘i’

Turning now toFIG. 4, a flow diagram is provided that illustrates a method for uninstalling clipping paths. As shown at block402, the last/previous clipping path processed when installing the clipping paths is selected. When the process begins, the last clipping path is selected, while subsequent loops process previous clipping paths until the first clipping path is processed. As shown at block404, the non-multisampled texture is set as the output color attachment for the non-multisampled frame buffer.

The current clipping path is tessellated into triangles, and the triangles are written to the non-multisampled frame buffer, as shown at block406. A current stencil value in the non-multisampled stencil buffer is decremented by one for each pixel covered at least partially by an area defined by the current clipping path, as shown at block408. Additionally, a clipping path coverage value is determined for each pixel for the current clipping path, as shown at block410. As noted above, the clipping path coverage value for a given pixel can be computed using any of a variety of known techniques.

As shown at block412, a current texture value in the non-multisampled texture for each pixel is divided by the clipping path coverage value determined for each respective pixel. The division can be obtained, for instance, by computing the reciprocal of the clipping path coverage value in a fragment shader and multiplying the current texture value in the non-multisampled texture with the reciprocal (e.g., the glBlendFunc call in OpenGL can perform this multiplication using blend hardware).

A determination is made at block414regarding whether the current clipping path is the first clipping path originally installed. If it is determined that the current clipping path is not the first clipping path, a previous clipping path is selected and processed using the approach of blocks402through412, as shown by the return to block402. Alternatively, if it is determined that the current clipping path is the first clipping path, the process ends, as shown at block416.

As previously noted, further embodiments are directed to processing clipping paths without relying on multisampling and without use of a stencil buffer.FIG. 5illustrates a system500for rendering clipped objects in accordance with such embodiments. Among other components not shown, the system500includes an image/vector processing engine504that processes clipping paths applied to input object502to provide a clipped object506. As shown inFIG. 5, the image/vector processing engine504employs a frame buffer508with multiple textures510,512and a color buffer514in rendering the clipped object506from the input object502. The frame buffer508, textures510,512, and color buffer514are non-multisampled, such that each pixel is treated as a single unit and not divided into subpixels. Although not shown inFIG. 5, it should be understood that the frame buffer508may include additional components (e.g., a depth buffer).

The image/vector processing engine504successively processes each of a number of clipping paths applied to the input object502, for instance, using the method600described below with reference toFIG. 6. For a given clipping path, the image/vector processing engine504sets a current texture510as the output color attachment for the frame buffer508. The image/vector processing engine504renders the current clipping path by tessellating the clipping path into triangles and writing the triangles to the frame buffer508. A clipping path coverage value is determined for each pixel for the current clipping path and written to the current texture510. As noted previously, the clipping path coverage value for a given pixel represents an extent to which the triangles cover the pixel and can be computed using any of a variety of known techniques.

If the current clipping path is not the first clipping path, the texture value for each pixel in the current texture510is multiplied by a texture value for each pixel in the previous texture512. The previous texture512stores path coverage data computed for each previously processed clipping path. The resulting value from the multiplication is stored in the current texture510. As such, the current texture includes anti-aliasing data for each pixel based on all clipping paths that have been processed at the current level. When a subsequent clipping path is processed, the current texture510is set as the previous texture512, and a new texture is used as the current texture for that clipping path.

Objects at the level of the current clipping path (i.e., objects under the current clipping path in conjunction with any previous clipping paths) are drawn by returning the color buffer514as the output color attachment for the frame buffer508. To draw the objects, the color value for each pixel is multiplied by a respective texture value in the current texture512for each pixel. This multiplication provides the desired anti-aliasing effect. The resulting values are written to the color buffer514, and a clipped object506is output for display.

Turning now toFIG. 6, a flow diagram is provided that illustrates a method600for providing anti-aliased rendering for a group of clipping paths without multisampling and without use of a stencil buffer. As shown at block602, a non-multisampled frame buffer is created. A clipping path is selected as the current clipping path, as shown at block604. Additionally, a non-multisampled texture is created and set as the current texture, as shown at block606. In some configurations, the texture values of the current texture are initialized with zeroes, as shown at block608. The current clipping path is rendered into the current texture. In some configurations, this is done by initially setting the current texture as the output color attachment for the non-multisampled frame buffer, as shown at block610. The current clipping path is tessellated into triangles, and the triangles are written to the non-multisampled frame buffer, as shown at block612. A clipping path coverage value is determined for each pixel for the current clipping path, as shown at block614. As noted above, the clipping path coverage value for a given pixel can be computed using any of a variety of known techniques. The clipping path value for each pixel is stored in the current texture, as shown at block616.

If the current clipping path is not the first clipping path, the texture value for each pixel in the current texture is multiplied by a texture value for each pixel in the previous texture, and the resulting value is stored in the current texture, as shown at block618. The previous texture stores texture values computed from previously processed clipping paths. One way of achieving this multiplication is using a blend function as glBlendFunc(GL_ZERO, GL_SRC_ALPHA).

Objects at the level of the current clipping path are drawn at block620. In some configurations, this includes returning the color buffer as the output color attachment for the non-multisampled frame buffer. To draw the objects, the color value for each pixel is multiplied by a respective texture value in the current texture for each pixel. This multiplication provides the desired anti-aliasing effect. After artwork is drawn, textures can be deleted or recycled.

A determination is made at block622regarding whether the current clipping path is the last clipping path. If it is determined that the current clipping path is not the last clipping path, a next clipping path is selected and processed using the approach of blocks604through620as shown by the return to block606. Alternatively, if it is determined that the current clipping path is the last clipping path, the process ends, as shown at block624.

Memory712includes computer storage media in the form of volatile and/or nonvolatile memory. The memory may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard drives, optical-disc drives, etc. Computing device700includes one or more processors that read data from various entities such as memory712or I/O components720. Presentation component(s)716present data indications to a user or other device. Exemplary presentation components include a display device, speaker, printing component, vibrating component, etc.

As described above, implementations of the present disclosure relate to anti-aliased rendering of clipping paths without relying on multisampling. The present invention has been described in relation to particular embodiments, which are intended in all respects to be illustrative rather than restrictive. Alternative embodiments will become apparent to those of ordinary skill in the art to which the present invention pertains without departing from its scope.