Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(697)

Side by Side Diff: ui/android/java/src/org/chromium/ui/display/VirtualDisplayAndroid.java

Issue 2523273002: Implement Virtual Display class for Android. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/android/java/src/org/chromium/ui/display/DisplayAndroidManager.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.ui.display;
6
7 import android.graphics.Point;
8
9 /**
10 * An instance of DisplayAndroid not associated with any physical display.
11 */
12 public class VirtualDisplayAndroid extends DisplayAndroid {
amp 2016/11/23 19:18:09 Would it be possible to add an 'isVirtual' field t
mthiesse 2016/11/23 19:22:23 Preferably, virtual vs. physical displays would be
amp 2016/11/23 19:34:34 I agree that ideally no code would need to know th
mthiesse 2016/11/23 19:44:51 I really don't think we should convey VR-ness or w
amp 2016/11/23 20:09:22 I'm interested in other solutions if possible. An
13 private final int mDisplayId;
14 private Point mSize;
15 private Point mPhysicalSize;
16 private float mDipScale;
17 private int mBitsPerPixel;
18 private int mBitsPerComponent;
19 private int mRotation;
20
21 /**
22 * @param displayId Display ID for this virtual display.
23 */
24 public static VirtualDisplayAndroid createVirtualDisplay(int displayId) {
25 VirtualDisplayAndroid display = new VirtualDisplayAndroid(displayId);
26 getManager().addVirtualDisplay(display);
27 return display;
28 }
29
30 private VirtualDisplayAndroid(int displayId) {
31 mDisplayId = displayId;
32 }
33
34 /**
35 * @param other Sets the properties of this display to those of the other di splay.
36 */
37 public void setTo(DisplayAndroid other) {
38 update(new Point(other.getDisplayWidth(), other.getDisplayHeight()),
39 new Point(other.getPhysicalDisplayWidth(), other.getPhysicalDisp layHeight()),
40 other.getDipScale(), other.getBitsPerPixel(),
41 other.getBitsPerComponent(), other.getRotation());
42 }
43
44 /**
45 * Update the display to the provided parameters. Null values leave the para meter unchanged.
46 */
47 public void update(Point size, Point physicalSize, Float dipScale, Integer b itsPerPixel,
48 Integer bitsPerComponent, Integer rotation) {
49 boolean dipScaleChanged = dipScale != null && mDipScale != dipScale;
50 boolean rotationChanged = rotation != null && mRotation != rotation;
51 mSize = size == null ? mSize : size;
52 mPhysicalSize = size == null ? mPhysicalSize : physicalSize;
53 mDipScale = size == null ? mDipScale : dipScale;
54 mBitsPerPixel = size == null ? mBitsPerPixel : bitsPerPixel;
55 mBitsPerComponent = size == null ? mBitsPerComponent : bitsPerComponent;
56 mRotation = size == null ? mRotation : rotation;
57 getManager().updateDisplayOnNativeSide(this);
58 notifyObservers(dipScaleChanged, rotationChanged);
59 }
60
61 private void notifyObservers(boolean dipScaleChanged, boolean rotationChange d) {
62 if (!dipScaleChanged && !rotationChanged) return;
63 DisplayAndroidObserver[] observers = getObservers();
64 for (DisplayAndroidObserver o : observers) {
65 if (dipScaleChanged) o.onDIPScaleChanged(mDipScale);
66 if (rotationChanged) o.onRotationChanged(mRotation);
67 }
68 }
69
70 @Override
71 public int getSdkDisplayId() {
72 return mDisplayId;
73 }
74
75 @Override
76 public int getDisplayHeight() {
77 return mSize.y;
78 }
79
80 @Override
81 public int getDisplayWidth() {
82 return mSize.x;
83 }
84
85 @Override
86 public int getPhysicalDisplayHeight() {
87 return mPhysicalSize.y;
88 }
89
90 @Override
91 public int getPhysicalDisplayWidth() {
92 return mPhysicalSize.x;
93 }
94
95 @Override
96 public int getRotation() {
97 return mRotation;
98 }
99
100 @Override
101 public float getDipScale() {
102 return mDipScale;
103 }
104
105 @Override
106 /* package */ int getBitsPerPixel() {
107 return mBitsPerPixel;
108 }
109
110 @Override
111 /* package */ int getBitsPerComponent() {
112 return mBitsPerComponent;
113 }
114
115 /**
116 * Removes this Virtual Display from the DisplayManger.
117 */
118 public void destroy() {
119 getManager().removeVirtualDisplay(this);
120 }
121 }
OLDNEW
« no previous file with comments | « ui/android/java/src/org/chromium/ui/display/DisplayAndroidManager.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698