shared_device_display_info.h revision 1e9bf3e0803691d0a228da41fc608347b6db4340
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)
211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int GetDisplayHeight();
221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int GetDisplayWidth();
231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int GetBitsPerPixel();
241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int GetBitsPerComponent();
251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  double GetDIPScale();
261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int GetSmallestDIPWidth();
271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Registers methods with JNI and returns true if succeeded.
291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  static bool RegisterSharedDeviceDisplayInfo(JNIEnv* env);
301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void InvokeUpdate(JNIEnv* env,
321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                    jobject jobj,
331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                    jint display_height,
341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                    jint display_width,
351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                    jint bits_per_pixel,
361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                    jint bits_per_component,
371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                    jdouble dip_scale,
381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                    jint smallest_dip_width);
391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) private:
401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  friend struct DefaultSingletonTraits<SharedDeviceDisplayInfo>;
411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SharedDeviceDisplayInfo();
431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  ~SharedDeviceDisplayInfo();
441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void UpdateDisplayInfo(JNIEnv* env,
451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                         jobject jobj,
461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                         jint display_height,
471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                         jint display_width,
481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                         jint bits_per_pixel,
491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                         jint bits_per_component,
501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                         jdouble dip_scale,
511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                         jint smallest_dip_width);
521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  base::Lock lock_;
541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  base::android::ScopedJavaGlobalRef<jobject> j_device_info_;
551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int display_height_;
571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int display_width_;
581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int bits_per_pixel_;
591e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int bits_per_component_;
601e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  double dip_scale_;
611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int smallest_dip_width_;
621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
631e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(SharedDeviceDisplayInfo);
641e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)};
651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}  // namespace gfx
671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
681e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif // UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_
69