1 /*
2  * Copyright (C) 2012 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 android.hardware.display;
18 
19 import android.graphics.Rect;
20 
21 /**
22  * Describes how the pixels of physical display device reflects the content of
23  * a logical display.
24  * <p>
25  * This information is used by the input system to translate touch input from
26  * physical display coordinates into logical display coordinates.
27  * </p>
28  *
29  * @hide Only for use within the system server.
30  */
31 public final class DisplayViewport {
32     // True if this viewport is valid.
33     public boolean valid;
34 
35     // The logical display id.
36     public int displayId;
37 
38     // The rotation applied to the physical coordinate system.
39     public int orientation;
40 
41     // The portion of the logical display that are presented on this physical display.
42     public final Rect logicalFrame = new Rect();
43 
44     // The portion of the (rotated) physical display that shows the logical display contents.
45     // The relation between logical and physical frame defines how the coordinate system
46     // should be scaled or translated after rotation.
47     public final Rect physicalFrame = new Rect();
48 
49     // The full width and height of the display device, rotated in the same
50     // manner as physicalFrame.  This expresses the full native size of the display device.
51     // The physical frame should usually fit within this area.
52     public int deviceWidth;
53     public int deviceHeight;
54 
copyFrom(DisplayViewport viewport)55     public void copyFrom(DisplayViewport viewport) {
56         valid = viewport.valid;
57         displayId = viewport.displayId;
58         orientation = viewport.orientation;
59         logicalFrame.set(viewport.logicalFrame);
60         physicalFrame.set(viewport.physicalFrame);
61         deviceWidth = viewport.deviceWidth;
62         deviceHeight = viewport.deviceHeight;
63     }
64 
65     // For debugging purposes.
66     @Override
toString()67     public String toString() {
68         return "DisplayViewport{valid=" + valid
69                 + ", displayId=" + displayId
70                 + ", orientation=" + orientation
71                 + ", logicalFrame=" + logicalFrame
72                 + ", physicalFrame=" + physicalFrame
73                 + ", deviceWidth=" + deviceWidth
74                 + ", deviceHeight=" + deviceHeight
75                 + "}";
76     }
77 }
78