Re: box-shadow offset when transform:rotate is used

Although I have no fundamental objection to the idea of
rotation-independent shadow settings, my instinct is that this would be
problematic to implement.  Box shadows as spec'ed are simple paint
operations, not 3D lighting effects.

As Tab noted, rotations are applied after the painted layer has been
generated. Although the browser could keep track of the net rotation that
will be applied to an element, and then apply the reverse effect to the
shadow, this would have performance impacts beyond the extra calculations.
Animated transformations are optimized because the painted content does not
change.

For most cases (a 2D rotated shape with a solid border & background), you
can get the desired effect with a drop-shadow filter on an un-transformed
wrapper element.

A drop-shadow might not have the best rendering performance currently, but
it could be improved in future if implementations use GPU blur effects.  If
a future CSS spec introduces proper 3D lighting and shadow effects, that
would also probably be applied via `filter`.  Box-shadows, in contrast, do
not affect containing boxes & stacking contexts, so would be more difficult
to transfer to GPU effects.

~ABR

Received on Friday, 19 February 2016 15:43:16 UTC