LayoutLib: Fix Canvas layer support with 2+ layers

- When drawing is not clipped to the top layers,
  drawing should not happen automatically on all
  existing layers. Instead each layer's flags dictate
  whether drawing should happen on layers beneath, starting
  with the top layer.
- upon restore, the same mechanism is taken. Only blit
  a layer into the layer beneath if it was drawn into
  using the logic above.

Also fixed:
- saveLayer() does not, in fact, always save matrix
  and clip info. The flag dictate this, the same way
  it does in save()
- drawing code didn't properly detect the case of drawing
  into layers if a save() was called after saveLayer().
  Now the code only looks at the layer list which provide
  all the needed info (flags mostly), and doesn't rely
  on mLocalLayer (which is used during restore only now).
- Properly handle HAS_ALPHA_LAYER_SAVE_FLAG (or lack
  thereof) when creating the BufferedImage for the layer.

Change-Id: I2fbbcc0f5d3a3dd208763705bc23e6658fd4e573
1 file changed