PageRenderTime 28ms CodeModel.GetById 13ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 1ms

/services/java/com/android/server/display/DisplayViewport.java

https://github.com/aizuzi/platform_frameworks_base
Java | 75 lines | 31 code | 10 blank | 34 comment | 0 complexity | 09de2b18e9709da951df89f2b86102e4 MD5 | raw file
 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
17package com.android.server.display;
18
19import 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 */
29public final class DisplayViewport {
30    // True if this viewport is valid.
31    public boolean valid;
32
33    // The logical display id.
34    public int displayId;
35
36    // The rotation applied to the physical coordinate system.
37    public int orientation;
38
39    // The portion of the logical display that are presented on this physical display.
40    public final Rect logicalFrame = new Rect();
41
42    // The portion of the (rotated) physical display that shows the logical display contents.
43    // The relation between logical and physical frame defines how the coordinate system
44    // should be scaled or translated after rotation.
45    public final Rect physicalFrame = new Rect();
46
47    // The full width and height of the display device, rotated in the same
48    // manner as physicalFrame.  This expresses the full native size of the display device.
49    // The physical frame should usually fit within this area.
50    public int deviceWidth;
51    public int deviceHeight;
52
53    public void copyFrom(DisplayViewport viewport) {
54        valid = viewport.valid;
55        displayId = viewport.displayId;
56        orientation = viewport.orientation;
57        logicalFrame.set(viewport.logicalFrame);
58        physicalFrame.set(viewport.physicalFrame);
59        deviceWidth = viewport.deviceWidth;
60        deviceHeight = viewport.deviceHeight;
61    }
62
63    // For debugging purposes.
64    @Override
65    public String toString() {
66        return "DisplayViewport{valid=" + valid
67                + ", displayId=" + displayId
68                + ", orientation=" + orientation
69                + ", logicalFrame=" + logicalFrame
70                + ", physicalFrame=" + physicalFrame
71                + ", deviceWidth=" + deviceWidth
72                + ", deviceHeight=" + deviceHeight
73                + "}";
74    }
75}