@@ -58,32 +58,42 @@ void PhysicalShapeLayer::Preroll(PrerollContext* context,
5858 // join the child paint bounds.
5959 // The offset is calculated as follows:
6060
61- // .-- (kLightRadius = 800)
62- // ----- (light)
63- // | (kLightHeight = 600)
61+ // .--- (kLightRadius)
62+ // -------/ (light)
63+ // | /
64+ // | /
65+ // |/
66+ // |O
67+ // /| (kLightHeight)
68+ // / |
69+ // / |
70+ // / |
71+ // / |
6472 // ------------- (layer)
65- // |
66- // | (elevation)
67- // |
73+ // /| |
74+ // / | | (elevation)
75+ // A / | |B
6876 // ------------------------------------------------ (canvas)
69- // -------- --- (extent of shadow)
77+ // --- (extent of shadow)
7078 //
71- // E = lx } x = (r + w/2)/h
79+ // E = lt } t = (r + w/2)/h
7280 // } =>
73- // r + w/2 = hx } E = (l/h)(r + w/2)
81+ // r + w/2 = ht } E = (l/h)(r + w/2)
7482 //
7583 // Where: E = extent of shadow
7684 // l = elevation of layer
7785 // r = radius of the light source
7886 // w = width of the layer
7987 // h = light height
80- // x = multiplier for elevation to extent
88+ // t = tangent of AOB, i.e., multiplier for elevation to extent
8189 SkRect bounds (path_.getBounds ());
82- double ex = (kLightRadius * device_pixel_ratio_ + bounds.width () * 0.5 ) /
90+ // tangent for x
91+ double tx = (kLightRadius * device_pixel_ratio_ + bounds.width () * 0.5 ) /
8392 kLightHeight ;
84- double ey = (kLightRadius * device_pixel_ratio_ + bounds.height () * 0.5 ) /
93+ // tangent for y
94+ double ty = (kLightRadius * device_pixel_ratio_ + bounds.height () * 0.5 ) /
8595 kLightHeight ;
86- bounds.outset (elevation_ * ex , elevation_ * ey );
96+ bounds.outset (elevation_ * tx , elevation_ * ty );
8797 set_paint_bounds (bounds);
8898#endif // defined(OS_FUCHSIA)
8999 }
0 commit comments