THN logo

THN Solutions

Sub-pixel accuracy


SunFire offers high quality result when rasterize a polygon. SunFire uses analytical method to get the sub-pixel accuracy. The alpha value at each pixel has range from 0-255. Imagine that a pixel include 256 sub-pixel, a line of polygon splits it into 2 area, one in polygon and one out of polygon. SunFire get total sub-pixel that is covered as inside polygon as alpha for blending. So that, SunFire exact at the sub-pixel level.

Sub-pixel accurate rasterization
Figure 1:Sub-pixel accurate rasterization

Quality


This part explains why you should use SunFire in high quality enviroment. We will compare result of SunFire to GDI+.
Following image is epected polygon (this path includes many small pies drawn from center).
Testing polygon
Figure 2:Testing polygon

And, we get the result of GDI+ and SunFire as following images:

GDI aliased zoomed     GDI anti-aliased zoomed     SunFire anti-aliased zoomed
Figure 3: Result of GDI+ Aliased, GDI+ Anti-Aliased and SunFire

Let's compare results above:
  • Gdi aliased has the worst quality. It looks jaggy and ugly
  • Gdi anti-aliased has better quality. But look at the red rectangle, the gradient from black to white is not smooth. Some pixels have been approximated.
  • SunFire result is the smoothest. Colors from black to white (in red rectangle) change continuously. Each pixel has distinct alpha value.

As you see in above test, SunFire gives smoother and better image. But, you will expect SunFire’s result much better than GDI+ anti-aliased. Now, we will show you why you should choose SunFire:
GDI anti-aliased     SunFire
Figure 4: Compare GDI+ Anti-Aliased and SunFire

Performance


You will wonder why you should change current code using GDI+ by SunFire. In this section, we will give you the benchmark result of SunFire. To ensure your UI working smoothly, performance is the highest priority in SunFire. SunFire have been optimized for a good performance at the best quality.

Before reading the benchmark table, let’s view test paths were used (images have been scaled at ratio below each image):
Circle 2     complex 1     complex 2
(a)Scaled 50%     (b)Scaled 40%     (c)Scaled 100%
Complex 3 Lion
(d)Scaled 30% (d)Scaled 35%
Figure 5: Performance test paths

Test enviroment:
  • Windows Vista Ultimate (32-bit)
  • Duo 2 Core 6400 2.13GHz
  • Ram: 3.2GB
  • .NET framework 2.0
Test function will draw above test paths 1,000 times. Result time is measured in millisecond (ms).
Test case GDI+ Aliased (ms) GDI+ Anti-Aliased (ms) SunFire (ms) Compare to GDI+ Aliased (ms) Compare to GDI+ Anti-Aliased (ms)
Circle 1 (Figure 2) 880.29 4,626.21 2,258.11 -157% 105%
Circle 2 (Figure 5a) 2,480.77 27,793.90 8.553.14 -245% 225%
Complex data 1(Figure 5b) 673.57 1,668.29 1,870.59 -178% -12%
Complex data 2 (Figure 5c) 3,104.60 3,308.04 1,726.60 80% 92%
Complex data 3 (Figure 5d) 23,178.32 26,041.53 14,431.61 62% 82%
Lion (Figure 5e) 2,180.20 5,632.70 2,557.46 -17% 120%
Rectangle (1000px-800px) 2,954.86 7,954.58 1,796.56 64% 343%
Average (by time) 5,064.66 11,003.61 4,727.77 7% 133%
Average (by percent)       -56% 136%
Table 1:Rasterizer performance in Window Vista
Notes: two last columns are the improvement of SunFire to GDI+. Green text means that SunFire is faster than controller, and red text means that SunFire is slower than controller.

Performance chart
Chart 1: SunFire's performance chart

As above benchmark, SunFire’s performance is better than GDI+ Anti-Aliased. And Sunfire’s performance is considerable to GDI+ Aliased. But notes that, “circle 1” and “circle 2” test paths are not common. When you work with paths, almost paths are similar to “complex data 3”,”lion” and “rectangle”. In normal case, SunFire’s performance is better than GDI+.