pdLayer: implement layer change notifications

This issue was a blocker for a whole host of other planned improvements,
so it is *great* to have it finished.

pdLayer objects expose a public layerDIB reference.  Despite its
non-OOP-ness, this was a carefully considered decision to maximize
performance, as it allows PD's various edit functions to directly
manipulate layer DIB data without the hassle (and performance hit) of
safe wrapper functions.

Unfortunately, this direct access prevents the layer from knowing when
its DIB contents have changed.  This has forced things like the layer
thumbnail generator to be extremely liberal with regenerating
thumbnails, as it has to assume that layer DIB data can change at any
time.

But no more!  With this commit, a new notifyLayerModified() function has
been added to the pdLayer class, and all internal DIB-modifying
functions have been updated to make use of it.  When called,
notifyLayerModified() marks all internal layer caches as dirty, and the
next time data from those caches is requested, they will either be
returned as-is (if clean) or regenerated on-the-fly (if dirty).

The first optimization this feature has allowed me to implement is
internal caching of layer thumbnails.  When a layer's DIB contents have
changed, the layer marks its internal thumbnail cache as dirty.  The
next time a layer thumbnail is requested, the layer checks the thumbnail
cache's state; if clean, the cached thumbnail is returned instantly.  If
dirty, the layer performs a one-time re-cache, then marks itself as
"clean" so subsequent requests simply hit the cache instead of requiring
a new thumbnail from scratch.

This has greatly improved performance of anything that calls
syncInterfaceToImage (e.g. everything in the damn program), because the
layer toolbox no longer has to regenerate its custom thumbnail cache
every time it is redrawn.  Instead, it just grabs the cached versions of
thumbnails from each layer - a huge win, especially on images with many
layers and/or very large layers.

Many more improvements to layer caching are planned, and this problem
was the major blocker for layer styles (as styles should also be cached
instead of constantly regenerated), so it's great to be on the right
track again.