| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.ui.display; | 5 package org.chromium.ui.display; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.content.ComponentCallbacks; | 8 import android.content.ComponentCallbacks; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.res.Configuration; | 10 import android.content.res.Configuration; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // The DisplayManager API observers all display updates, so in theory it
should not matter | 207 // The DisplayManager API observers all display updates, so in theory it
should not matter |
| 208 // which context is used to obtain it. If this turns out not to be true
in practice, it's | 208 // which context is used to obtain it. If this turns out not to be true
in practice, it's |
| 209 // possible register from all context used though quite complex. | 209 // possible register from all context used though quite complex. |
| 210 return ContextUtils.getApplicationContext(); | 210 return ContextUtils.getApplicationContext(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 private static DisplayManager getDisplayManager() { | 213 private static DisplayManager getDisplayManager() { |
| 214 return (DisplayManager) getContext().getSystemService(Context.DISPLAY_SE
RVICE); | 214 return (DisplayManager) getContext().getSystemService(Context.DISPLAY_SE
RVICE); |
| 215 } | 215 } |
| 216 | 216 |
| 217 private static void updateDeviceDisplayInfo() { | 217 private void updateDeviceDisplayInfo() { |
| 218 if (mNativePointer == 0) return; |
| 218 DeviceDisplayInfo.create(getContext()).updateNativeSharedDisplayInfo(); | 219 DeviceDisplayInfo.create(getContext()).updateNativeSharedDisplayInfo(); |
| 219 } | 220 } |
| 220 | 221 |
| 221 @CalledByNative | 222 @CalledByNative |
| 222 private static void onNativeSideCreated(long nativePointer) { | 223 private static void onNativeSideCreated(long nativePointer) { |
| 223 DisplayAndroidManager singleton = getInstance(); | 224 DisplayAndroidManager singleton = getInstance(); |
| 224 singleton.setNativePointer(nativePointer); | 225 singleton.setNativePointer(nativePointer); |
| 225 } | 226 } |
| 226 | 227 |
| 227 private DisplayAndroidManager() {} | 228 private DisplayAndroidManager() {} |
| (...skipping 22 matching lines...) Expand all Loading... |
| 250 mBackend.startListening(); | 251 mBackend.startListening(); |
| 251 } | 252 } |
| 252 | 253 |
| 253 private void setNativePointer(long nativePointer) { | 254 private void setNativePointer(long nativePointer) { |
| 254 mNativePointer = nativePointer; | 255 mNativePointer = nativePointer; |
| 255 nativeSetPrimaryDisplayId(mNativePointer, mMainSdkDisplayId); | 256 nativeSetPrimaryDisplayId(mNativePointer, mMainSdkDisplayId); |
| 256 | 257 |
| 257 for (int i = 0; i < mIdMap.size(); ++i) { | 258 for (int i = 0; i < mIdMap.size(); ++i) { |
| 258 updateDisplayOnNativeSide(mIdMap.valueAt(i)); | 259 updateDisplayOnNativeSide(mIdMap.valueAt(i)); |
| 259 } | 260 } |
| 261 updateDeviceDisplayInfo(); |
| 260 } | 262 } |
| 261 | 263 |
| 262 /* package */ DisplayAndroid getDisplayAndroid(Display display) { | 264 /* package */ DisplayAndroid getDisplayAndroid(Display display) { |
| 263 int sdkDisplayId = display.getDisplayId(); | 265 int sdkDisplayId = display.getDisplayId(); |
| 264 DisplayAndroid displayAndroid = mIdMap.get(sdkDisplayId); | 266 DisplayAndroid displayAndroid = mIdMap.get(sdkDisplayId); |
| 265 if (displayAndroid == null) { | 267 if (displayAndroid == null) { |
| 266 displayAndroid = addDisplay(display); | 268 displayAndroid = addDisplay(display); |
| 267 } | 269 } |
| 268 return displayAndroid; | 270 return displayAndroid; |
| 269 } | 271 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 294 displayAndroid.getBitsPerPixel(), displayAndroid.getBitsPerCompo
nent()); | 296 displayAndroid.getBitsPerPixel(), displayAndroid.getBitsPerCompo
nent()); |
| 295 } | 297 } |
| 296 | 298 |
| 297 private native void nativeUpdateDisplay(long nativeDisplayAndroidManager, in
t sdkDisplayId, | 299 private native void nativeUpdateDisplay(long nativeDisplayAndroidManager, in
t sdkDisplayId, |
| 298 int physicalWidth, int physicalHeight, int width, int height, float
dipScale, | 300 int physicalWidth, int physicalHeight, int width, int height, float
dipScale, |
| 299 int rotationDegrees, int bitsPerPixel, int bitsPerComponent); | 301 int rotationDegrees, int bitsPerPixel, int bitsPerComponent); |
| 300 private native void nativeRemoveDisplay(long nativeDisplayAndroidManager, in
t sdkDisplayId); | 302 private native void nativeRemoveDisplay(long nativeDisplayAndroidManager, in
t sdkDisplayId); |
| 301 private native void nativeSetPrimaryDisplayId( | 303 private native void nativeSetPrimaryDisplayId( |
| 302 long nativeDisplayAndroidManager, int sdkDisplayId); | 304 long nativeDisplayAndroidManager, int sdkDisplayId); |
| 303 } | 305 } |
| OLD | NEW |