Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 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 com.android.server.display; |
| 18 | |
| 19 | import android.graphics.Rect; |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 20 | import android.view.Display; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 21 | import android.view.DisplayInfo; |
| 22 | import android.view.Surface; |
| 23 | |
| 24 | import java.io.PrintWriter; |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 25 | import java.util.Arrays; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 26 | import java.util.List; |
| 27 | |
| 28 | import libcore.util.Objects; |
| 29 | |
| 30 | /** |
| 31 | * Describes how a logical display is configured. |
| 32 | * <p> |
| 33 | * At this time, we only support logical displays that are coupled to a particular |
| 34 | * primary display device from which the logical display derives its basic properties |
| 35 | * such as its size, density and refresh rate. |
| 36 | * </p><p> |
| 37 | * A logical display may be mirrored onto multiple display devices in addition to its |
| 38 | * primary display device. Note that the contents of a logical display may not |
| 39 | * always be visible, even on its primary display device, such as in the case where |
| 40 | * the primary display device is currently mirroring content from a different |
| 41 | * logical display. |
| 42 | * </p><p> |
| 43 | * This object is designed to encapsulate as much of the policy of logical |
| 44 | * displays as possible. The idea is to make it easy to implement new kinds of |
| 45 | * logical displays mostly by making local changes to this class. |
| 46 | * </p><p> |
| 47 | * Note: The display manager architecture does not actually require logical displays |
| 48 | * to be associated with any individual display device. Logical displays and |
| 49 | * display devices are orthogonal concepts. Some mapping will exist between |
| 50 | * logical displays and display devices but it can be many-to-many and |
| 51 | * and some might have no relation at all. |
| 52 | * </p><p> |
| 53 | * Logical displays are guarded by the {@link DisplayManagerService.SyncRoot} lock. |
| 54 | * </p> |
| 55 | */ |
| 56 | final class LogicalDisplay { |
| 57 | private final DisplayInfo mBaseDisplayInfo = new DisplayInfo(); |
| 58 | |
Jeff Brown | 8ec0943 | 2012-10-16 16:19:23 -0700 | [diff] [blame] | 59 | // The layer stack we use when the display has been blanked to prevent any |
| 60 | // of its content from appearing. |
| 61 | private static final int BLANK_LAYER_STACK = -1; |
| 62 | |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 63 | private final int mDisplayId; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 64 | private final int mLayerStack; |
| 65 | private DisplayInfo mOverrideDisplayInfo; // set by the window manager |
| 66 | private DisplayInfo mInfo; |
| 67 | |
| 68 | // The display device that this logical display is based on and which |
| 69 | // determines the base metrics that it uses. |
| 70 | private DisplayDevice mPrimaryDisplayDevice; |
| 71 | private DisplayDeviceInfo mPrimaryDisplayDeviceInfo; |
| 72 | |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 73 | // True if the logical display has unique content. |
| 74 | private boolean mHasContent; |
| 75 | |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 76 | // The pending requested refresh rate. 0 if no request is pending. |
| 77 | private float mRequestedRefreshRate; |
| 78 | |
Filip Gruszczynski | d2e8640 | 2015-02-19 13:05:03 -0800 | [diff] [blame] | 79 | // The display offsets to apply to the display projection. |
| 80 | private int mDisplayOffsetX; |
| 81 | private int mDisplayOffsetY; |
| 82 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 83 | // Temporary rectangle used when needed. |
Mathias Agopian | 63f1c43 | 2012-09-04 19:29:13 -0700 | [diff] [blame] | 84 | private final Rect mTempLayerStackRect = new Rect(); |
| 85 | private final Rect mTempDisplayRect = new Rect(); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 86 | |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 87 | public LogicalDisplay(int displayId, int layerStack, DisplayDevice primaryDisplayDevice) { |
| 88 | mDisplayId = displayId; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 89 | mLayerStack = layerStack; |
| 90 | mPrimaryDisplayDevice = primaryDisplayDevice; |
| 91 | } |
| 92 | |
| 93 | /** |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 94 | * Gets the logical display id of this logical display. |
| 95 | * |
| 96 | * @return The logical display id. |
| 97 | */ |
| 98 | public int getDisplayIdLocked() { |
| 99 | return mDisplayId; |
| 100 | } |
| 101 | |
| 102 | /** |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 103 | * Gets the primary display device associated with this logical display. |
| 104 | * |
| 105 | * @return The primary display device. |
| 106 | */ |
| 107 | public DisplayDevice getPrimaryDisplayDeviceLocked() { |
| 108 | return mPrimaryDisplayDevice; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Gets information about the logical display. |
| 113 | * |
| 114 | * @return The device info, which should be treated as immutable by the caller. |
| 115 | * The logical display should allocate a new display info object whenever |
| 116 | * the data changes. |
| 117 | */ |
| 118 | public DisplayInfo getDisplayInfoLocked() { |
| 119 | if (mInfo == null) { |
| 120 | mInfo = new DisplayInfo(); |
| 121 | if (mOverrideDisplayInfo != null) { |
| 122 | mInfo.copyFrom(mOverrideDisplayInfo); |
| 123 | mInfo.layerStack = mBaseDisplayInfo.layerStack; |
| 124 | mInfo.name = mBaseDisplayInfo.name; |
Wale Ogunwale | 361ca21 | 2014-11-20 11:42:38 -0800 | [diff] [blame] | 125 | mInfo.uniqueId = mBaseDisplayInfo.uniqueId; |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 126 | mInfo.state = mBaseDisplayInfo.state; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 127 | } else { |
| 128 | mInfo.copyFrom(mBaseDisplayInfo); |
| 129 | } |
| 130 | } |
| 131 | return mInfo; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Sets overridden logical display information from the window manager. |
| 136 | * This method can be used to adjust application insets, rotation, and other |
| 137 | * properties that the window manager takes care of. |
| 138 | * |
| 139 | * @param info The logical display information, may be null. |
| 140 | */ |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 141 | public boolean setDisplayInfoOverrideFromWindowManagerLocked(DisplayInfo info) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 142 | if (info != null) { |
| 143 | if (mOverrideDisplayInfo == null) { |
| 144 | mOverrideDisplayInfo = new DisplayInfo(info); |
| 145 | mInfo = null; |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 146 | return true; |
| 147 | } |
| 148 | if (!mOverrideDisplayInfo.equals(info)) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 149 | mOverrideDisplayInfo.copyFrom(info); |
| 150 | mInfo = null; |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 151 | return true; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 152 | } |
| 153 | } else if (mOverrideDisplayInfo != null) { |
| 154 | mOverrideDisplayInfo = null; |
| 155 | mInfo = null; |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 156 | return true; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 157 | } |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 158 | return false; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 159 | } |
| 160 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 161 | /** |
| 162 | * Returns true if the logical display is in a valid state. |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 163 | * This method should be checked after calling {@link #updateLocked} to handle the |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 164 | * case where a logical display should be removed because all of its associated |
| 165 | * display devices are gone or if it is otherwise no longer needed. |
| 166 | * |
| 167 | * @return True if the logical display is still valid. |
| 168 | */ |
| 169 | public boolean isValidLocked() { |
| 170 | return mPrimaryDisplayDevice != null; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Updates the state of the logical display based on the available display devices. |
| 175 | * The logical display might become invalid if it is attached to a display device |
| 176 | * that no longer exists. |
| 177 | * |
| 178 | * @param devices The list of all connected display devices. |
| 179 | */ |
| 180 | public void updateLocked(List<DisplayDevice> devices) { |
| 181 | // Nothing to update if already invalid. |
| 182 | if (mPrimaryDisplayDevice == null) { |
| 183 | return; |
| 184 | } |
| 185 | |
| 186 | // Check whether logical display has become invalid. |
| 187 | if (!devices.contains(mPrimaryDisplayDevice)) { |
| 188 | mPrimaryDisplayDevice = null; |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | // Bootstrap the logical display using its associated primary physical display. |
| 193 | // We might use more elaborate configurations later. It's possible that the |
| 194 | // configuration of several physical displays might be used to determine the |
| 195 | // logical display that they are sharing. (eg. Adjust size for pixel-perfect |
| 196 | // mirroring over HDMI.) |
| 197 | DisplayDeviceInfo deviceInfo = mPrimaryDisplayDevice.getDisplayDeviceInfoLocked(); |
| 198 | if (!Objects.equal(mPrimaryDisplayDeviceInfo, deviceInfo)) { |
| 199 | mBaseDisplayInfo.layerStack = mLayerStack; |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 200 | mBaseDisplayInfo.flags = 0; |
Jeff Brown | 77aebfd | 2012-10-01 21:07:03 -0700 | [diff] [blame] | 201 | if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_SUPPORTS_PROTECTED_BUFFERS) != 0) { |
| 202 | mBaseDisplayInfo.flags |= Display.FLAG_SUPPORTS_PROTECTED_BUFFERS; |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 203 | } |
Jeff Brown | f0681b3 | 2012-10-23 17:35:57 -0700 | [diff] [blame] | 204 | if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_SECURE) != 0) { |
| 205 | mBaseDisplayInfo.flags |= Display.FLAG_SECURE; |
| 206 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 207 | if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_PRIVATE) != 0) { |
| 208 | mBaseDisplayInfo.flags |= Display.FLAG_PRIVATE; |
| 209 | } |
Jeff Brown | 7d00aff | 2013-08-02 19:03:49 -0700 | [diff] [blame] | 210 | if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_PRESENTATION) != 0) { |
| 211 | mBaseDisplayInfo.flags |= Display.FLAG_PRESENTATION; |
| 212 | } |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 213 | mBaseDisplayInfo.type = deviceInfo.type; |
| 214 | mBaseDisplayInfo.address = deviceInfo.address; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 215 | mBaseDisplayInfo.name = deviceInfo.name; |
Wale Ogunwale | 361ca21 | 2014-11-20 11:42:38 -0800 | [diff] [blame] | 216 | mBaseDisplayInfo.uniqueId = deviceInfo.uniqueId; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 217 | mBaseDisplayInfo.appWidth = deviceInfo.width; |
| 218 | mBaseDisplayInfo.appHeight = deviceInfo.height; |
| 219 | mBaseDisplayInfo.logicalWidth = deviceInfo.width; |
| 220 | mBaseDisplayInfo.logicalHeight = deviceInfo.height; |
| 221 | mBaseDisplayInfo.rotation = Surface.ROTATION_0; |
| 222 | mBaseDisplayInfo.refreshRate = deviceInfo.refreshRate; |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 223 | mBaseDisplayInfo.supportedRefreshRates = Arrays.copyOf( |
| 224 | deviceInfo.supportedRefreshRates, deviceInfo.supportedRefreshRates.length); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 225 | mBaseDisplayInfo.logicalDensityDpi = deviceInfo.densityDpi; |
| 226 | mBaseDisplayInfo.physicalXDpi = deviceInfo.xDpi; |
| 227 | mBaseDisplayInfo.physicalYDpi = deviceInfo.yDpi; |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 228 | mBaseDisplayInfo.appVsyncOffsetNanos = deviceInfo.appVsyncOffsetNanos; |
| 229 | mBaseDisplayInfo.presentationDeadlineNanos = deviceInfo.presentationDeadlineNanos; |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 230 | mBaseDisplayInfo.state = deviceInfo.state; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 231 | mBaseDisplayInfo.smallestNominalAppWidth = deviceInfo.width; |
| 232 | mBaseDisplayInfo.smallestNominalAppHeight = deviceInfo.height; |
| 233 | mBaseDisplayInfo.largestNominalAppWidth = deviceInfo.width; |
| 234 | mBaseDisplayInfo.largestNominalAppHeight = deviceInfo.height; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 235 | mBaseDisplayInfo.ownerUid = deviceInfo.ownerUid; |
| 236 | mBaseDisplayInfo.ownerPackageName = deviceInfo.ownerPackageName; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 237 | |
| 238 | mPrimaryDisplayDeviceInfo = deviceInfo; |
| 239 | mInfo = null; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Applies the layer stack and transformation to the given display device |
| 245 | * so that it shows the contents of this logical display. |
| 246 | * |
| 247 | * We know that the given display device is only ever showing the contents of |
| 248 | * a single logical display, so this method is expected to blow away all of its |
| 249 | * transformation properties to make it happen regardless of what the |
| 250 | * display device was previously showing. |
| 251 | * |
| 252 | * The caller must have an open Surface transaction. |
| 253 | * |
| 254 | * The display device may not be the primary display device, in the case |
| 255 | * where the display is being mirrored. |
| 256 | * |
| 257 | * @param device The display device to modify. |
Jeff Brown | 8ec0943 | 2012-10-16 16:19:23 -0700 | [diff] [blame] | 258 | * @param isBlanked True if the device is being blanked. |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 259 | */ |
Jeff Brown | 8ec0943 | 2012-10-16 16:19:23 -0700 | [diff] [blame] | 260 | public void configureDisplayInTransactionLocked(DisplayDevice device, |
| 261 | boolean isBlanked) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 262 | final DisplayInfo displayInfo = getDisplayInfoLocked(); |
| 263 | final DisplayDeviceInfo displayDeviceInfo = device.getDisplayDeviceInfoLocked(); |
| 264 | |
| 265 | // Set the layer stack. |
Jeff Brown | 8ec0943 | 2012-10-16 16:19:23 -0700 | [diff] [blame] | 266 | device.setLayerStackInTransactionLocked(isBlanked ? BLANK_LAYER_STACK : mLayerStack); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 267 | |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 268 | // Set the refresh rate |
| 269 | device.requestRefreshRateLocked(mRequestedRefreshRate); |
| 270 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 271 | // Set the viewport. |
| 272 | // This is the area of the logical display that we intend to show on the |
| 273 | // display device. For now, it is always the full size of the logical display. |
Mathias Agopian | 63f1c43 | 2012-09-04 19:29:13 -0700 | [diff] [blame] | 274 | mTempLayerStackRect.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 275 | |
| 276 | // Set the orientation. |
| 277 | // The orientation specifies how the physical coordinate system of the display |
| 278 | // is rotated when the contents of the logical display are rendered. |
| 279 | int orientation = Surface.ROTATION_0; |
Scott Anderson | 8786ed9 | 2013-11-01 13:27:39 -0700 | [diff] [blame] | 280 | if ((displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 281 | orientation = displayInfo.rotation; |
| 282 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 283 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 284 | // Apply the physical rotation of the display device itself. |
| 285 | orientation = (orientation + displayDeviceInfo.rotation) % 4; |
| 286 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 287 | // Set the frame. |
| 288 | // The frame specifies the rotated physical coordinates into which the viewport |
| 289 | // is mapped. We need to take care to preserve the aspect ratio of the viewport. |
| 290 | // Currently we maximize the area to fill the display, but we could try to be |
| 291 | // more clever and match resolutions. |
| 292 | boolean rotated = (orientation == Surface.ROTATION_90 |
| 293 | || orientation == Surface.ROTATION_270); |
| 294 | int physWidth = rotated ? displayDeviceInfo.height : displayDeviceInfo.width; |
| 295 | int physHeight = rotated ? displayDeviceInfo.width : displayDeviceInfo.height; |
| 296 | |
| 297 | // Determine whether the width or height is more constrained to be scaled. |
| 298 | // physWidth / displayInfo.logicalWidth => letter box |
| 299 | // or physHeight / displayInfo.logicalHeight => pillar box |
| 300 | // |
| 301 | // We avoid a division (and possible floating point imprecision) here by |
| 302 | // multiplying the fractions by the product of their denominators before |
| 303 | // comparing them. |
Mathias Agopian | 63f1c43 | 2012-09-04 19:29:13 -0700 | [diff] [blame] | 304 | int displayRectWidth, displayRectHeight; |
Jeff Brown | d46747a | 2015-04-15 19:02:36 -0700 | [diff] [blame] | 305 | if ((displayInfo.flags & Display.FLAG_SCALING_DISABLED) != 0) { |
| 306 | displayRectWidth = displayInfo.logicalWidth; |
| 307 | displayRectHeight = displayInfo.logicalHeight; |
| 308 | } else if (physWidth * displayInfo.logicalHeight |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 309 | < physHeight * displayInfo.logicalWidth) { |
| 310 | // Letter box. |
Mathias Agopian | 63f1c43 | 2012-09-04 19:29:13 -0700 | [diff] [blame] | 311 | displayRectWidth = physWidth; |
| 312 | displayRectHeight = displayInfo.logicalHeight * physWidth / displayInfo.logicalWidth; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 313 | } else { |
| 314 | // Pillar box. |
Mathias Agopian | 63f1c43 | 2012-09-04 19:29:13 -0700 | [diff] [blame] | 315 | displayRectWidth = displayInfo.logicalWidth * physHeight / displayInfo.logicalHeight; |
| 316 | displayRectHeight = physHeight; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 317 | } |
Mathias Agopian | 63f1c43 | 2012-09-04 19:29:13 -0700 | [diff] [blame] | 318 | int displayRectTop = (physHeight - displayRectHeight) / 2; |
| 319 | int displayRectLeft = (physWidth - displayRectWidth) / 2; |
| 320 | mTempDisplayRect.set(displayRectLeft, displayRectTop, |
| 321 | displayRectLeft + displayRectWidth, displayRectTop + displayRectHeight); |
| 322 | |
Filip Gruszczynski | d2e8640 | 2015-02-19 13:05:03 -0800 | [diff] [blame] | 323 | mTempDisplayRect.left += mDisplayOffsetX; |
| 324 | mTempDisplayRect.right += mDisplayOffsetX; |
| 325 | mTempDisplayRect.top += mDisplayOffsetY; |
| 326 | mTempDisplayRect.bottom += mDisplayOffsetY; |
Mathias Agopian | 63f1c43 | 2012-09-04 19:29:13 -0700 | [diff] [blame] | 327 | device.setProjectionInTransactionLocked(orientation, mTempLayerStackRect, mTempDisplayRect); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 330 | /** |
| 331 | * Returns true if the logical display has unique content. |
| 332 | * <p> |
| 333 | * If the display has unique content then we will try to ensure that it is |
| 334 | * visible on at least its primary display device. Otherwise we will ignore the |
| 335 | * logical display and perhaps show mirrored content on the primary display device. |
| 336 | * </p> |
| 337 | * |
| 338 | * @return True if the display has unique content. |
| 339 | */ |
| 340 | public boolean hasContentLocked() { |
| 341 | return mHasContent; |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * Sets whether the logical display has unique content. |
| 346 | * |
| 347 | * @param hasContent True if the display has unique content. |
| 348 | */ |
| 349 | public void setHasContentLocked(boolean hasContent) { |
| 350 | mHasContent = hasContent; |
| 351 | } |
| 352 | |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 353 | /** |
| 354 | * Requests the given refresh rate. |
| 355 | * @param requestedRefreshRate The desired refresh rate. |
| 356 | */ |
| 357 | public void setRequestedRefreshRateLocked(float requestedRefreshRate) { |
| 358 | mRequestedRefreshRate = requestedRefreshRate; |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * Gets the pending requested refresh rate. |
| 363 | * |
| 364 | * @return The pending refresh rate requested |
| 365 | */ |
| 366 | public float getRequestedRefreshRateLocked() { |
| 367 | return mRequestedRefreshRate; |
| 368 | } |
| 369 | |
Filip Gruszczynski | d2e8640 | 2015-02-19 13:05:03 -0800 | [diff] [blame] | 370 | /** |
| 371 | * Gets the burn-in offset in X. |
| 372 | */ |
| 373 | public int getDisplayOffsetXLocked() { |
| 374 | return mDisplayOffsetX; |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * Gets the burn-in offset in Y. |
| 379 | */ |
| 380 | public int getDisplayOffsetYLocked() { |
| 381 | return mDisplayOffsetY; |
| 382 | } |
| 383 | |
| 384 | /** |
| 385 | * Sets the burn-in offsets. |
| 386 | */ |
| 387 | public void setDisplayOffsetsLocked(int x, int y) { |
| 388 | mDisplayOffsetX = x; |
| 389 | mDisplayOffsetY = y; |
| 390 | } |
| 391 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 392 | public void dumpLocked(PrintWriter pw) { |
Jeff Brown | c272664 | 2012-10-02 16:17:31 -0700 | [diff] [blame] | 393 | pw.println("mDisplayId=" + mDisplayId); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 394 | pw.println("mLayerStack=" + mLayerStack); |
Jeff Brown | c272664 | 2012-10-02 16:17:31 -0700 | [diff] [blame] | 395 | pw.println("mHasContent=" + mHasContent); |
Filip Gruszczynski | d2e8640 | 2015-02-19 13:05:03 -0800 | [diff] [blame] | 396 | pw.println("mRequestedRefreshRate=" + mRequestedRefreshRate); |
| 397 | pw.println("mDisplayOffset=(" + mDisplayOffsetX + ", " + mDisplayOffsetY + ")"); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 398 | pw.println("mPrimaryDisplayDevice=" + (mPrimaryDisplayDevice != null ? |
| 399 | mPrimaryDisplayDevice.getNameLocked() : "null")); |
| 400 | pw.println("mBaseDisplayInfo=" + mBaseDisplayInfo); |
| 401 | pw.println("mOverrideDisplayInfo=" + mOverrideDisplayInfo); |
| 402 | } |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 403 | } |