blob: a8854cfe7995ded2cc2e643d50a1ec13b089199d [file] [log] [blame]
Craig Mautner59c00972012-07-30 12:10:24 -07001/*
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
Craig Mautner4f67ba62012-08-02 11:23:00 -070021import com.android.server.display.DisplayManagerService;
22
Craig Mautner59c00972012-07-30 12:10:24 -070023import java.io.PrintWriter;
24import java.util.ArrayList;
25
26class DisplayContentList extends ArrayList<DisplayContent> {
27}
28
29/**
30 * Utility class for keeping track of the WindowStates and other pertinent contents of a
31 * particular Display.
32 *
33 * IMPORTANT: No method from this class should ever be used without holding
34 * WindowManagerService.mWindowMap.
35 */
36class DisplayContent {
37
38 /** Unique identifier of this stack. */
39 private final int mDisplayId;
40
41 /** Z-ordered (bottom-most first) list of all Window objects. Assigned to an element
42 * from mDisplayWindows; */
43 private WindowList mWindows = new WindowList();
44
45
46 // This protects the following display size properties, so that
47 // getDisplaySize() doesn't need to acquire the global lock. This is
48 // needed because the window manager sometimes needs to use ActivityThread
49 // while it has its global state locked (for example to load animation
50 // resources), but the ActivityThread also needs get the current display
51 // size sometimes when it has its package lock held.
52 //
53 // These will only be modified with both mWindowMap and mDisplaySizeLock
54 // held (in that order) so the window manager doesn't need to acquire this
55 // lock when needing these values in its normal operation.
56 final Object mDisplaySizeLock = new Object();
57 int mInitialDisplayWidth = 0;
58 int mInitialDisplayHeight = 0;
Dianne Hackborndde331c2012-08-03 14:01:57 -070059 int mInitialDisplayDensity = 0;
Craig Mautner59c00972012-07-30 12:10:24 -070060 int mBaseDisplayWidth = 0;
61 int mBaseDisplayHeight = 0;
Dianne Hackborndde331c2012-08-03 14:01:57 -070062 int mBaseDisplayDensity = 0;
Craig Mautner4f67ba62012-08-02 11:23:00 -070063 final DisplayManagerService mDisplayManager;
Craig Mautner59c00972012-07-30 12:10:24 -070064 final DisplayInfo mDisplayInfo = new DisplayInfo();
65
Craig Mautner4f67ba62012-08-02 11:23:00 -070066 DisplayContent(DisplayManagerService displayManager, final int displayId) {
67 mDisplayManager = displayManager;
Craig Mautner59c00972012-07-30 12:10:24 -070068 mDisplayId = displayId;
Craig Mautner4f67ba62012-08-02 11:23:00 -070069 displayManager.getDisplayInfo(displayId, mDisplayInfo);
Craig Mautner59c00972012-07-30 12:10:24 -070070 }
71
72 int getDisplayId() {
73 return mDisplayId;
74 }
75
76 WindowList getWindowList() {
77 return mWindows;
78 }
79
80 DisplayInfo getDisplayInfo() {
81 return mDisplayInfo;
82 }
83
84 public void dump(PrintWriter pw) {
85 pw.print(" Display: mDisplayId="); pw.println(mDisplayId);
86 pw.print(" init="); pw.print(mInitialDisplayWidth); pw.print("x");
Dianne Hackborndde331c2012-08-03 14:01:57 -070087 pw.print(mInitialDisplayHeight); pw.print(" "); pw.print(mInitialDisplayDensity);
88 pw.print("dpi");
Craig Mautner59c00972012-07-30 12:10:24 -070089 if (mInitialDisplayWidth != mBaseDisplayWidth
Dianne Hackborndde331c2012-08-03 14:01:57 -070090 || mInitialDisplayHeight != mBaseDisplayHeight
91 || mInitialDisplayDensity != mBaseDisplayDensity) {
Craig Mautner59c00972012-07-30 12:10:24 -070092 pw.print(" base=");
93 pw.print(mBaseDisplayWidth); pw.print("x"); pw.print(mBaseDisplayHeight);
Dianne Hackborndde331c2012-08-03 14:01:57 -070094 pw.print(" "); pw.print(mBaseDisplayDensity); pw.print("dpi");
Craig Mautner59c00972012-07-30 12:10:24 -070095 }
96 pw.print(" cur=");
97 pw.print(mDisplayInfo.logicalWidth);
98 pw.print("x"); pw.print(mDisplayInfo.logicalHeight);
99 pw.print(" app=");
100 pw.print(mDisplayInfo.appWidth);
101 pw.print("x"); pw.print(mDisplayInfo.appHeight);
102 pw.print(" rng="); pw.print(mDisplayInfo.smallestNominalAppWidth);
103 pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight);
104 pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
105 pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
106 pw.println();
107 }
108}