Use selection masks in layer-based Paint to paint shapes or to isolate a selection of the front or matte clip that you want to paint.
To paint inside or outside a selection mask:
The stroke is only applied in the selection mask (or outside the selection mask if Invert is selected).