blob: 145a217dbd273521f0eb423fa34088a0e1b06f15 [file] [log] [blame]
Jeff Browna506a6e2013-06-04 00:02:38 -07001/*
2 * Copyright (C) 2013 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 */
16package android.hardware.display;
17
18import android.os.IBinder;
19import android.view.Display;
20
21/**
22 * Represents a virtual display.
23 *
24 * @see DisplayManager#createPrivateVirtualDisplay
25 */
26public final class VirtualDisplay {
27 private final DisplayManagerGlobal mGlobal;
28 private final Display mDisplay;
29 private IBinder mToken;
30
31 VirtualDisplay(DisplayManagerGlobal global, Display display, IBinder token) {
32 mGlobal = global;
33 mDisplay = display;
34 mToken = token;
35 }
36
37 /**
38 * Gets the virtual display.
39 */
40 public Display getDisplay() {
41 return mDisplay;
42 }
43
44 /**
45 * Releases the virtual display and destroys its underlying surface.
46 * <p>
47 * All remaining windows on the virtual display will be forcibly removed
48 * as part of releasing the virtual display.
49 * </p>
50 */
51 public void release() {
52 if (mToken != null) {
53 mGlobal.releaseVirtualDisplay(mToken);
54 mToken = null;
55 }
56 }
57
58 @Override
59 public String toString() {
60 return "VirtualDisplay{display=" + mDisplay + ", token=" + mToken + "}";
61 }
62}