1d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown/* 2d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * Copyright (C) 2012 The Android Open Source Project 3d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * 4d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * Licensed under the Apache License, Version 2.0 (the "License"); 5d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * you may not use this file except in compliance with the License. 6d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * You may obtain a copy of the License at 7d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * 8d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * http://www.apache.org/licenses/LICENSE-2.0 9d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * 10d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * Unless required by applicable law or agreed to in writing, software 11d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * distributed under the License is distributed on an "AS IS" BASIS, 12d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * See the License for the specific language governing permissions and 14d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * limitations under the License. 15d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown */ 16d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown 174ccb823a9f62e57f9d221f83a97e82967e79a9e5Jeff Brownpackage android.hardware.display; 18d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown 19d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brownimport android.graphics.Rect; 20d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown 21d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown/** 22d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * Describes how the pixels of physical display device reflects the content of 23d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * a logical display. 24d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * <p> 25d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * This information is used by the input system to translate touch input from 26d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * physical display coordinates into logical display coordinates. 27d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown * </p> 284ccb823a9f62e57f9d221f83a97e82967e79a9e5Jeff Brown * 294ccb823a9f62e57f9d221f83a97e82967e79a9e5Jeff Brown * @hide Only for use within the system server. 30d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown */ 31d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brownpublic final class DisplayViewport { 32d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown // True if this viewport is valid. 33d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown public boolean valid; 34d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown 35d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown // The logical display id. 36d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown public int displayId; 37d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown 38d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown // The rotation applied to the physical coordinate system. 39d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown public int orientation; 40d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown 41d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown // The portion of the logical display that are presented on this physical display. 42d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown public final Rect logicalFrame = new Rect(); 43d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown 44d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown // The portion of the (rotated) physical display that shows the logical display contents. 45d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown // The relation between logical and physical frame defines how the coordinate system 46d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown // should be scaled or translated after rotation. 47d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown public final Rect physicalFrame = new Rect(); 48d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown 4983d616a9c7b9505153d258511eb5c16b552e268dJeff Brown // The full width and height of the display device, rotated in the same 5083d616a9c7b9505153d258511eb5c16b552e268dJeff Brown // manner as physicalFrame. This expresses the full native size of the display device. 5183d616a9c7b9505153d258511eb5c16b552e268dJeff Brown // The physical frame should usually fit within this area. 5283d616a9c7b9505153d258511eb5c16b552e268dJeff Brown public int deviceWidth; 5383d616a9c7b9505153d258511eb5c16b552e268dJeff Brown public int deviceHeight; 5483d616a9c7b9505153d258511eb5c16b552e268dJeff Brown 55d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown public void copyFrom(DisplayViewport viewport) { 56d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown valid = viewport.valid; 57d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown displayId = viewport.displayId; 58d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown orientation = viewport.orientation; 59d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown logicalFrame.set(viewport.logicalFrame); 60d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown physicalFrame.set(viewport.physicalFrame); 6183d616a9c7b9505153d258511eb5c16b552e268dJeff Brown deviceWidth = viewport.deviceWidth; 6283d616a9c7b9505153d258511eb5c16b552e268dJeff Brown deviceHeight = viewport.deviceHeight; 63d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown } 64d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown 65d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown // For debugging purposes. 66d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown @Override 67d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown public String toString() { 68d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown return "DisplayViewport{valid=" + valid 69d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown + ", displayId=" + displayId 70d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown + ", orientation=" + orientation 71d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown + ", logicalFrame=" + logicalFrame 72d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown + ", physicalFrame=" + physicalFrame 7383d616a9c7b9505153d258511eb5c16b552e268dJeff Brown + ", deviceWidth=" + deviceWidth 7483d616a9c7b9505153d258511eb5c16b552e268dJeff Brown + ", deviceHeight=" + deviceHeight 75d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown + "}"; 76d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown } 77d728bf514f257670fcb9aa22c6eaf97626072c93Jeff Brown} 78