11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// found in the LICENSE file. 41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#ifndef UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_ 61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#define UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_ 71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 81e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/android/scoped_java_ref.h" 91e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/basictypes.h" 101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/memory/singleton.h" 111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/synchronization/lock.h" 121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace gfx { 141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Facilitates access to device information typically only 161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// available using the Android SDK, including Display properties. 171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class SharedDeviceDisplayInfo { 181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) public: 191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) static SharedDeviceDisplayInfo* GetInstance(); 201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // See documentation in DeviceDisplayInfo.java 221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int GetDisplayHeight(); 231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int GetDisplayWidth(); 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int GetPhysicalDisplayHeight(); 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int GetPhysicalDisplayWidth(); 261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int GetBitsPerPixel(); 271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int GetBitsPerComponent(); 281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) double GetDIPScale(); 291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int GetSmallestDIPWidth(); 300529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch int GetRotationDegrees(); 311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Registers methods with JNI and returns true if succeeded. 331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) static bool RegisterSharedDeviceDisplayInfo(JNIEnv* env); 341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void InvokeUpdate(JNIEnv* env, 361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jobject jobj, 371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jint display_height, 381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jint display_width, 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) jint physical_display_height, 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) jint physical_display_width, 411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jint bits_per_pixel, 421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jint bits_per_component, 431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jdouble dip_scale, 440529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch jint smallest_dip_width, 450529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch jint rotation_degrees); 461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) private: 471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) friend struct DefaultSingletonTraits<SharedDeviceDisplayInfo>; 481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) SharedDeviceDisplayInfo(); 501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) ~SharedDeviceDisplayInfo(); 511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void UpdateDisplayInfo(JNIEnv* env, 521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jobject jobj, 531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jint display_height, 541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jint display_width, 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) jint physical_display_height, 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) jint physical_display_width, 571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jint bits_per_pixel, 581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jint bits_per_component, 591e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) jdouble dip_scale, 600529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch jint smallest_dip_width, 610529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch jint rotation_degrees); 621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 631e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::Lock lock_; 641e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::android::ScopedJavaGlobalRef<jobject> j_device_info_; 651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int display_height_; 671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int display_width_; 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int physical_display_height_; 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int physical_display_width_; 701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int bits_per_pixel_; 711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int bits_per_component_; 721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) double dip_scale_; 731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int smallest_dip_width_; 740529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch int rotation_degrees_; 751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(SharedDeviceDisplayInfo); 771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}; 781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} // namespace gfx 801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif // UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_ 82