add a use_alsa gyp setting
[chromium-blink-merge.git] / ui / gfx / screen_android.cc
blob81d3bcf285dc63d49aa9cfef88c61662daebf1eb
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.
5 #include "ui/gfx/screen.h"
7 #include "base/logging.h"
8 #include "ui/gfx/android/device_display_info.h"
9 #include "ui/gfx/display.h"
10 #include "ui/gfx/size_conversions.h"
12 namespace gfx {
14 class ScreenAndroid : public Screen {
15 public:
16 ScreenAndroid() {}
18 bool IsDIPEnabled() OVERRIDE {
19 return true;
22 gfx::Point GetCursorScreenPoint() OVERRIDE {
23 return gfx::Point();
26 gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE {
27 NOTIMPLEMENTED();
28 return NULL;
31 gfx::Display GetPrimaryDisplay() const OVERRIDE {
32 gfx::DeviceDisplayInfo device_info;
33 const float device_scale_factor = device_info.GetDIPScale();
34 const gfx::Rect bounds_in_pixels =
35 gfx::Rect(
36 device_info.GetDisplayWidth(),
37 device_info.GetDisplayHeight());
38 const gfx::Rect bounds_in_dip =
39 gfx::Rect(gfx::ToCeiledSize(gfx::ScaleSize(
40 bounds_in_pixels.size(), 1.0f / device_scale_factor)));
41 gfx::Display display(0, bounds_in_dip);
42 display.set_device_scale_factor(device_scale_factor);
43 return display;
46 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const OVERRIDE {
47 return GetPrimaryDisplay();
50 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const OVERRIDE {
51 return GetPrimaryDisplay();
54 int GetNumDisplays() OVERRIDE {
55 return 1;
58 virtual gfx::Display GetDisplayMatching(
59 const gfx::Rect& match_rect) const OVERRIDE {
60 return GetPrimaryDisplay();
63 virtual void AddObserver(DisplayObserver* observer) OVERRIDE {
64 // no display change on Android.
67 virtual void RemoveObserver(DisplayObserver* observer) OVERRIDE {
68 // no display change on Android.
71 private:
72 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid);
75 Screen* CreateNativeScreen() {
76 return new ScreenAndroid;
79 } // namespace gfx