Take draw margins into account for tile layer bounding rect

Without taking the draw margins into account, tiles sticking outside of
the layer's area fail to repaint correctly when changing layer
visibility or opacity.

Some additional checking was required to make sure the bounding rect
updates as necessary when a tile layer's draw margins change.