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

Unified Diff: ui/gfx/android/device_display_info.cc

Issue 26129009: Cache DeviceDisplayInfo data in shared structure on native side to avoid frequent JNI calls. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Fix clang build issues. Created 7 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/android/device_display_info.h ('k') | ui/gfx/android/gfx_jni_registrar.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/android/device_display_info.cc
diff --git a/ui/gfx/android/device_display_info.cc b/ui/gfx/android/device_display_info.cc
index 23c6c2eeffd943c51bda15ce7912f71c43a8f7fe..2de8440e1d3e2b41e9b7b0bc5384188d7fd8b929 100644
--- a/ui/gfx/android/device_display_info.cc
+++ b/ui/gfx/android/device_display_info.cc
@@ -4,70 +4,39 @@
#include "ui/gfx/android/device_display_info.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::AttachCurrentThread;
-using base::android::ScopedJavaLocalRef;
+#include "ui/gfx/android/shared_device_display_info.h"
namespace gfx {
DeviceDisplayInfo::DeviceDisplayInfo() {
- JNIEnv* env = AttachCurrentThread();
- j_device_info_.Reset(Java_DeviceDisplayInfo_create(env,
- base::android::GetApplicationContext()));
}
DeviceDisplayInfo::~DeviceDisplayInfo() {
}
int DeviceDisplayInfo::GetDisplayHeight() {
- JNIEnv* env = AttachCurrentThread();
- jint result =
- Java_DeviceDisplayInfo_getDisplayHeight(env, j_device_info_.obj());
- return static_cast<int>(result);
+ return SharedDeviceDisplayInfo::GetInstance()->GetDisplayHeight();
}
int DeviceDisplayInfo::GetDisplayWidth() {
- JNIEnv* env = AttachCurrentThread();
- jint result =
- Java_DeviceDisplayInfo_getDisplayWidth(env, j_device_info_.obj());
- return static_cast<int>(result);
+ return SharedDeviceDisplayInfo::GetInstance()->GetDisplayWidth();
}
int DeviceDisplayInfo::GetBitsPerPixel() {
- JNIEnv* env = AttachCurrentThread();
- jint result =
- Java_DeviceDisplayInfo_getBitsPerPixel(env, j_device_info_.obj());
- return static_cast<int>(result);
+ return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerPixel();
}
int DeviceDisplayInfo::GetBitsPerComponent() {
- JNIEnv* env = AttachCurrentThread();
- jint result =
- Java_DeviceDisplayInfo_getBitsPerComponent(env, j_device_info_.obj());
- return static_cast<int>(result);
+ return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerComponent();
}
double DeviceDisplayInfo::GetDIPScale() {
- JNIEnv* env = AttachCurrentThread();
- jdouble result =
- Java_DeviceDisplayInfo_getDIPScale(env, j_device_info_.obj());
- return static_cast<double>(result);
+ return SharedDeviceDisplayInfo::GetInstance()->GetDIPScale();
}
int DeviceDisplayInfo::GetSmallestDIPWidth() {
- JNIEnv* env = AttachCurrentThread();
- jint result =
- Java_DeviceDisplayInfo_getSmallestDIPWidth(env, j_device_info_.obj());
- return static_cast<int>(result);
-}
-
-// static
-bool DeviceDisplayInfo::RegisterDeviceDisplayInfo(JNIEnv* env) {
- return RegisterNativesImpl(env);
+ return SharedDeviceDisplayInfo::GetInstance()->GetSmallestDIPWidth();
}
} // namespace gfx
« no previous file with comments | « ui/gfx/android/device_display_info.h ('k') | ui/gfx/android/gfx_jni_registrar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698