ImageDecoder: Disallow empty/unsorted crop rects

Bug: 135133301
Test: Idf64474f28c0bf3f77616a31d843d84fbfd570ab

If the specified crop Rect is empty or unsorted, throw an
IllegalStateException, like we do if the Rect does not fit in the target
size.

This is a change in behavior to make it more consistent. Here are the
specific behavior changes:
- an empty crop rect was previously supported in all cases, but would
  result in a zero width and/or height Bitmap/Drawable. If one
  dimension is non-zero, it still affects layout, though nothing is
  drawn. This is not useful, so the new Exception is more helpful. (It
  is also more consistent with setTargetSize, which throws an
  IllegalArgumentException for non-positive dimensions.)
- a negative width or height in decodeBitmap, or on a static image in
  decodeDrawable, previously threw an IOException when trying to call
  SkBitmap::setInfo with a negative width or height. Throwing an
  IllegalStateException is more consistent with other invalid crop rects
- a negative width or height in decodeDrawable on an animated image
  previously resulted in an AnimatedImageDrawable with a negative
  intrinsic width and/or height. When passed to an ImageView, this
  dimension ends up being 1. Again, this does not seem useful.

Change-Id: I15d2f77125799413eaf55d417e98ff34599e2eb4
1 file changed