| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromecast/graphics/cast_screen.h" | 5 #include "chromecast/graphics/cast_screen.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" |
| 10 #include "chromecast/public/graphics_properties_shlib.h" |
| 9 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
| 10 #include "ui/display/screen.h" | 12 #include "ui/display/screen.h" |
| 11 #include "ui/gfx/geometry/rect_conversions.h" | 13 #include "ui/gfx/geometry/rect_conversions.h" |
| 14 #include "ui/gfx/geometry/size.h" |
| 12 #include "ui/gfx/geometry/size_conversions.h" | 15 #include "ui/gfx/geometry/size_conversions.h" |
| 13 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 14 | 17 |
| 15 namespace chromecast { | 18 namespace chromecast { |
| 16 | 19 |
| 17 namespace { | 20 namespace { |
| 18 | 21 |
| 19 const int64_t kDisplayId = 1; | 22 const int64_t kDisplayId = 1; |
| 20 | 23 |
| 21 const int k720pWidth = 1280; | 24 // Helper to return the screen resolution (device pixels) |
| 22 const int k720pHeight = 720; | 25 // to use. |
| 23 | 26 gfx::Size GetScreenResolution() { |
| 24 // When CastScreen is first initialized, we may not have any display info | 27 if (GraphicsPropertiesShlib::IsSupported( |
| 25 // available. These constants hold the initial size that we default to, and | 28 GraphicsPropertiesShlib::k1080p, |
| 26 // the size can be updated when we have actual display info at hand with | 29 base::CommandLine::ForCurrentProcess()->argv())) { |
| 27 // UpdateDisplaySize(). | 30 return gfx::Size(1920, 1080); |
| 28 const int kInitDisplayWidth = k720pWidth; | 31 } else { |
| 29 const int kInitDisplayHeight = k720pHeight; | 32 return gfx::Size(1280, 720); |
| 33 } |
| 34 } |
| 30 | 35 |
| 31 } // namespace | 36 } // namespace |
| 32 | 37 |
| 33 CastScreen::~CastScreen() { | 38 CastScreen::~CastScreen() { |
| 34 } | 39 } |
| 35 | 40 |
| 36 void CastScreen::SetDisplayResizeCallback(const DisplayResizeCallback& cb) { | |
| 37 DCHECK(!cb.is_null()); | |
| 38 display_resize_cb_ = cb; | |
| 39 } | |
| 40 | |
| 41 void CastScreen::UpdateDisplaySize(const gfx::Size& size) { | |
| 42 display_.SetScaleAndBounds(1.0f, gfx::Rect(size)); | |
| 43 if (!display_resize_cb_.is_null()) | |
| 44 display_resize_cb_.Run(Size(size.width(), size.height())); | |
| 45 } | |
| 46 | |
| 47 gfx::Point CastScreen::GetCursorScreenPoint() { | 41 gfx::Point CastScreen::GetCursorScreenPoint() { |
| 48 return aura::Env::GetInstance()->last_mouse_location(); | 42 return aura::Env::GetInstance()->last_mouse_location(); |
| 49 } | 43 } |
| 50 | 44 |
| 51 bool CastScreen::IsWindowUnderCursor(gfx::NativeWindow window) { | 45 bool CastScreen::IsWindowUnderCursor(gfx::NativeWindow window) { |
| 52 NOTIMPLEMENTED(); | 46 NOTIMPLEMENTED(); |
| 53 return false; | 47 return false; |
| 54 } | 48 } |
| 55 | 49 |
| 56 gfx::NativeWindow CastScreen::GetWindowAtScreenPoint(const gfx::Point& point) { | 50 gfx::NativeWindow CastScreen::GetWindowAtScreenPoint(const gfx::Point& point) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 82 | 76 |
| 83 display::Display CastScreen::GetPrimaryDisplay() const { | 77 display::Display CastScreen::GetPrimaryDisplay() const { |
| 84 return display_; | 78 return display_; |
| 85 } | 79 } |
| 86 | 80 |
| 87 void CastScreen::AddObserver(display::DisplayObserver* observer) {} | 81 void CastScreen::AddObserver(display::DisplayObserver* observer) {} |
| 88 | 82 |
| 89 void CastScreen::RemoveObserver(display::DisplayObserver* observer) {} | 83 void CastScreen::RemoveObserver(display::DisplayObserver* observer) {} |
| 90 | 84 |
| 91 CastScreen::CastScreen() : display_(kDisplayId) { | 85 CastScreen::CastScreen() : display_(kDisplayId) { |
| 92 display_.SetScaleAndBounds(1.0f, | 86 // Device scale factor computed relative to 720p display |
| 93 gfx::Rect(kInitDisplayWidth, kInitDisplayHeight)); | 87 const gfx::Size size = GetScreenResolution(); |
| 88 const float device_scale_factor = size.height() / 720.0f; |
| 89 display_.SetScaleAndBounds(device_scale_factor, gfx::Rect(size)); |
| 94 } | 90 } |
| 95 | 91 |
| 96 } // namespace chromecast | 92 } // namespace chromecast |
| OLD | NEW |