blob: 499fd56485783928f965a17e9ddb9b40d5d77e92 [file] [log] [blame]
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001/*
2 * Copyright (C) 2013 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
17package android.hardware.photography;
18
19/**
20 * A simple immutable class for describing the dimensions of camera image
21 * buffers.
22 */
23public final class Size {
24 /**
25 * Create a new immutable Size instance
26 *
Igor Murashkinb519cc52013-07-02 11:23:44 -070027 * @param width The width to store in the Size instance
28 * @param height The height to store in the Size instance
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080029 */
Igor Murashkind7bf1772013-07-12 18:01:31 -070030 public Size(int width, int height) {
Igor Murashkinb519cc52013-07-02 11:23:44 -070031 mWidth = width;
32 mHeight = height;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080033 }
34
35 public final int getWidth() {
36 return mWidth;
37 }
38
39 public final int getHeight() {
40 return mHeight;
41 }
42
Igor Murashkind7bf1772013-07-12 18:01:31 -070043 @Override
44 public boolean equals(Object obj) {
45 if (obj == null) {
46 return false;
47 }
48 if (this == obj) {
49 return true;
50 }
51 if (obj instanceof Size) {
52 Size other = (Size) obj;
53 return mWidth == other.mWidth && mHeight == other.mHeight;
54 }
55 return false;
56 }
57
58 @Override
59 public String toString() {
60 return mWidth + "x" + mHeight;
61 }
62
63 @Override
64 public int hashCode() {
65 final long INT_MASK = 0xffffffffL;
66
67 long asLong = INT_MASK & mWidth;
68 asLong <<= 32;
69
70 asLong |= (INT_MASK & mHeight);
71
72 return ((Long)asLong).hashCode();
73 }
74
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080075 private final int mWidth;
76 private final int mHeight;
77};