1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.cts.verifier.camera.its; 18 19 import android.util.Size; 20 21 import java.util.Arrays; 22 import java.util.Locale; 23 import java.util.Objects; 24 25 26 final class ImageReaderArgs { 27 private final Size[] mOutputSizes; 28 private final int[] mOutputFormats; 29 private final Size mInputSize; 30 private final int mInputFormat; 31 private final int mMaxInputBuffers; 32 private final boolean mHas10bitOutput; 33 ImageReaderArgs(Size[] outputSizes, int[] outputFormats, Size inputSize, int inputFormat, int maxInputBuffers, boolean has10bitOutput)34 private ImageReaderArgs(Size[] outputSizes, int[] outputFormats, 35 Size inputSize, int inputFormat, 36 int maxInputBuffers, boolean has10bitOutput) { 37 mOutputSizes = outputSizes; 38 mOutputFormats = outputFormats; 39 mInputSize = inputSize; 40 mInputFormat = inputFormat; 41 mMaxInputBuffers = maxInputBuffers; 42 mHas10bitOutput = has10bitOutput; 43 } 44 45 public static final ImageReaderArgs EMPTY = new ImageReaderArgs( 46 null, null, null, -1, -1, false); 47 valueOf(Size[] outputSizes, int[] outputFormats, Size inputSize, int inputFormat, int maxInputBuffers, boolean has10bitOutput)48 public static ImageReaderArgs valueOf(Size[] outputSizes, int[] outputFormats, 49 Size inputSize, int inputFormat, 50 int maxInputBuffers, boolean has10bitOutput) { 51 return new ImageReaderArgs(outputSizes.clone(), outputFormats.clone(), 52 inputSize, inputFormat, maxInputBuffers, has10bitOutput); 53 } 54 getOutputSizes()55 public Size[] getOutputSizes() { 56 return mOutputSizes; 57 } 58 getOutputFormats()59 public int[] getOutputFormats() { 60 return mOutputFormats; 61 } 62 getInputSize()63 public Size getInputSize() { 64 return mInputSize; 65 } 66 getInputFormat()67 public int getInputFormat() { 68 return mInputFormat; 69 } 70 getMaxInputBuffers()71 public int getMaxInputBuffers() { 72 return mMaxInputBuffers; 73 } 74 getHas10bitOutput()75 public boolean getHas10bitOutput() { 76 return mHas10bitOutput; 77 } 78 79 @Override equals(Object obj)80 public boolean equals(Object obj) { 81 if (obj == null) { 82 return false; 83 } else if (this == obj) { 84 return true; 85 } else if (obj instanceof ImageReaderArgs) { 86 ImageReaderArgs other = (ImageReaderArgs) obj; 87 return (Arrays.equals(mOutputSizes, other.mOutputSizes) && 88 Arrays.equals(mOutputFormats, other.mOutputFormats) && 89 Objects.equals(mInputSize, other.mInputSize) && 90 mInputFormat == other.mInputFormat && 91 mMaxInputBuffers == other.mMaxInputBuffers && 92 mHas10bitOutput == other.mHas10bitOutput); 93 } else { 94 return false; 95 } 96 } 97 98 @Override hashCode()99 public int hashCode() { 100 return Objects.hash(Arrays.hashCode(mOutputSizes), Arrays.hashCode(mOutputFormats), 101 mInputSize, mInputFormat, mMaxInputBuffers, mHas10bitOutput); 102 } 103 104 @Override toString()105 public String toString() { 106 StringBuilder output = new StringBuilder(); 107 output.append(String.format(Locale.getDefault(), 108 "outputSizes: %s, ", Arrays.toString(mOutputSizes))); 109 output.append(String.format(Locale.getDefault(), 110 "outputFormats: %s, ", Arrays.toString(mOutputFormats))); 111 output.append(String.format(Locale.getDefault(), 112 "inputSize: %s, ", Objects.toString(mInputSize))); 113 output.append(String.format(Locale.getDefault(), 114 "inputFormat: %d, ", mInputFormat)); 115 output.append(String.format(Locale.getDefault(), 116 "maxInputBuffers: %d, ", mMaxInputBuffers)); 117 output.append(String.format(Locale.getDefault(), 118 "has10bitOutput: %s", mHas10bitOutput)); 119 return output.toString(); 120 } 121 }