Use soft references for the AWT image cache

The layout editor stores both an SWT image (of the most recently
rendered scene), as well as an AWT image which is kept around such
that it can be used over again and over again as the scratch buffer
for layout lib. However, if you're opening a lot of editors, there's a
lot of these AWT buffers sitting around and most of the time not
getting used. In a low memory situation they should be able to be
freed up.

To allow for this, the AWT image buffers are now held only by a soft
(not weak) reference. If the soft reference is cleared by the garbage
collector, then a new AWT image buffer will be allocated when needed
for layoutlib.

There is one wrinkle in all this: On Linux, we prescale images
(because scaling while painting is very slow -- see issue 19447). This
means we need to keep the AWT image around. Thus, there's a second
field which is strong reference to the AWT image, which we set if
prescaling is enabled.

Change-Id: Ifb64e476c29194f0e99fec023612f9dc880dd6f4
1 file changed