Commit 21c5afa3 authored by boliu's avatar boliu Committed by Commit bot

android: Remove DeviceDisplayInfo

Move getSmallestDIPWidth to ChromeContextUtil in chrome. This removes
the last usage of DeviceDisplayInfo, so finally remove it.

BUG=625089

Review-Url: https://codereview.chromium.org/2623653002
Cr-Commit-Position: refs/heads/master@{#442981}
parent bbdc4e44
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.util;
import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative;
final class ChromeContextUtil {
private ChromeContextUtil() {}
@CalledByNative
private static int getSmallestDIPWidth() {
return ContextUtils.getApplicationContext()
.getResources()
.getConfiguration()
.smallestScreenWidthDp;
}
}
......@@ -1021,6 +1021,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/upgrade/UpgradeActivity.java",
"java/src/org/chromium/chrome/browser/upgrade/UpgradeIntentService.java",
"java/src/org/chromium/chrome/browser/util/AccessibilityUtil.java",
"java/src/org/chromium/chrome/browser/util/ChromeContextUtil.java",
"java/src/org/chromium/chrome/browser/util/ChromeFileProvider.java",
"java/src/org/chromium/chrome/browser/util/ColorUtils.java",
"java/src/org/chromium/chrome/browser/util/FeatureUtilities.java",
......
......@@ -2529,6 +2529,8 @@ split_static_library("browser") {
"android/chrome_backup_agent.cc",
"android/chrome_backup_agent.h",
"android/chrome_backup_watcher.cc",
"android/chrome_context_util.cc",
"android/chrome_context_util.h",
"android/chrome_feature_list.cc",
"android/chrome_feature_list.h",
"android/chrome_jni_registrar.cc",
......@@ -4054,6 +4056,7 @@ if (is_android) {
"../android/java/src/org/chromium/chrome/browser/tabmodel/TabModelJniBridge.java",
"../android/java/src/org/chromium/chrome/browser/tabmodel/TabModelSelectorBase.java",
"../android/java/src/org/chromium/chrome/browser/toolbar/ToolbarModel.java",
"../android/java/src/org/chromium/chrome/browser/util/ChromeContextUtil.java",
"../android/java/src/org/chromium/chrome/browser/util/FeatureUtilities.java",
"../android/java/src/org/chromium/chrome/browser/util/PlatformUtil.java",
"../android/java/src/org/chromium/chrome/browser/util/UrlUtilities.java",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/android/chrome_context_util.h"
#include "base/android/jni_android.h"
#include "jni/ChromeContextUtil_jni.h"
namespace chrome {
namespace android {
ChromeContextUtil::ChromeContextUtil() {}
// static
int ChromeContextUtil::GetSmallestDIPWidth() {
return Java_ChromeContextUtil_getSmallestDIPWidth(
base::android::AttachCurrentThread());
}
} // namespace android
} // namespace chrome
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_CHROME_CONTEXT_UTIL_H_
#define CHROME_BROWSER_ANDROID_CHROME_CONTEXT_UTIL_H_
namespace chrome {
namespace android {
class ChromeContextUtil {
public:
// Smallest possible screen size in density-independent pixels.
static int GetSmallestDIPWidth();
private:
ChromeContextUtil();
};
} // namespace android
} // namespace chrome
#endif // CHROME_BROWSER_ANDROID_CHROME_CONTEXT_UTIL_H_
......@@ -263,6 +263,7 @@
#endif
#if defined(OS_ANDROID)
#include "chrome/browser/android/chrome_context_util.h"
#include "chrome/browser/android/devtools_manager_delegate_android.h"
#include "chrome/browser/android/ntp/new_tab_page_url_handler.h"
#include "chrome/browser/android/service_tab_launcher.h"
......@@ -270,7 +271,6 @@
#include "components/payments/payment_request.mojom.h"
#include "content/public/browser/android/java_interfaces.h"
#include "ui/base/ui_base_paths.h"
#include "ui/gfx/android/device_display_info.h"
#else
#include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
#endif
......@@ -704,8 +704,7 @@ float GetDeviceScaleAdjustment() {
static const float kMaxFSM = 1.3f;
static const int kWidthForMaxFSM = 800;
gfx::DeviceDisplayInfo info;
int minWidth = info.GetSmallestDIPWidth();
int minWidth = chrome::android::ChromeContextUtil::GetSmallestDIPWidth();
if (minWidth <= kWidthForMinFSM)
return kMinFSM;
......
......@@ -183,7 +183,6 @@ android_library("ui_java") {
"java/src/org/chromium/ui/display/PhysicalDisplayAndroid.java",
"java/src/org/chromium/ui/display/VirtualDisplayAndroid.java",
"java/src/org/chromium/ui/gfx/BitmapHelper.java",
"java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java",
"java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java",
"java/src/org/chromium/ui/gl/SurfaceTextureListener.java",
"java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java",
......
......@@ -20,7 +20,6 @@ import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.ui.gfx.DeviceDisplayInfo;
/**
* DisplayAndroidManager is a class that informs its observers Display changes.
......@@ -111,7 +110,6 @@ public class DisplayAndroidManager {
@Override
public void onConfigurationChanged(Configuration newConfig) {
updateDeviceDisplayInfo();
((PhysicalDisplayAndroid) mIdMap.get(mMainSdkDisplayId)).updateFromDisplay(
getDefaultDisplayForContext(getContext()));
}
......@@ -170,7 +168,6 @@ public class DisplayAndroidManager {
@Override
public void onDisplayChanged(int sdkDisplayId) {
updateDeviceDisplayInfo();
PhysicalDisplayAndroid displayAndroid =
(PhysicalDisplayAndroid) mIdMap.get(sdkDisplayId);
if (displayAndroid != null) {
......@@ -222,10 +219,6 @@ public class DisplayAndroidManager {
return (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE);
}
private static void updateDeviceDisplayInfo() {
DeviceDisplayInfo.create(getContext()).updateNativeSharedDisplayInfo();
}
@CalledByNative
private static void onNativeSideCreated(long nativePointer) {
DisplayAndroidManager singleton = getInstance();
......
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.ui.gfx;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.MainDex;
/**
* This class facilitates access to android information typically only
* available using the Java SDK, including {@link Display} properties.
*
* Currently the information consists of very raw display information (height, width, DPI scale)
* regarding the main display.
*
* This class is being Deprecated. Use DisplayAndroid instead where possible.
*/
@JNINamespace("gfx")
@MainDex
public class DeviceDisplayInfo {
private final Context mAppContext;
private final WindowManager mWinManager;
private Point mTempPoint = new Point();
private DisplayMetrics mTempMetrics = new DisplayMetrics();
private DeviceDisplayInfo(Context context) {
mAppContext = context.getApplicationContext();
mWinManager = (WindowManager) mAppContext.getSystemService(Context.WINDOW_SERVICE);
}
/**
* @return Display height in physical pixels.
*/
@CalledByNative
public int getDisplayHeight() {
getDisplay().getSize(mTempPoint);
return mTempPoint.y;
}
/**
* @return Display width in physical pixels.
*/
@CalledByNative
public int getDisplayWidth() {
getDisplay().getSize(mTempPoint);
return mTempPoint.x;
}
/**
* @return Real physical display height in physical pixels.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@CalledByNative
public int getPhysicalDisplayHeight() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
return 0;
}
getDisplay().getRealSize(mTempPoint);
return mTempPoint.y;
}
/**
* @return Real physical display width in physical pixels.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@CalledByNative
public int getPhysicalDisplayWidth() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
return 0;
}
getDisplay().getRealSize(mTempPoint);
return mTempPoint.x;
}
@SuppressWarnings("deprecation")
private int getPixelFormat() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
return getDisplay().getPixelFormat();
}
// JellyBean MR1 and later always uses RGBA_8888.
return PixelFormat.RGBA_8888;
}
/**
* @return Bits per pixel.
*/
@CalledByNative
private int getBitsPerPixel() {
int format = getPixelFormat();
PixelFormat info = new PixelFormat();
PixelFormat.getPixelFormatInfo(format, info);
return info.bitsPerPixel;
}
/**
* @return Bits per component.
*/
@SuppressWarnings("deprecation")
@CalledByNative
private int getBitsPerComponent() {
int format = getPixelFormat();
switch (format) {
case PixelFormat.RGBA_4444:
return 4;
case PixelFormat.RGBA_5551:
return 5;
case PixelFormat.RGBA_8888:
case PixelFormat.RGBX_8888:
case PixelFormat.RGB_888:
return 8;
case PixelFormat.RGB_332:
return 2;
case PixelFormat.RGB_565:
return 5;
// Non-RGB formats.
case PixelFormat.A_8:
case PixelFormat.LA_88:
case PixelFormat.L_8:
return 0;
// Unknown format. Use 8 as a sensible default.
default:
return 8;
}
}
/**
* @return A scaling factor for the Density Independent Pixel unit. 1.0 is
* 160dpi, 0.75 is 120dpi, 2.0 is 320dpi.
*/
@CalledByNative
public double getDIPScale() {
getDisplay().getMetrics(mTempMetrics);
return mTempMetrics.density;
}
/**
* @return Smallest screen size in density-independent pixels that the
* application will see, regardless of orientation.
*/
@CalledByNative
private int getSmallestDIPWidth() {
return mAppContext.getResources().getConfiguration().smallestScreenWidthDp;
}
/**
* @return the screen's rotation angle from its 'natural' orientation.
* Expected values are one of { 0, 90, 180, 270 }.
* See http://developer.android.com/reference/android/view/Display.html#getRotation()
* for more information about Display.getRotation() behavior.
*/
@CalledByNative
public int getRotationDegrees() {
switch (getDisplay().getRotation()) {
case Surface.ROTATION_0:
return 0;
case Surface.ROTATION_90:
return 90;
case Surface.ROTATION_180:
return 180;
case Surface.ROTATION_270:
return 270;
}
// This should not happen.
assert false;
return 0;
}
/**
* Inform the native implementation to update its cached representation of
* the DeviceDisplayInfo values.
*/
public void updateNativeSharedDisplayInfo() {
nativeUpdateSharedDeviceDisplayInfo(
getDisplayHeight(), getDisplayWidth(),
getPhysicalDisplayHeight(), getPhysicalDisplayWidth(),
getBitsPerPixel(), getBitsPerComponent(),
getDIPScale(), getSmallestDIPWidth(), getRotationDegrees());
}
private Display getDisplay() {
return mWinManager.getDefaultDisplay();
}
/**
* Creates DeviceDisplayInfo for a given Context.
*
* @param context A context to use.
* @return DeviceDisplayInfo associated with a given Context.
*/
@CalledByNative
public static DeviceDisplayInfo create(Context context) {
return new DeviceDisplayInfo(context);
}
private native void nativeUpdateSharedDeviceDisplayInfo(
int displayHeight, int displayWidth,
int physicalDisplayHeight, int physicalDisplayWidth,
int bitsPerPixel, int bitsPerComponent, double dipScale,
int smallestDIPWidth, int rotationDegrees);
}
......@@ -23,14 +23,10 @@ source_set("gfx_export") {
component("gfx") {
sources = [
"android/device_display_info.cc",
"android/device_display_info.h",
"android/gfx_jni_registrar.cc",
"android/gfx_jni_registrar.h",
"android/java_bitmap.cc",
"android/java_bitmap.h",
"android/shared_device_display_info.cc",
"android/shared_device_display_info.h",
"android/view_configuration.cc",
"android/view_configuration.h",
"animation/animation.cc",
......@@ -739,7 +735,6 @@ if (is_android) {
generate_jni("gfx_jni_headers") {
sources = [
"../android/java/src/org/chromium/ui/gfx/BitmapHelper.java",
"../android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java",
"../android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java",
]
jni_package = "gfx"
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/gfx/android/device_display_info.h"
#include "base/logging.h"
#include "ui/gfx/android/shared_device_display_info.h"
namespace gfx {
DeviceDisplayInfo::DeviceDisplayInfo() {
}
DeviceDisplayInfo::~DeviceDisplayInfo() {
}
int DeviceDisplayInfo::GetDisplayHeight() const {
return SharedDeviceDisplayInfo::GetInstance()->GetDisplayHeight();
}
int DeviceDisplayInfo::GetDisplayWidth() const {
return SharedDeviceDisplayInfo::GetInstance()->GetDisplayWidth();
}
int DeviceDisplayInfo::GetPhysicalDisplayHeight() const {
return SharedDeviceDisplayInfo::GetInstance()->GetPhysicalDisplayHeight();
}
int DeviceDisplayInfo::GetPhysicalDisplayWidth() const {
return SharedDeviceDisplayInfo::GetInstance()->GetPhysicalDisplayWidth();
}
int DeviceDisplayInfo::GetBitsPerPixel() const {
return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerPixel();
}
int DeviceDisplayInfo::GetBitsPerComponent() const {
return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerComponent();
}
double DeviceDisplayInfo::GetDIPScale() const {
return SharedDeviceDisplayInfo::GetInstance()->GetDIPScale();
}
int DeviceDisplayInfo::GetSmallestDIPWidth() const {
return SharedDeviceDisplayInfo::GetInstance()->GetSmallestDIPWidth();
}
int DeviceDisplayInfo::GetRotationDegrees() const {
return SharedDeviceDisplayInfo::GetInstance()->GetRotationDegrees();
}
} // namespace gfx
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_
#define UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_
#include <jni.h>
#include <string>
#include "base/macros.h"
#include "ui/gfx/gfx_export.h"
namespace gfx {
// Facilitates access to device information typically only
// available using the Android SDK, including Display properties.
class GFX_EXPORT DeviceDisplayInfo {
public:
DeviceDisplayInfo();
~DeviceDisplayInfo();
// Returns display height in physical pixels.
int GetDisplayHeight() const;
// Returns display width in physical pixels.
int GetDisplayWidth() const;
// Returns real display height in physical pixels.
// This version does not subtract window decorations etc.
// WARNING: This is only supported on JB-MR1 (sdk >= 17). Either
// check the SDK-level, or check for '0' being returned.
int GetPhysicalDisplayHeight() const;
// Returns real display width in physical pixels.
// This version does not subtract window decorations etc.
// WARNING: This is only supported on JB-MR1 (sdk >= 17). Either
// check the SDK-level, or check for '0' being returned.
int GetPhysicalDisplayWidth() const;
// Returns number of bits per pixel.
int GetBitsPerPixel() const;
// Returns number of bits per component.
int GetBitsPerComponent() const;
// Returns a scaling factor for Density Independent Pixel unit
// (1.0 is 160dpi, 0.75 is 120dpi, 2.0 is 320dpi).
double GetDIPScale() const;
// Smallest possible screen size in density-independent pixels.
int GetSmallestDIPWidth() const;
// Returns the display rotation angle from its natural orientation. Expected
// values are one of { 0, 90, 180, 270 }.
// See DeviceDispayInfo.java for more information.
int GetRotationDegrees() const;
private:
DISALLOW_COPY_AND_ASSIGN(DeviceDisplayInfo);
};
} // namespace gfx
#endif // UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_
......@@ -7,15 +7,12 @@
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "base/macros.h"
#include "ui/gfx/android/shared_device_display_info.h"
#include "ui/gfx/android/view_configuration.h"
namespace gfx {
namespace android {
static base::android::RegistrationMethod kGfxRegisteredMethods[] = {
{ "SharedDeviceDisplayInfo",
SharedDeviceDisplayInfo::RegisterSharedDeviceDisplayInfo },
{ "ViewConfiguration", ViewConfiguration::RegisterViewConfiguration }
};
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/gfx/android/shared_device_display_info.h"
#include "base/android/context_utils.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/logging.h"
#include "jni/DeviceDisplayInfo_jni.h"
using base::android::JavaParamRef;
namespace gfx {
// static JNI call
static void UpdateSharedDeviceDisplayInfo(JNIEnv* env,
const JavaParamRef<jobject>& obj,
jint display_height,
jint display_width,
jint physical_display_height,
jint physical_display_width,
jint bits_per_pixel,
jint bits_per_component,
jdouble dip_scale,
jint smallest_dip_width,
jint rotation_degrees) {
SharedDeviceDisplayInfo::GetInstance()->InvokeUpdate(env, obj,
display_height, display_width,
physical_display_height, physical_display_width,
bits_per_pixel, bits_per_component,
dip_scale, smallest_dip_width, rotation_degrees);
}
// static
SharedDeviceDisplayInfo* SharedDeviceDisplayInfo::GetInstance() {
return base::Singleton<SharedDeviceDisplayInfo>::get();
}
int SharedDeviceDisplayInfo::GetDisplayHeight() {
base::AutoLock autolock(lock_);
DCHECK_NE(0, display_height_);
return display_height_;
}
int SharedDeviceDisplayInfo::GetDisplayWidth() {
base::AutoLock autolock(lock_);
DCHECK_NE(0, display_width_);
return display_width_;
}
int SharedDeviceDisplayInfo::GetPhysicalDisplayHeight() {
base::AutoLock autolock(lock_);
return physical_display_height_;
}
int SharedDeviceDisplayInfo::GetPhysicalDisplayWidth() {
base::AutoLock autolock(lock_);
return physical_display_width_;
}
int SharedDeviceDisplayInfo::GetBitsPerPixel() {
base::AutoLock autolock(lock_);
DCHECK_NE(0, bits_per_pixel_);
return bits_per_pixel_;
}
int SharedDeviceDisplayInfo::GetBitsPerComponent() {
base::AutoLock autolock(lock_);
DCHECK_NE(0, bits_per_component_);
return bits_per_component_;
}
double SharedDeviceDisplayInfo::GetDIPScale() {
base::AutoLock autolock(lock_);
DCHECK_NE(0, dip_scale_);
return dip_scale_;
}
int SharedDeviceDisplayInfo::GetSmallestDIPWidth() {
base::AutoLock autolock(lock_);
DCHECK_NE(0, smallest_dip_width_);
return smallest_dip_width_;
}
int SharedDeviceDisplayInfo::GetRotationDegrees() {
base::AutoLock autolock(lock_);
return rotation_degrees_;
}
// static
bool SharedDeviceDisplayInfo::RegisterSharedDeviceDisplayInfo(JNIEnv* env) {
return RegisterNativesImpl(env);
}
void SharedDeviceDisplayInfo::InvokeUpdate(JNIEnv* env,
jobject obj,
jint display_height,
jint display_width,
jint physical_display_height,
jint physical_display_width,
jint bits_per_pixel,
jint bits_per_component,
jdouble dip_scale,
jint smallest_dip_width,
jint rotation_degrees) {
base::AutoLock autolock(lock_);
UpdateDisplayInfo(env, obj,
display_height, display_width,
physical_display_height, physical_display_width,
bits_per_pixel, bits_per_component, dip_scale,
smallest_dip_width, rotation_degrees);
}
SharedDeviceDisplayInfo::SharedDeviceDisplayInfo()
: display_height_(0),
display_width_(0),
bits_per_pixel_(0),
bits_per_component_(0),
dip_scale_(0),
smallest_dip_width_(0) {
JNIEnv* env = base::android::AttachCurrentThread();
j_device_info_.Reset(
Java_DeviceDisplayInfo_create(
env, base::android::GetApplicationContext()));
UpdateDisplayInfo(
env, j_device_info_.obj(),
Java_DeviceDisplayInfo_getDisplayHeight(env, j_device_info_),
Java_DeviceDisplayInfo_getDisplayWidth(env, j_device_info_),
Java_DeviceDisplayInfo_getPhysicalDisplayHeight(env, j_device_info_),
Java_DeviceDisplayInfo_getPhysicalDisplayWidth(env, j_device_info_),
Java_DeviceDisplayInfo_getBitsPerPixel(env, j_device_info_),
Java_DeviceDisplayInfo_getBitsPerComponent(env, j_device_info_),
Java_DeviceDisplayInfo_getDIPScale(env, j_device_info_),
Java_DeviceDisplayInfo_getSmallestDIPWidth(env, j_device_info_),
Java_DeviceDisplayInfo_getRotationDegrees(env, j_device_info_));
}
SharedDeviceDisplayInfo::~SharedDeviceDisplayInfo() {
}
void SharedDeviceDisplayInfo::UpdateDisplayInfo(JNIEnv* env,
jobject jobj,
jint display_height,
jint display_width,
jint physical_display_height,
jint physical_display_width,
jint bits_per_pixel,
jint bits_per_component,
jdouble dip_scale,
jint smallest_dip_width,
jint rotation_degrees) {
display_height_ = static_cast<int>(display_height);
display_width_ = static_cast<int>(display_width);
physical_display_height_ = static_cast<int>(physical_display_height);
physical_display_width_ = static_cast<int>(physical_display_width);
bits_per_pixel_ = static_cast<int>(bits_per_pixel);
bits_per_component_ = static_cast<int>(bits_per_component);
dip_scale_ = static_cast<double>(dip_scale);
smallest_dip_width_ = static_cast<int>(smallest_dip_width);
rotation_degrees_ = static_cast<int>(rotation_degrees);
}
} // namespace gfx
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_
#define UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_
#include "base/android/scoped_java_ref.h"
#include "base/macros.h"
#include "base/memory/singleton.h"
#include "base/synchronization/lock.h"
namespace gfx {
// Facilitates access to device information typically only
// available using the Android SDK, including Display properties.
class SharedDeviceDisplayInfo {
public:
static SharedDeviceDisplayInfo* GetInstance();
// See documentation in DeviceDisplayInfo.java
int GetDisplayHeight();
int GetDisplayWidth();
int GetPhysicalDisplayHeight();
int GetPhysicalDisplayWidth();
int GetBitsPerPixel();
int GetBitsPerComponent();
double GetDIPScale();
int GetSmallestDIPWidth();
int GetRotationDegrees();
// Registers methods with JNI and returns true if succeeded.
static bool RegisterSharedDeviceDisplayInfo(JNIEnv* env);
void InvokeUpdate(JNIEnv* env,
jobject jobj,
jint display_height,
jint display_width,
jint physical_display_height,
jint physical_display_width,
jint bits_per_pixel,
jint bits_per_component,
jdouble dip_scale,
jint smallest_dip_width,
jint rotation_degrees);
private:
friend struct base::DefaultSingletonTraits<SharedDeviceDisplayInfo>;
SharedDeviceDisplayInfo();
~SharedDeviceDisplayInfo();
void UpdateDisplayInfo(JNIEnv* env,
jobject jobj,
jint display_height,
jint display_width,
jint physical_display_height,
jint physical_display_width,
jint bits_per_pixel,
jint bits_per_component,
jdouble dip_scale,
jint smallest_dip_width,
jint rotation_degrees);
base::Lock lock_;
base::android::ScopedJavaGlobalRef<jobject> j_device_info_;
int display_height_;
int display_width_;
int physical_display_height_;
int physical_display_width_;
int bits_per_pixel_;
int bits_per_component_;
double dip_scale_;
int smallest_dip_width_;
int rotation_degrees_;
DISALLOW_COPY_AND_ASSIGN(SharedDeviceDisplayInfo);
};
} // namespace gfx
#endif // UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment