am 7f94b52f: Merge "MediaCodec/Image: handle null cropRect correctly"

* commit '7f94b52fc7c66bc40702b46f59b3929c076cbbfb':
  MediaCodec/Image: handle null cropRect correctly
This commit is contained in:
Lajos Molnar
2015-01-10 01:26:02 +00:00
committed by Android Git Automerger
2 changed files with 10 additions and 6 deletions

View File

@@ -146,8 +146,10 @@ public abstract class Image implements AutoCloseable {
* using coordinates in the largest-resolution plane. * using coordinates in the largest-resolution plane.
*/ */
public void setCropRect(Rect cropRect) { public void setCropRect(Rect cropRect) {
cropRect = new Rect(cropRect); // make a copy if (cropRect != null) {
cropRect.intersect(0, 0, getWidth(), getHeight()); cropRect = new Rect(cropRect); // make a copy
cropRect.intersect(0, 0, getWidth(), getHeight());
}
mCropRect = cropRect; mCropRect = cropRect;
} }

View File

@@ -1778,10 +1778,6 @@ final public class MediaCodec {
mIsValid = true; mIsValid = true;
mIsReadOnly = buffer.isReadOnly(); mIsReadOnly = buffer.isReadOnly();
mBuffer = buffer.duplicate(); mBuffer = buffer.duplicate();
if (cropRect != null) {
cropRect.offset(-xOffset, -yOffset);
}
super.setCropRect(cropRect);
// save offsets and info // save offsets and info
mXOffset = xOffset; mXOffset = xOffset;
@@ -1833,6 +1829,12 @@ final public class MediaCodec {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"unsupported info length: " + info.remaining()); "unsupported info length: " + info.remaining());
} }
if (cropRect == null) {
cropRect = new Rect(0, 0, mWidth, mHeight);
}
cropRect.offset(-xOffset, -yOffset);
super.setCropRect(cropRect);
} }
private class MediaPlane extends Plane { private class MediaPlane extends Plane {