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