1 /* 2 * Copyright (C) 2015 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 18 package android.hardware.camera2.params; 19 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.annotation.SystemApi; 23 import android.graphics.ImageFormat; 24 import android.hardware.camera2.CameraCaptureSession; 25 import android.hardware.camera2.CameraDevice; 26 import android.hardware.camera2.utils.HashCodeHelpers; 27 import android.hardware.camera2.utils.SurfaceUtils; 28 import android.os.Parcel; 29 import android.os.Parcelable; 30 import android.util.Log; 31 import android.util.Size; 32 import android.view.Surface; 33 34 import java.util.Arrays; 35 import java.util.List; 36 import java.util.Collections; 37 import java.util.ArrayList; 38 39 import static com.android.internal.util.Preconditions.*; 40 41 /** 42 * A class for describing camera output, which contains a {@link Surface} and its specific 43 * configuration for creating capture session. 44 * 45 * @see CameraDevice#createCaptureSessionByOutputConfigurations 46 * 47 */ 48 public final class OutputConfiguration implements Parcelable { 49 50 /** 51 * Rotation constant: 0 degree rotation (no rotation) 52 * 53 * @hide 54 */ 55 @SystemApi 56 public static final int ROTATION_0 = 0; 57 58 /** 59 * Rotation constant: 90 degree counterclockwise rotation. 60 * 61 * @hide 62 */ 63 @SystemApi 64 public static final int ROTATION_90 = 1; 65 66 /** 67 * Rotation constant: 180 degree counterclockwise rotation. 68 * 69 * @hide 70 */ 71 @SystemApi 72 public static final int ROTATION_180 = 2; 73 74 /** 75 * Rotation constant: 270 degree counterclockwise rotation. 76 * 77 * @hide 78 */ 79 @SystemApi 80 public static final int ROTATION_270 = 3; 81 82 /** 83 * Invalid surface group ID. 84 * 85 *<p>An {@link OutputConfiguration} with this value indicates that the included surface 86 *doesn't belong to any surface group.</p> 87 */ 88 public static final int SURFACE_GROUP_ID_NONE = -1; 89 90 /** 91 * Create a new {@link OutputConfiguration} instance with a {@link Surface}. 92 * 93 * @param surface 94 * A Surface for camera to output to. 95 * 96 * <p>This constructor creates a default configuration, with a surface group ID of 97 * {@value #SURFACE_GROUP_ID_NONE}.</p> 98 * 99 */ OutputConfiguration(@onNull Surface surface)100 public OutputConfiguration(@NonNull Surface surface) { 101 this(SURFACE_GROUP_ID_NONE, surface, ROTATION_0); 102 } 103 104 /** 105 * Unknown surface source type. 106 */ 107 private final int SURFACE_TYPE_UNKNOWN = -1; 108 109 /** 110 * The surface is obtained from {@link android.view.SurfaceView}. 111 */ 112 private final int SURFACE_TYPE_SURFACE_VIEW = 0; 113 114 /** 115 * The surface is obtained from {@link android.graphics.SurfaceTexture}. 116 */ 117 private final int SURFACE_TYPE_SURFACE_TEXTURE = 1; 118 119 /** 120 * Maximum number of surfaces supported by one {@link OutputConfiguration}. 121 * 122 * <p>The combined number of surfaces added by the constructor and 123 * {@link OutputConfiguration#addSurface} should not exceed this value.</p> 124 * 125 */ 126 private static final int MAX_SURFACES_COUNT = 2; 127 128 /** 129 * Create a new {@link OutputConfiguration} instance with a {@link Surface}, 130 * with a surface group ID. 131 * 132 * <p> 133 * A surface group ID is used to identify which surface group this output surface belongs to. A 134 * surface group is a group of output surfaces that are not intended to receive camera output 135 * buffer streams simultaneously. The {@link CameraDevice} may be able to share the buffers used 136 * by all the surfaces from the same surface group, therefore may reduce the overall memory 137 * footprint. The application should only set the same set ID for the streams that are not 138 * simultaneously streaming. A negative ID indicates that this surface doesn't belong to any 139 * surface group. The default value is {@value #SURFACE_GROUP_ID_NONE}.</p> 140 * 141 * <p>For example, a video chat application that has an adaptive output resolution feature would 142 * need two (or more) output resolutions, to switch resolutions without any output glitches. 143 * However, at any given time, only one output is active to minimize outgoing network bandwidth 144 * and encoding overhead. To save memory, the application should set the video outputs to have 145 * the same non-negative group ID, so that the camera device can share the same memory region 146 * for the alternating outputs.</p> 147 * 148 * <p>It is not an error to include output streams with the same group ID in the same capture 149 * request, but the resulting memory consumption may be higher than if the two streams were 150 * not in the same surface group to begin with, especially if the outputs have substantially 151 * different dimensions.</p> 152 * 153 * @param surfaceGroupId 154 * A group ID for this output, used for sharing memory between multiple outputs. 155 * @param surface 156 * A Surface for camera to output to. 157 * 158 */ OutputConfiguration(int surfaceGroupId, @NonNull Surface surface)159 public OutputConfiguration(int surfaceGroupId, @NonNull Surface surface) { 160 this(surfaceGroupId, surface, ROTATION_0); 161 } 162 163 /** 164 * Create a new {@link OutputConfiguration} instance. 165 * 166 * <p>This constructor takes an argument for desired camera rotation</p> 167 * 168 * @param surface 169 * A Surface for camera to output to. 170 * @param rotation 171 * The desired rotation to be applied on camera output. Value must be one of 172 * ROTATION_[0, 90, 180, 270]. Note that when the rotation is 90 or 270 degrees, 173 * application should make sure corresponding surface size has width and height 174 * transposed relative to the width and height without rotation. For example, 175 * if application needs camera to capture 1280x720 picture and rotate it by 90 degree, 176 * application should set rotation to {@code ROTATION_90} and make sure the 177 * corresponding Surface size is 720x1280. Note that {@link CameraDevice} might 178 * throw {@code IllegalArgumentException} if device cannot perform such rotation. 179 * @hide 180 */ 181 @SystemApi OutputConfiguration(@onNull Surface surface, int rotation)182 public OutputConfiguration(@NonNull Surface surface, int rotation) { 183 this(SURFACE_GROUP_ID_NONE, surface, rotation); 184 } 185 186 /** 187 * Create a new {@link OutputConfiguration} instance, with rotation and a group ID. 188 * 189 * <p>This constructor takes an argument for desired camera rotation and for the surface group 190 * ID. See {@link #OutputConfiguration(int, Surface)} for details of the group ID.</p> 191 * 192 * @param surfaceGroupId 193 * A group ID for this output, used for sharing memory between multiple outputs. 194 * @param surface 195 * A Surface for camera to output to. 196 * @param rotation 197 * The desired rotation to be applied on camera output. Value must be one of 198 * ROTATION_[0, 90, 180, 270]. Note that when the rotation is 90 or 270 degrees, 199 * application should make sure corresponding surface size has width and height 200 * transposed relative to the width and height without rotation. For example, 201 * if application needs camera to capture 1280x720 picture and rotate it by 90 degree, 202 * application should set rotation to {@code ROTATION_90} and make sure the 203 * corresponding Surface size is 720x1280. Note that {@link CameraDevice} might 204 * throw {@code IllegalArgumentException} if device cannot perform such rotation. 205 * @hide 206 */ 207 @SystemApi OutputConfiguration(int surfaceGroupId, @NonNull Surface surface, int rotation)208 public OutputConfiguration(int surfaceGroupId, @NonNull Surface surface, int rotation) { 209 checkNotNull(surface, "Surface must not be null"); 210 checkArgumentInRange(rotation, ROTATION_0, ROTATION_270, "Rotation constant"); 211 mSurfaceGroupId = surfaceGroupId; 212 mSurfaceType = SURFACE_TYPE_UNKNOWN; 213 mSurfaces = new ArrayList<Surface>(); 214 mSurfaces.add(surface); 215 mRotation = rotation; 216 mConfiguredSize = SurfaceUtils.getSurfaceSize(surface); 217 mConfiguredFormat = SurfaceUtils.getSurfaceFormat(surface); 218 mConfiguredDataspace = SurfaceUtils.getSurfaceDataspace(surface); 219 mConfiguredGenerationId = surface.getGenerationId(); 220 mIsDeferredConfig = false; 221 mIsShared = false; 222 } 223 224 /** 225 * Create a new {@link OutputConfiguration} instance, with desired Surface size and Surface 226 * source class. 227 * <p> 228 * This constructor takes an argument for desired Surface size and the Surface source class 229 * without providing the actual output Surface. This is used to setup an output configuration 230 * with a deferred Surface. The application can use this output configuration to create a 231 * session. 232 * </p> 233 * <p> 234 * However, the actual output Surface must be set via {@link #addSurface} and the deferred 235 * Surface configuration must be finalized via {@link 236 * CameraCaptureSession#finalizeOutputConfigurations} before submitting a request with this 237 * Surface target. The deferred Surface can only be obtained either from {@link 238 * android.view.SurfaceView} by calling {@link android.view.SurfaceHolder#getSurface}, or from 239 * {@link android.graphics.SurfaceTexture} via 240 * {@link android.view.Surface#Surface(android.graphics.SurfaceTexture)}). 241 * </p> 242 * 243 * @param surfaceSize Size for the deferred surface. 244 * @param klass a non-{@code null} {@link Class} object reference that indicates the source of 245 * this surface. Only {@link android.view.SurfaceHolder SurfaceHolder.class} and 246 * {@link android.graphics.SurfaceTexture SurfaceTexture.class} are supported. 247 * @throws IllegalArgumentException if the Surface source class is not supported, or Surface 248 * size is zero. 249 */ OutputConfiguration(@onNull Size surfaceSize, @NonNull Class<T> klass)250 public <T> OutputConfiguration(@NonNull Size surfaceSize, @NonNull Class<T> klass) { 251 checkNotNull(klass, "surfaceSize must not be null"); 252 checkNotNull(klass, "klass must not be null"); 253 if (klass == android.view.SurfaceHolder.class) { 254 mSurfaceType = SURFACE_TYPE_SURFACE_VIEW; 255 } else if (klass == android.graphics.SurfaceTexture.class) { 256 mSurfaceType = SURFACE_TYPE_SURFACE_TEXTURE; 257 } else { 258 mSurfaceType = SURFACE_TYPE_UNKNOWN; 259 throw new IllegalArgumentException("Unknow surface source class type"); 260 } 261 262 if (surfaceSize.getWidth() == 0 || surfaceSize.getHeight() == 0) { 263 throw new IllegalArgumentException("Surface size needs to be non-zero"); 264 } 265 266 mSurfaceGroupId = SURFACE_GROUP_ID_NONE; 267 mSurfaces = new ArrayList<Surface>(); 268 mRotation = ROTATION_0; 269 mConfiguredSize = surfaceSize; 270 mConfiguredFormat = StreamConfigurationMap.imageFormatToInternal(ImageFormat.PRIVATE); 271 mConfiguredDataspace = StreamConfigurationMap.imageFormatToDataspace(ImageFormat.PRIVATE); 272 mConfiguredGenerationId = 0; 273 mIsDeferredConfig = true; 274 mIsShared = false; 275 } 276 277 /** 278 * Enable multiple surfaces sharing the same OutputConfiguration 279 * 280 * <p>For advanced use cases, a camera application may require more streams than the combination 281 * guaranteed by {@link CameraDevice#createCaptureSession}. In this case, more than one 282 * compatible surface can be attached to an OutputConfiguration so that they map to one 283 * camera stream, and the outputs share memory buffers when possible. </p> 284 * 285 * <p>Two surfaces are compatible in the below cases:</p> 286 * 287 * <li> Surfaces with the same size, format, dataSpace, and Surface source class. In this case, 288 * {@link CameraDevice#createCaptureSessionByOutputConfigurations} is guaranteed to succeed. 289 * 290 * <li> Surfaces with the same size, format, and dataSpace, but different Surface source classes 291 * that are generally not compatible. However, on some devices, the underlying camera device is 292 * able to use the same buffer layout for both surfaces. The only way to discover if this is the 293 * case is to create a capture session with that output configuration. For example, if the 294 * camera device uses the same private buffer format between a SurfaceView/SurfaceTexture and a 295 * MediaRecorder/MediaCodec, {@link CameraDevice#createCaptureSessionByOutputConfigurations} 296 * will succeed. Otherwise, it fails with {@link 297 * CameraCaptureSession.StateCallback#onConfigureFailed}. 298 * </ol> 299 * 300 * <p>To enable surface sharing, this function must be called before {@link 301 * CameraDevice#createCaptureSessionByOutputConfigurations}. Calling this function after {@link 302 * CameraDevice#createCaptureSessionByOutputConfigurations} has no effect.</p> 303 * 304 * <p>Up to 2 surfaces can be shared for an OutputConfiguration. The supported surfaces for 305 * sharing must be of type SurfaceTexture, SurfaceView, MediaRecorder, MediaCodec, or 306 * implementation defined ImageReader.</p> 307 */ enableSurfaceSharing()308 public void enableSurfaceSharing() { 309 mIsShared = true; 310 } 311 312 /** 313 * Check if this configuration has deferred configuration. 314 * 315 * <p>This will return true if the output configuration was constructed with surface deferred by 316 * {@link OutputConfiguration#OutputConfiguration(Size, Class)}. It will return true even after 317 * the deferred surface is added later by {@link OutputConfiguration#addSurface}.</p> 318 * 319 * @return true if this configuration has deferred surface. 320 * @hide 321 */ isDeferredConfiguration()322 public boolean isDeferredConfiguration() { 323 return mIsDeferredConfig; 324 } 325 326 /** 327 * Add a surface to this OutputConfiguration. 328 * 329 * <p> This function can be called before or after {@link 330 * CameraDevice#createCaptureSessionByOutputConfigurations}. If it's called after, 331 * the application must finalize the capture session with 332 * {@link CameraCaptureSession#finalizeOutputConfigurations}. 333 * </p> 334 * 335 * <p> If the OutputConfiguration was constructed with a deferred surface by {@link 336 * OutputConfiguration#OutputConfiguration(Size, Class)}, the added surface must be obtained 337 * from {@link android.view.SurfaceView} by calling {@link android.view.SurfaceHolder#getSurface}, 338 * or from {@link android.graphics.SurfaceTexture} via 339 * {@link android.view.Surface#Surface(android.graphics.SurfaceTexture)}).</p> 340 * 341 * <p> If the OutputConfiguration was constructed by other constructors, the added 342 * surface must be compatible with the existing surface. See {@link #enableSurfaceSharing} for 343 * details of compatible surfaces.</p> 344 * 345 * <p> If the OutputConfiguration already contains a Surface, {@link #enableSurfaceSharing} must 346 * be called before calling this function to add a new Surface.</p> 347 * 348 * @param surface The surface to be added. 349 * @throws IllegalArgumentException if the Surface is invalid, the Surface's 350 * dataspace/format doesn't match, or adding the Surface would exceed number of 351 * shared surfaces supported. 352 * @throws IllegalStateException if the Surface was already added to this OutputConfiguration, 353 * or if the OutputConfiguration is not shared and it already has a surface associated 354 * with it. 355 */ addSurface(@onNull Surface surface)356 public void addSurface(@NonNull Surface surface) { 357 checkNotNull(surface, "Surface must not be null"); 358 if (mSurfaces.contains(surface)) { 359 throw new IllegalStateException("Surface is already added!"); 360 } 361 if (mSurfaces.size() == 1 && !mIsShared) { 362 throw new IllegalStateException("Cannot have 2 surfaces for a non-sharing configuration"); 363 } 364 if (mSurfaces.size() + 1 > MAX_SURFACES_COUNT) { 365 throw new IllegalArgumentException("Exceeds maximum number of surfaces"); 366 } 367 368 // This will throw IAE is the surface was abandoned. 369 Size surfaceSize = SurfaceUtils.getSurfaceSize(surface); 370 if (!surfaceSize.equals(mConfiguredSize)) { 371 Log.w(TAG, "Added surface size " + surfaceSize + 372 " is different than pre-configured size " + mConfiguredSize + 373 ", the pre-configured size will be used."); 374 } 375 376 if (mConfiguredFormat != SurfaceUtils.getSurfaceFormat(surface)) { 377 throw new IllegalArgumentException("The format of added surface format doesn't match"); 378 } 379 380 // If the surface format is PRIVATE, do not enforce dataSpace because camera device may 381 // override it. 382 if (mConfiguredFormat != ImageFormat.PRIVATE && 383 mConfiguredDataspace != SurfaceUtils.getSurfaceDataspace(surface)) { 384 throw new IllegalArgumentException("The dataspace of added surface doesn't match"); 385 } 386 387 mSurfaces.add(surface); 388 } 389 390 /** 391 * Create a new {@link OutputConfiguration} instance with another {@link OutputConfiguration} 392 * instance. 393 * 394 * @param other Another {@link OutputConfiguration} instance to be copied. 395 * 396 * @hide 397 */ OutputConfiguration(@onNull OutputConfiguration other)398 public OutputConfiguration(@NonNull OutputConfiguration other) { 399 if (other == null) { 400 throw new IllegalArgumentException("OutputConfiguration shouldn't be null"); 401 } 402 403 this.mSurfaces = other.mSurfaces; 404 this.mRotation = other.mRotation; 405 this.mSurfaceGroupId = other.mSurfaceGroupId; 406 this.mSurfaceType = other.mSurfaceType; 407 this.mConfiguredDataspace = other.mConfiguredDataspace; 408 this.mConfiguredFormat = other.mConfiguredFormat; 409 this.mConfiguredSize = other.mConfiguredSize; 410 this.mConfiguredGenerationId = other.mConfiguredGenerationId; 411 this.mIsDeferredConfig = other.mIsDeferredConfig; 412 } 413 414 /** 415 * Create an OutputConfiguration from Parcel. 416 */ OutputConfiguration(@onNull Parcel source)417 private OutputConfiguration(@NonNull Parcel source) { 418 int rotation = source.readInt(); 419 int surfaceSetId = source.readInt(); 420 int surfaceType = source.readInt(); 421 int width = source.readInt(); 422 int height = source.readInt(); 423 boolean isDeferred = source.readInt() == 1; 424 ArrayList<Surface> surfaces = new ArrayList<Surface>(); 425 source.readTypedList(surfaces, Surface.CREATOR); 426 427 checkArgumentInRange(rotation, ROTATION_0, ROTATION_270, "Rotation constant"); 428 429 mSurfaceGroupId = surfaceSetId; 430 mRotation = rotation; 431 mSurfaces = surfaces; 432 mConfiguredSize = new Size(width, height); 433 mIsDeferredConfig = isDeferred; 434 mSurfaces = surfaces; 435 if (mSurfaces.size() > 0) { 436 mSurfaceType = SURFACE_TYPE_UNKNOWN; 437 mConfiguredFormat = SurfaceUtils.getSurfaceFormat(mSurfaces.get(0)); 438 mConfiguredDataspace = SurfaceUtils.getSurfaceDataspace(mSurfaces.get(0)); 439 mConfiguredGenerationId = mSurfaces.get(0).getGenerationId(); 440 } else { 441 mSurfaceType = surfaceType; 442 mConfiguredFormat = StreamConfigurationMap.imageFormatToInternal(ImageFormat.PRIVATE); 443 mConfiguredDataspace = 444 StreamConfigurationMap.imageFormatToDataspace(ImageFormat.PRIVATE); 445 mConfiguredGenerationId = 0; 446 } 447 } 448 449 /** 450 * Get the {@link Surface} associated with this {@link OutputConfiguration}. 451 * 452 * If more than one surface is associated with this {@link OutputConfiguration}, return the 453 * first one as specified in the constructor or {@link OutputConfiguration#addSurface}. 454 */ getSurface()455 public @Nullable Surface getSurface() { 456 if (mSurfaces.size() == 0) { 457 return null; 458 } 459 460 return mSurfaces.get(0); 461 } 462 463 /** 464 * Get the immutable list of surfaces associated with this {@link OutputConfiguration}. 465 * 466 * @return the list of surfaces associated with this {@link OutputConfiguration} as specified in 467 * the constructor and {@link OutputConfiguration#addSurface}. The list should not be modified. 468 */ 469 @NonNull getSurfaces()470 public List<Surface> getSurfaces() { 471 return Collections.unmodifiableList(mSurfaces); 472 } 473 474 /** 475 * Get the rotation associated with this {@link OutputConfiguration}. 476 * 477 * @return the rotation associated with this {@link OutputConfiguration}. 478 * Value will be one of ROTATION_[0, 90, 180, 270] 479 * 480 * @hide 481 */ 482 @SystemApi getRotation()483 public int getRotation() { 484 return mRotation; 485 } 486 487 /** 488 * Get the surface group ID associated with this {@link OutputConfiguration}. 489 * 490 * @return the surface group ID associated with this {@link OutputConfiguration}. 491 * The default value is {@value #SURFACE_GROUP_ID_NONE}. 492 */ getSurfaceGroupId()493 public int getSurfaceGroupId() { 494 return mSurfaceGroupId; 495 } 496 497 public static final Parcelable.Creator<OutputConfiguration> CREATOR = 498 new Parcelable.Creator<OutputConfiguration>() { 499 @Override 500 public OutputConfiguration createFromParcel(Parcel source) { 501 try { 502 OutputConfiguration outputConfiguration = new OutputConfiguration(source); 503 return outputConfiguration; 504 } catch (Exception e) { 505 Log.e(TAG, "Exception creating OutputConfiguration from parcel", e); 506 return null; 507 } 508 } 509 510 @Override 511 public OutputConfiguration[] newArray(int size) { 512 return new OutputConfiguration[size]; 513 } 514 }; 515 516 @Override describeContents()517 public int describeContents() { 518 return 0; 519 } 520 521 @Override writeToParcel(Parcel dest, int flags)522 public void writeToParcel(Parcel dest, int flags) { 523 if (dest == null) { 524 throw new IllegalArgumentException("dest must not be null"); 525 } 526 dest.writeInt(mRotation); 527 dest.writeInt(mSurfaceGroupId); 528 dest.writeInt(mSurfaceType); 529 dest.writeInt(mConfiguredSize.getWidth()); 530 dest.writeInt(mConfiguredSize.getHeight()); 531 dest.writeInt(mIsDeferredConfig ? 1 : 0); 532 dest.writeInt(mIsShared ? 1 : 0); 533 dest.writeTypedList(mSurfaces); 534 } 535 536 /** 537 * Check if this {@link OutputConfiguration} is equal to another {@link OutputConfiguration}. 538 * 539 * <p>Two output configurations are only equal if and only if the underlying surfaces, surface 540 * properties (width, height, format, dataspace) when the output configurations are created, 541 * and all other configuration parameters are equal. </p> 542 * 543 * @return {@code true} if the objects were equal, {@code false} otherwise 544 */ 545 @Override equals(Object obj)546 public boolean equals(Object obj) { 547 if (obj == null) { 548 return false; 549 } else if (this == obj) { 550 return true; 551 } else if (obj instanceof OutputConfiguration) { 552 final OutputConfiguration other = (OutputConfiguration) obj; 553 if (mRotation != other.mRotation || 554 !mConfiguredSize.equals(other.mConfiguredSize) || 555 mConfiguredFormat != other.mConfiguredFormat || 556 mSurfaceGroupId != other.mSurfaceGroupId || 557 mSurfaceType != other.mSurfaceType || 558 mIsDeferredConfig != other.mIsDeferredConfig || 559 mIsShared != other.mIsShared || 560 mConfiguredFormat != other.mConfiguredFormat || 561 mConfiguredDataspace != other.mConfiguredDataspace || 562 mConfiguredGenerationId != other.mConfiguredGenerationId) 563 return false; 564 565 int minLen = Math.min(mSurfaces.size(), other.mSurfaces.size()); 566 for (int i = 0; i < minLen; i++) { 567 if (mSurfaces.get(i) != other.mSurfaces.get(i)) 568 return false; 569 } 570 571 return true; 572 } 573 return false; 574 } 575 576 /** 577 * {@inheritDoc} 578 */ 579 @Override hashCode()580 public int hashCode() { 581 // Need ensure that the hashcode remains unchanged after adding a deferred surface. Otherwise 582 // the deferred output configuration will be lost in the camera streammap after the deferred 583 // surface is set. 584 if (mIsDeferredConfig) { 585 return HashCodeHelpers.hashCode( 586 mRotation, mConfiguredSize.hashCode(), mConfiguredFormat, mConfiguredDataspace, 587 mSurfaceGroupId, mSurfaceType, mIsShared ? 1 : 0); 588 } 589 590 return HashCodeHelpers.hashCode( 591 mRotation, mSurfaces.hashCode(), mConfiguredGenerationId, 592 mConfiguredSize.hashCode(), mConfiguredFormat, 593 mConfiguredDataspace, mSurfaceGroupId, mIsShared ? 1 : 0); 594 } 595 596 private static final String TAG = "OutputConfiguration"; 597 private ArrayList<Surface> mSurfaces; 598 private final int mRotation; 599 private final int mSurfaceGroupId; 600 // Surface source type, this is only used by the deferred surface configuration objects. 601 private final int mSurfaceType; 602 603 // The size, format, and dataspace of the surface when OutputConfiguration is created. 604 private final Size mConfiguredSize; 605 private final int mConfiguredFormat; 606 private final int mConfiguredDataspace; 607 // Surface generation ID to distinguish changes to Surface native internals 608 private final int mConfiguredGenerationId; 609 // Flag indicating if this config has deferred surface. 610 private final boolean mIsDeferredConfig; 611 // Flag indicating if this config has shared surfaces 612 private boolean mIsShared; 613 } 614