DisplayContent.java revision 59c009776dae5ccbdfb93d7151ff2065ca049dc3
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.wm; 18 19import android.view.DisplayInfo; 20 21import java.io.PrintWriter; 22import java.util.ArrayList; 23 24class DisplayContentList extends ArrayList<DisplayContent> { 25} 26 27/** 28 * Utility class for keeping track of the WindowStates and other pertinent contents of a 29 * particular Display. 30 * 31 * IMPORTANT: No method from this class should ever be used without holding 32 * WindowManagerService.mWindowMap. 33 */ 34class DisplayContent { 35 36 /** Unique identifier of this stack. */ 37 private final int mDisplayId; 38 39 /** Z-ordered (bottom-most first) list of all Window objects. Assigned to an element 40 * from mDisplayWindows; */ 41 private WindowList mWindows = new WindowList(); 42 43 44 // This protects the following display size properties, so that 45 // getDisplaySize() doesn't need to acquire the global lock. This is 46 // needed because the window manager sometimes needs to use ActivityThread 47 // while it has its global state locked (for example to load animation 48 // resources), but the ActivityThread also needs get the current display 49 // size sometimes when it has its package lock held. 50 // 51 // These will only be modified with both mWindowMap and mDisplaySizeLock 52 // held (in that order) so the window manager doesn't need to acquire this 53 // lock when needing these values in its normal operation. 54 final Object mDisplaySizeLock = new Object(); 55 int mInitialDisplayWidth = 0; 56 int mInitialDisplayHeight = 0; 57 int mBaseDisplayWidth = 0; 58 int mBaseDisplayHeight = 0; 59 final DisplayInfo mDisplayInfo = new DisplayInfo(); 60 61 DisplayContent(final int displayId) { 62 mDisplayId = displayId; 63 } 64 65 int getDisplayId() { 66 return mDisplayId; 67 } 68 69 WindowList getWindowList() { 70 return mWindows; 71 } 72 73 DisplayInfo getDisplayInfo() { 74 return mDisplayInfo; 75 } 76 77 public void dump(PrintWriter pw) { 78 pw.print(" Display: mDisplayId="); pw.println(mDisplayId); 79 pw.print(" init="); pw.print(mInitialDisplayWidth); pw.print("x"); 80 pw.print(mInitialDisplayHeight); 81 if (mInitialDisplayWidth != mBaseDisplayWidth 82 || mInitialDisplayHeight != mBaseDisplayHeight) { 83 pw.print(" base="); 84 pw.print(mBaseDisplayWidth); pw.print("x"); pw.print(mBaseDisplayHeight); 85 } 86 if (mInitialDisplayWidth != mDisplayInfo.logicalWidth 87 || mInitialDisplayHeight != mDisplayInfo.logicalHeight) { 88 pw.print(" init="); pw.print(mInitialDisplayWidth); 89 pw.print("x"); pw.print(mInitialDisplayHeight); 90 } 91 pw.print(" cur="); 92 pw.print(mDisplayInfo.logicalWidth); 93 pw.print("x"); pw.print(mDisplayInfo.logicalHeight); 94 pw.print(" app="); 95 pw.print(mDisplayInfo.appWidth); 96 pw.print("x"); pw.print(mDisplayInfo.appHeight); 97 pw.print(" rng="); pw.print(mDisplayInfo.smallestNominalAppWidth); 98 pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight); 99 pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth); 100 pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight); 101 pw.println(); 102 } 103} 104