Merge "Camera: Fix framework bugs with DEPTH-only camera devices" into mnc-dev

This commit is contained in:
Eino-Ville Talvala
2015-08-12 20:01:44 +00:00
committed by Android (Google) Code Review
2 changed files with 36 additions and 13 deletions

View File

@@ -98,9 +98,19 @@ public final class StreamConfigurationMap {
HighSpeedVideoConfiguration[] highSpeedVideoConfigurations, HighSpeedVideoConfiguration[] highSpeedVideoConfigurations,
ReprocessFormatsMap inputOutputFormatsMap, ReprocessFormatsMap inputOutputFormatsMap,
boolean listHighResolution) { boolean listHighResolution) {
mConfigurations = checkArrayElementsNotNull(configurations, "configurations");
mMinFrameDurations = checkArrayElementsNotNull(minFrameDurations, "minFrameDurations"); if (configurations == null) {
mStallDurations = checkArrayElementsNotNull(stallDurations, "stallDurations"); // If no color configurations exist, ensure depth ones do
checkArrayElementsNotNull(depthConfigurations, "depthConfigurations");
mConfigurations = new StreamConfiguration[0];
mMinFrameDurations = new StreamConfigurationDuration[0];
mStallDurations = new StreamConfigurationDuration[0];
} else {
mConfigurations = checkArrayElementsNotNull(configurations, "configurations");
mMinFrameDurations = checkArrayElementsNotNull(minFrameDurations, "minFrameDurations");
mStallDurations = checkArrayElementsNotNull(stallDurations, "stallDurations");
}
mListHighResolution = listHighResolution; mListHighResolution = listHighResolution;
if (depthConfigurations == null) { if (depthConfigurations == null) {
@@ -124,7 +134,7 @@ public final class StreamConfigurationMap {
} }
// For each format, track how many sizes there are available to configure // For each format, track how many sizes there are available to configure
for (StreamConfiguration config : configurations) { for (StreamConfiguration config : mConfigurations) {
int fmt = config.getFormat(); int fmt = config.getFormat();
SparseIntArray map = null; SparseIntArray map = null;
if (config.isOutput()) { if (config.isOutput()) {
@@ -159,7 +169,8 @@ public final class StreamConfigurationMap {
mDepthOutputFormats.get(config.getFormat()) + 1); mDepthOutputFormats.get(config.getFormat()) + 1);
} }
if (mOutputFormats.indexOfKey(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) < 0) { if (configurations != null &&
mOutputFormats.indexOfKey(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) < 0) {
throw new AssertionError( throw new AssertionError(
"At least one stream configuration for IMPLEMENTATION_DEFINED must exist"); "At least one stream configuration for IMPLEMENTATION_DEFINED must exist");
} }

View File

@@ -679,17 +679,31 @@ public class ImageReader implements AutoCloseable {
@Override @Override
public int getWidth() { public int getWidth() {
throwISEIfImageIsInvalid(); throwISEIfImageIsInvalid();
mWidth = (getFormat() == ImageFormat.JPEG) ? ImageReader.this.getWidth() : int width;
nativeGetWidth(mFormat); switch(getFormat()) {
return mWidth; case ImageFormat.JPEG:
case ImageFormat.DEPTH_POINT_CLOUD:
width = ImageReader.this.getWidth();
break;
default:
width = nativeGetWidth(mFormat);
}
return width;
} }
@Override @Override
public int getHeight() { public int getHeight() {
throwISEIfImageIsInvalid(); throwISEIfImageIsInvalid();
mHeight = (getFormat() == ImageFormat.JPEG) ? ImageReader.this.getHeight() : int height;
nativeGetHeight(mFormat); switch(getFormat()) {
return mHeight; case ImageFormat.JPEG:
case ImageFormat.DEPTH_POINT_CLOUD:
height = ImageReader.this.getHeight();
break;
default:
height = nativeGetHeight(mFormat);
}
return height;
} }
@Override @Override
@@ -826,8 +840,6 @@ public class ImageReader implements AutoCloseable {
private long mTimestamp; private long mTimestamp;
private SurfacePlane[] mPlanes; private SurfacePlane[] mPlanes;
private int mHeight = -1;
private int mWidth = -1;
private int mFormat = ImageFormat.UNKNOWN; private int mFormat = ImageFormat.UNKNOWN;
// If this image is detached from the ImageReader. // If this image is detached from the ImageReader.
private AtomicBoolean mIsDetached = new AtomicBoolean(false); private AtomicBoolean mIsDetached = new AtomicBoolean(false);