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

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

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: 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
Index: ui/gfx/android/device_display_info.h
diff --git a/ui/gfx/android/device_display_info.h b/ui/gfx/android/device_display_info.h
index c989b9849551c0a778b440c01d02cf5280535873..bc8e0a69812942c215a3d128839e5143e2ffa55d 100644
--- a/ui/gfx/android/device_display_info.h
+++ b/ui/gfx/android/device_display_info.h
@@ -10,6 +10,7 @@
#include "base/android/scoped_java_ref.h"
#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
Yaron 2013/10/10 11:52:46 You'll be able to remove by changing to LazyInstan
#include "ui/gfx/gfx_export.h"
namespace gfx {
@@ -37,15 +38,45 @@ class GFX_EXPORT DeviceDisplayInfo {
// (1.0 is 160dpi, 0.75 is 120dpi, 2.0 is 320dpi).
double GetDIPScale();
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DeviceDisplayInfo);
+};
+
+class GFX_EXPORT SharedDisplayInfo {
+ public:
+ static int GetDisplayHeight();
+ static int GetDisplayWidth();
+ static int GetBitsPerPixel();
+ static int GetBitsPerComponent();
+ static double GetDIPScale();
+
+ static void UpdateDisplayInfo(JNIEnv*, jobject, jint display_height,
+ jint display_width, jint bits_per_pixel, jint bits_per_component,
+ jdouble dip_scale);
+
// Registers methods with JNI and returns true if succeeded.
- static bool RegisterDeviceDisplayInfo(JNIEnv* env);
+ static bool RegisterSharedDeviceDisplayInfo(JNIEnv* env);
private:
+ static SharedDisplayInfo* Instance();
+ SharedDisplayInfo();
+
+ void InvokeUpdate();
Yaron 2013/10/10 11:52:46 never called
+ void RegisterListener();
+
+ static scoped_ptr<SharedDisplayInfo> instance_;
+
base::android::ScopedJavaGlobalRef<jobject> j_device_info_;
- DISALLOW_COPY_AND_ASSIGN(DeviceDisplayInfo);
+ int display_height_;
+ int display_width_;
+ int bits_per_pixel_;
+ int bits_per_component_;
+ double dip_scale_;
};
+
+
} // namespace gfx
#endif // UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_

Powered by Google App Engine
This is Rietveld 408576698