A brief comment on Adobe's flashplayer rendering algorithm

Source: Internet
Author: User
Tags polyline
Some time ago to see CSDN on an article about Flashplayer rendering performance is a few times the HTML 5 of the article, recalling the recent years of Adobe's Flashplayer research, want to theoretically explore why there is such a result, Also explain why Adobe's Flashplayer will be criticized for traditional hardware acceleration (non-GPU scenarios);
Earlier in an IC design company for a low-end platform (with hardware 3D acceleration) as the official Flashplayer hardware acceleration, a few months down, the hardware rendering engine is done, but the final result is very surprising-----the performance of using hardware acceleration is actually worse than software rendering In order to explain the reasons, we should start with the principle of Adobe's Flashplayer software rendering algorithm.
In fact, the Flashplayer 2D rendering engine uses the most common scanning line algorithm (Scanline algorithm), and simply speaking, is a virtual display device (for the case of antialiasing, the virtual display device is larger than the actual display device, such as 4 x 4 anti-aliasing, The virtual display device is 4 times times the portrait of the actual display device, and each scan line calculates the intersection point of each edge (edge) of the vector graph and fills the horizontal line between the two intersections according to the different filling laws, so that as the scan line is calculated from top to bottom, a complete graphic is completed in the virtual display device and , and then, according to the hyper-sampling algorithm, the graphics on the virtual display device are output to the actual display device, so that a perfect non-sawtooth image is obtained on the actual display device, and the above actions are repeated at a certain rate, and the continuous animation can be obtained; Flashplayer by parsing the streaming SWF file, and follow the specified speed Update screen to complete the animation playback, so we have some simple conclusion:
The L-vector operation is a vast calculation of the project, which also explains why Flashplayer has a performance problem on most platforms; Unfortunately, the current real-time 2D vector graphics playback software seems to be only flashplayer, so the blame is no way;
L WHY the high-quality display performance of the lower picture quality is much worse, because in high-quality, Flashplayer is the use of 4 x 4 ultra-sample anti-aliasing, and that the calculation of the intersection by the scanning line calculation is 4 times times the low picture quality;
(For 2D vector graphics display, refer to my previous resources: http://download.csdn.net/source/5773340)
In the actual 2D vector engine, the problem is often more complex, after considering the Cap and join, the actual even a very simple polyline or Bezier curve is composed of a lot of curves (two endpoints of the polyline----CAP):

It's understandable why so far there are few real-time 2D vector displays that can compete with Adobe Flashplayer, which is a paradox: Why would Adobe's Flashplayer be a solo show? The above is only about the 2D vector graphics display of the principle of interpretation, other 2D vector display engine, such as OPENVG (GINGKOVG), agg, etc. using the same principle, Adobe's flashplayer relatively universal 2D vector display engine must have his own special definition, Reading Adobe's official technical document on Flashplayer (SWF_FILE_FORMAT_SPEC_V10), we soon found two interesting explanations:
L Flashplayer supports only 2-order Bezier curves (quadratic Bezier), and does not support 3-order Bezier curves (Cubic Bézier) used in traditional 2D vector engines like PostScript and OPENVG;


Relative to the 2-order Beizer curve, the 3-order Bezier curve alone in the calculation of the intersection point is an increase in the computational volume does not seem large: more than a few multiplication operations, but in most CPU systems, the time consumed by the multiplication method will be greater than the addition and subtraction, especially in a very large amount of computation, the cumulative difference is greater;
L clearly state in Adobe's official document that Flashplayer does not support dot dash (dash)


Why don't we support dash? In fact, in the vector graphics display, in addition to the curve and Scan line intersection of the calculation, the most difficult is to calculate the length of the curve, dash display must rely on the calculation of the prior curve length, when the implementation of GINGKOVG, does not include the dash function of the curve shows that its display performance is 4 times times the use of dash;
L That's all? Not, but even with the above constraints, its display performance has been "boosted" several times. In Adobe's Flashplayer, other optimization algorithms are used for rendering at the same time, although these optimization algorithms are also used as general-purpose optimization techniques in most 2D vector engines; (Reference: http://download.csdn.net/source/1998019)
Unfortunately, most 2D vector engines will support 3-order Bezier curves and dashes, even arcs (OpenVG), because they need to consider commonality. In this way, it is not difficult to understand why the open source Flashplayer using standard 2D rendering engines (such as Gnash using agg) cannot compare with the performance of Adobe's Flashplayer----- Because Flashplayer's 2D rendering engine is tailored to the real-time nature of flash playback, of course, Adobe's flashplayer has a lot to do with the optimization of the program, which is not something we need to discuss here;
Things seem to be over, but with a deep study of flashplayer, we've found some more in-depth questions-----and why Adobe's Flashplayer is widely criticized for the poor hardware acceleration, without considering hardware acceleration for a particular GPU, We only consider the standard hardware acceleration (OpenGL ES/OPENVG) to explain the problem; When Adobe's Flashplayer was born, there was no universal 2D vector display standard (such as OpenVG), and its 2D vector graphics display was a bright spot for software rendering. , after more than 10 years of development and optimization, Adobe's 2D software vector rendering engine has evolved to perfection, which can also explain why the rendering engine has not changed much since Flashplayer 4 to Flashplayer 8, and it can also explain why Adobe Flashplayer software rendering can be even better than using low-end hardware acceleration, but, analyticals reminder, overly perfect standards and algorithms hinder the possibility of using standard hardware acceleration (Hardware acceleration for special GPUs, because their flexibility is not in our consideration), As we continue to look at Adobe's official documents, we note that there is a difference between the flashplayer and the traditional 2D vector engine: the traditional 2D vector engine (such as OPENVG/GINGKOVG) has two filling rules: the odd-even fill rule (even-odd Fill rule) and the non-0 fill rule (non-zero fill rule), and Adobe's Flashplayer adds the edge-padding rule (edge-edge fill rule), and most 2D vector engines are for each shape/ Object uses a single shading method (Rcolor), and in the edge fill rule, one edge can have two different shading modes (COLOR1/COLOR2) depending on the left and right, but Adobe does this because it adds flexibility to software rendering. If a different shading method is allowed for the intersecting part when the two shapes intersect,


Unfortunately, when using the standard graphics Acceleration engine (OPENVG/OPENGL) It is confusing to us that we may have different shading methods for a shape, which seems to be contrary to most 2D vector engines, although we can see two different parity fill rules for the edge-padding rule, But with a fill rule that may change for each edge, the re-validation of a shape with a single color is not so easy, especially for a shape formed by a curve. However, this problem is not very troublesome compared to 2D vector graphics rendering, but we can find that Adobe Flashplayer does not seem "friendly" to most traditional 2D vector engines today-----programmers must carefully write a middle tier to solve these problems, This is not an error for Adobe: these 2D vector display standards (OpenVG) have not appeared at the time of Flashplayer's birth, but it is a pity that Adobe's flashplayer is not an open source program (Adobe Flashplayer's AVM2 is open source) , so we have to wait patiently for adobe to do this for us, unless we are not prepared to use the official flashplayer;
(We use OPENVG's flashplayer ourselves)
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.