1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/reftests/css-blending/background-blending-alpha-ref.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +<!-- 1.5 + Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ 1.7 +--> 1.8 +<html> 1.9 +<style> 1.10 +.reftest { 1.11 + background-color: rgba(0, 255, 0, 0.5); 1.12 +} 1.13 + 1.14 +.child { 1.15 + width: 100px; 1.16 + height: 100px; 1.17 + opacity: 0.5; 1.18 + background-color: rgb(0, 127, 0); 1.19 +} 1.20 + 1.21 +.topleft { 1.22 + float:left; 1.23 + 1.24 + width: 100px; 1.25 + height: 100px; 1.26 + 1.27 + /*First blend black rect with green in place*/ 1.28 + /* Cs = (1 - αb) x Cs + αb x B(Cb, Cs)*/ 1.29 + /* B(Cb, Cs) = | Cb - Cs | = (0, 0, 0) */ 1.30 + /* 0.5 * (0, 255, 0) + 0.5 * (0, 0, 0) = (0, 127.5, 0)*/ 1.31 + 1.32 + /* Now, composite the resulting color with src-over; the alpha is the original alpha for the top layer 1.33 + while the color is the blending result*/ 1.34 + /* co = αs x Fa x Cs + αb x Fb x Cb - this is premultiplied */ 1.35 + /* αo = αs + αb x (1 – αs) */ 1.36 + /* Source over: Fa = 1; Fb = 1 – αs */ 1.37 + /*co = 0.5 * 1 * (0, 127.5, 0) + 0.5 * 0.5 * (0, 255, 0) = (0, 63.5, 0) + 0.25 * (0, 255, 0) = (0, 127.5, 0)*/ 1.38 + /*ao = 0.5 + 0.5 * 0.5 = 0.75*/ 1.39 + /* Co = co/ao = (0, 127.5, 0) / 0.75*/ 1.40 + 1.41 + /* Now alpha composite on white background */ 1.42 + /*co = 0.75 * 1 * (0, 127.5, 0) / 0.75 + 1 * 0.25 * (255, 255, 255) = (0, 127.5, 0) + (63.75, 63.75, 63.75) = (63.75, 159, 63.75) = (64, 191, 64) */ 1.43 + 1.44 + background-color: rgb(64, 191, 64); 1.45 +} 1.46 + 1.47 +.topright { 1.48 + float:left; 1.49 + width: 100px; 1.50 + height: 100px; 1.51 +} 1.52 + 1.53 +.bottom { 1.54 + width:200px; 1.55 + height: 100px; 1.56 + clear:both; 1.57 +} 1.58 + 1.59 +</style> 1.60 + 1.61 +<div class="topleft"></div> 1.62 +<div class="reftest topright"></div> 1.63 +<div class="reftest bottom"></div> 1.64 + 1.65 +</html>