Avoid unnecessary save/restores in Canvas.

Canvas has code for lazy save/restore of state, which is important for
performance due to the large size of canvas state, the cost in the
graphics back-end, and the ease with which developers can add too many
save/restores.

However, the current implementation does not reduce the number of saves
if the last save actually applies. In that case it makes all the
intervening save/restore calls.

This patch fixes the situation - only making as many saves/restores as
are actually necessary.

R=senorblanco,junov
BUG=334904

Review URL: https://codereview.chromium.org/135123005

git-svn-id: svn://svn.chromium.org/blink/trunk@166422 bbb929c8-8fbe-4397-9dbb-9b2b20218538