Add layout validation.

This changes adds tracking of the current layout for each image. When the image
is used the current layout is verified to be legal and optimal for the command.

Conflicts:
	layers/draw_state.cpp
2 files changed