shared_device_display_info.h revision 0529e5d033099cbfc42635f6f6183833b09dff6e
1// Copyright 2013 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 13namespace gfx { 14 15// Facilitates access to device information typically only 16// available using the Android SDK, including Display properties. 17class SharedDeviceDisplayInfo { 18 public: 19 static SharedDeviceDisplayInfo* GetInstance(); 20 21 // See documentation in DeviceDisplayInfo.java 22 int GetDisplayHeight(); 23 int GetDisplayWidth(); 24 int GetPhysicalDisplayHeight(); 25 int GetPhysicalDisplayWidth(); 26 int GetBitsPerPixel(); 27 int GetBitsPerComponent(); 28 double GetDIPScale(); 29 int GetSmallestDIPWidth(); 30 int GetRotationDegrees(); 31 32 // Registers methods with JNI and returns true if succeeded. 33 static bool RegisterSharedDeviceDisplayInfo(JNIEnv* env); 34 35 void InvokeUpdate(JNIEnv* env, 36 jobject jobj, 37 jint display_height, 38 jint display_width, 39 jint physical_display_height, 40 jint physical_display_width, 41 jint bits_per_pixel, 42 jint bits_per_component, 43 jdouble dip_scale, 44 jint smallest_dip_width, 45 jint rotation_degrees); 46 private: 47 friend struct DefaultSingletonTraits<SharedDeviceDisplayInfo>; 48 49 SharedDeviceDisplayInfo(); 50 ~SharedDeviceDisplayInfo(); 51 void UpdateDisplayInfo(JNIEnv* env, 52 jobject jobj, 53 jint display_height, 54 jint display_width, 55 jint physical_display_height, 56 jint physical_display_width, 57 jint bits_per_pixel, 58 jint bits_per_component, 59 jdouble dip_scale, 60 jint smallest_dip_width, 61 jint rotation_degrees); 62 63 base::Lock lock_; 64 base::android::ScopedJavaGlobalRef<jobject> j_device_info_; 65 66 int display_height_; 67 int display_width_; 68 int physical_display_height_; 69 int physical_display_width_; 70 int bits_per_pixel_; 71 int bits_per_component_; 72 double dip_scale_; 73 int smallest_dip_width_; 74 int rotation_degrees_; 75 76 DISALLOW_COPY_AND_ASSIGN(SharedDeviceDisplayInfo); 77}; 78 79} // namespace gfx 80 81#endif // UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_ 82