Merge "camera2 params: Modify Capability constructor to take a Size and Range."
This commit is contained in:
committed by
Android (Google) Code Review
commit
5f1ff7d2ec
@@ -18154,7 +18154,7 @@ package android.hardware.camera2.params {
|
||||
}
|
||||
|
||||
public final class Capability {
|
||||
ctor public Capability(int, int, int, float, float);
|
||||
ctor public Capability(int, @NonNull android.util.Size, @NonNull android.util.Range<java.lang.Float>);
|
||||
method @NonNull public android.util.Size getMaxStreamingSize();
|
||||
method public int getMode();
|
||||
method @NonNull public android.util.Range<java.lang.Float> getZoomRatioRange();
|
||||
|
||||
@@ -88,8 +88,8 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -1734,12 +1734,12 @@ public class CameraMetadataNative implements Parcelable {
|
||||
int height = maxSizes[3 * i + 2];
|
||||
if (mode != CameraMetadata.CONTROL_EXTENDED_SCENE_MODE_DISABLED
|
||||
&& j < numExtendedSceneModeZoomRanges) {
|
||||
capabilities[i] = new Capability(mode, width, height, zoomRanges[2 * j],
|
||||
zoomRanges[2 * j + 1]);
|
||||
capabilities[i] = new Capability(mode, new Size(width, height),
|
||||
new Range<Float>(zoomRanges[2 * j], zoomRanges[2 * j + 1]));
|
||||
j++;
|
||||
} else {
|
||||
capabilities[i] = new Capability(mode, width, height, modeOffMinZoomRatio,
|
||||
modeOffMaxZoomRatio);
|
||||
capabilities[i] = new Capability(mode, new Size(width, height),
|
||||
new Range<Float>(modeOffMinZoomRatio, modeOffMaxZoomRatio));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,8 @@ public final class Capability {
|
||||
public static final int COUNT = 3;
|
||||
|
||||
private final int mMode;
|
||||
private final int mMaxStreamingWidth;
|
||||
private final int mMaxStreamingHeight;
|
||||
private final float mMinZoomRatio;
|
||||
private final float mMaxZoomRatio;
|
||||
private final Size mMaxStreamingSize;
|
||||
private final Range<Float> mZoomRatioRange;
|
||||
|
||||
/**
|
||||
* Create a new Capability object.
|
||||
@@ -57,29 +55,30 @@ public final class Capability {
|
||||
* objects during normal use of the camera API.</p>
|
||||
*
|
||||
* @param mode supported mode for a camera capability.
|
||||
* @param maxStreamingWidth The width of the maximum streaming size for this mode
|
||||
* @param maxStreamingHeight The height of the maximum streaming size for this mode
|
||||
* @param minZoomRatio the minimum zoom ratio this mode supports
|
||||
* @param maxZoomRatio the maximum zoom ratio this mode supports
|
||||
* @param maxStreamingSize The maximum streaming size for this mode
|
||||
* @param zoomRatioRange the minimum/maximum zoom ratio this mode supports
|
||||
*
|
||||
* @throws IllegalArgumentException if any of the argument is not valid
|
||||
* @throws IllegalArgumentException if any of the arguments are not valid
|
||||
*/
|
||||
public Capability(int mode, int maxStreamingWidth, int maxStreamingHeight,
|
||||
float minZoomRatio, float maxZoomRatio) {
|
||||
public Capability(int mode, @NonNull Size maxStreamingSize,
|
||||
@NonNull Range<Float> zoomRatioRange) {
|
||||
mMode = mode;
|
||||
mMaxStreamingWidth = checkArgumentNonnegative(maxStreamingWidth,
|
||||
"maxStreamingWidth must be nonnegative");
|
||||
mMaxStreamingHeight = checkArgumentNonnegative(maxStreamingHeight,
|
||||
"maxStreamingHeight must be nonnegative");
|
||||
checkArgumentNonnegative(maxStreamingSize.getWidth(),
|
||||
"maxStreamingSize.getWidth() must be nonnegative");
|
||||
checkArgumentNonnegative(maxStreamingSize.getHeight(),
|
||||
"maxStreamingSize.getHeight() must be nonnegative");
|
||||
mMaxStreamingSize = maxStreamingSize;
|
||||
|
||||
if (minZoomRatio > maxZoomRatio) {
|
||||
throw new IllegalArgumentException("minZoomRatio " + minZoomRatio
|
||||
+ " is greater than maxZoomRatio " + maxZoomRatio);
|
||||
if (zoomRatioRange.getLower() > zoomRatioRange.getUpper()) {
|
||||
throw new IllegalArgumentException("zoomRatioRange.getLower() "
|
||||
+ zoomRatioRange.getLower() + " is greater than zoomRatioRange.getUpper() "
|
||||
+ zoomRatioRange.getUpper());
|
||||
}
|
||||
mMinZoomRatio = checkArgumentPositive(minZoomRatio,
|
||||
"minZoomRatio must be positive");
|
||||
mMaxZoomRatio = checkArgumentPositive(maxZoomRatio,
|
||||
"maxZoomRatio must be positive");
|
||||
checkArgumentPositive(zoomRatioRange.getLower(),
|
||||
"zoomRatioRange.getLower() must be positive");
|
||||
checkArgumentPositive(zoomRatioRange.getUpper(),
|
||||
"zoomRatioRange.getUpper() must be positive");
|
||||
mZoomRatioRange = zoomRatioRange;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +99,7 @@ public final class Capability {
|
||||
* @return a new {@link Size} with non-negative width and height
|
||||
*/
|
||||
public @NonNull Size getMaxStreamingSize() {
|
||||
return new Size(mMaxStreamingWidth, mMaxStreamingHeight);
|
||||
return mMaxStreamingSize;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +108,7 @@ public final class Capability {
|
||||
* @return The supported zoom ratio range supported by this capability
|
||||
*/
|
||||
public @NonNull Range<Float> getZoomRatioRange() {
|
||||
return new Range<Float>(mMinZoomRatio, mMaxZoomRatio);
|
||||
return mZoomRatioRange;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,10 +131,8 @@ public final class Capability {
|
||||
if (obj instanceof Capability) {
|
||||
final Capability other = (Capability) obj;
|
||||
return (mMode == other.mMode
|
||||
&& mMaxStreamingWidth == other.mMaxStreamingWidth
|
||||
&& mMaxStreamingHeight == other.mMaxStreamingHeight
|
||||
&& mMinZoomRatio == other.mMinZoomRatio
|
||||
&& mMaxZoomRatio == other.mMaxZoomRatio);
|
||||
&& mMaxStreamingSize.equals(other.mMaxStreamingSize)
|
||||
&& mZoomRatioRange.equals(other.mZoomRatioRange));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -145,8 +142,9 @@ public final class Capability {
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return HashCodeHelpers.hashCode(mMode, mMaxStreamingWidth, mMaxStreamingHeight,
|
||||
mMinZoomRatio, mMaxZoomRatio);
|
||||
return HashCodeHelpers.hashCode(mMode, mMaxStreamingSize.getWidth(),
|
||||
mMaxStreamingSize.getHeight(), mZoomRatioRange.getLower(),
|
||||
mZoomRatioRange.getUpper());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +156,7 @@ public final class Capability {
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("(mode:%d, maxStreamingSize:%d x %d, zoomRatio: %f-%f)",
|
||||
mMode, mMaxStreamingWidth, mMaxStreamingHeight, mMinZoomRatio,
|
||||
mMaxZoomRatio);
|
||||
mMode, mMaxStreamingSize.getWidth(), mMaxStreamingSize.getHeight(),
|
||||
mZoomRatioRange.getLower(), mZoomRatioRange.getUpper());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user