MediaCodec/Image: handle null cropRect correctly

- allow Media.Image.setCropRect(null) to unset cropRect
- use full image if cropRect is null in MediaCodec$Image

Bug: 18124320
Change-Id: I7abb6175402a1fe913e16c0a682fabee79c55741
This commit is contained in:
Lajos Molnar
2014-10-27 14:54:33 -07:00
parent d234dc1f20
commit 24ffac0135
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.
*/
public void setCropRect(Rect cropRect) {
cropRect = new Rect(cropRect); // make a copy
cropRect.intersect(0, 0, getWidth(), getHeight());
if (cropRect != null) {
cropRect = new Rect(cropRect); // make a copy
cropRect.intersect(0, 0, getWidth(), getHeight());
}
mCropRect = cropRect;
}

View File

@@ -1778,10 +1778,6 @@ final public class MediaCodec {
mIsValid = true;
mIsReadOnly = buffer.isReadOnly();
mBuffer = buffer.duplicate();
if (cropRect != null) {
cropRect.offset(-xOffset, -yOffset);
}
super.setCropRect(cropRect);
// save offsets and info
mXOffset = xOffset;
@@ -1833,6 +1829,12 @@ final public class MediaCodec {
throw new UnsupportedOperationException(
"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 {