GitHub PushEvent at 2014-01-19 00:37:53
Repository: libass
Actor: astiob
Payload: {"shas":[["c556b342d9de6741588626ce38460e89bb6cef31","128f98cf59b3e88da3b9e012fc9458775e76c986@inbox.lv","Make fix_outline always produce the correct final color\n\nWhenever a glyph has a border, the original glyph's own ASS_Image\nis applied on top of the border's ASS_Image. Let's mathematically\ndevise such alpha values for the border image that the resulting\ncolors exactly match (modulo rounding) the colors produced by a\nhypothetical ASS_Image that contains both the glyph and the border.\n\nLet a_i be the opacity of a single pixel within an ASS_Image,\nwhere i is either g for glyph or o for outline (border). Further,\nlet A_i be the opacity and c_i the color of the entire ASS_Image.\n\nThink of a_i as the _area_ covered by the glyph/border,\nmeasured in pixels. We have 0 <= a_g <= a_o <= 1.\nWe also have 0 <= A_g, A_o <= 1.\n\nWe need a background color. Let's denote it as c_b. The background\ncolor includes any effects from applying the shadow of the glyph.\n\nThe final color we want to achieve is:\n  * on the area covered by the original glyph,\n                                       A_g c_g + (1 - A_g) c_b.\n  * on the area covered by the border, A_o c_o + (1 - A_o) c_b.\n  * on the remaining area,             c_b.\nAveraging the color over the pixel's area gives:\n           a_g  (A_g c_g + (1 - A_g) c_b) +\n    (a_o - a_g) (A_o c_o + (1 - A_o) c_b) +\n      (1 - a_o)  c_b\n\nThe color we actually get after blending the border with the\nbackground and then blending the original glyph with the result is:\n        (A_g a_g) c_g +\n    (1 - A_g a_g) ((A_o a_o) c_o + (1 - A_o a_o) c_b)\n\nWe want to replace a_o in the actual color's expression with a\nvalue that makes it match the expected color. Let's call this value\na_o'. Equating both expressions and solving for a_o' gives:\n       A_o (c_o - c_b) = 0 and a_o' does not matter\n    or A_g a_g = 1 and a_o' does not matter\n    or a_o' = (a_o - a_g) / (1 - A_g a_g)\n\nIn the A_o (c_o - c_b) = 0 case, we can always pick an a_o' that\nsatisfies one of the other two conditions. Effectively we can\nignore the first case altogether.\n\nA_g a_g can only equal 1 if A_g = a_g = 1. Since a_g <= a_o <= 1,\na_o must also be 1. As it happens, libass already handles this case\nseparately: as a precaution, it checks that a_g < a_o and sets a_o'\nto zero if this condition fails to hold. This works fine, so let's\nretain this behavior.\n\nThis commit makes libass use the solution formula from the third\ncase to calculate a_o'. To enable this, the opacity of the original\nglyph is passed to fix_outline and outline_to_bitmap3. Generated\nbitmaps depend on it, so glyphs with different primary color alpha\nare now distinguished by the bitmap cache. The calculation itself\nis performed exactly and rounded correctly (half towards +infinity)\nusing only integer arithmetic.","Oleg Oshmyan",true],["81bb699fbdee77a84547dc1b3433dd5bdf6625f1","128f98cf59b3e88da3b9e012fc9458775e76c986@inbox.lv","Omit fully transparent glyphs from non-opaque-box shadows\n\nIf there is an outline around the transparent glyph,\nthe shadow is supposed to be a copy of this outline.\n\nThis completes the fix made in commit f9283004,\nwhich covered the case where there is no outline.\n\nFixes issue #70.","Oleg Oshmyan",true]],"size":2,"ref":"refs/heads/alpha","head":"81bb699fbdee77a84547dc1b3433dd5bdf6625f1"}