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

Side by Side Diff: ui/gfx/android/shared_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: Updated by review comments. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 #ifndef UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_
6 #define UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_
7
8 #include "base/android/scoped_java_ref.h"
9 #include "base/basictypes.h"
10 #include "base/memory/singleton.h"
11 #include "base/synchronization/lock.h"
12
13 namespace gfx {
14
15 // Facilitates access to device information typically only
16 // available using the Android SDK, including Display properties.
17 class SharedDeviceDisplayInfo {
18 public:
19 static SharedDeviceDisplayInfo* GetInstance();
20
21 int GetDisplayHeight();
22 int GetDisplayWidth();
23 int GetBitsPerPixel();
24 int GetBitsPerComponent();
25 double GetDIPScale();
26 int GetSmallestDIPWidth();
27
28 // Registers methods with JNI and returns true if succeeded.
29 static bool RegisterSharedDeviceDisplayInfo(JNIEnv* env);
30
31 void InvokeUpdate(JNIEnv* env,
32 jobject jobj,
33 jint display_height,
34 jint display_width,
35 jint bits_per_pixel,
36 jint bits_per_component,
37 jdouble dip_scale,
38 jint smallest_dip_width);
39 private:
40 friend class DefaultSingletonTraits<SharedDeviceDisplayInfo>;
41
42 SharedDeviceDisplayInfo();
43 void UpdateDisplayInfo(JNIEnv* env,
44 jobject jobj,
45 jint display_height,
46 jint display_width,
47 jint bits_per_pixel,
48 jint bits_per_component,
49 jdouble dip_scale,
50 jint smallest_dip_width);
51
52 base::Lock lock_;
53 base::android::ScopedJavaGlobalRef<jobject> j_device_info_;
54
55 int display_height_;
56 int display_width_;
57 int bits_per_pixel_;
58 int bits_per_component_;
59 double dip_scale_;
60 int smallest_dip_width_;
61
62 DISALLOW_COPY_AND_ASSIGN(SharedDeviceDisplayInfo);
63 };
64
65 } // namespace gfx
66
67 #endif // UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698