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 "ui/aura/env.h" | 9 #include "ui/aura/env.h" |
10 #include "ui/display/screen.h" | 10 #include "ui/display/screen.h" |
11 #include "ui/gfx/geometry/rect_conversions.h" | 11 #include "ui/gfx/geometry/rect_conversions.h" |
12 #include "ui/gfx/geometry/size_conversions.h" | 12 #include "ui/gfx/geometry/size_conversions.h" |
13 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
14 | 14 |
15 namespace chromecast { | 15 namespace chromecast { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const int64_t kDisplayId = 1; | 19 const int64_t kDisplayId = 1; |
20 | 20 |
21 const int k720pWidth = 1280; | |
22 const int k720pHeight = 720; | |
23 | |
24 // When CastScreen is first initialized, we may not have any display info | |
25 // available. These constants hold the initial size that we default to, and | |
26 // the size can be updated when we have actual display info at hand with | |
27 // UpdateDisplaySize(). | |
28 const int kInitDisplayWidth = k720pWidth; | |
29 const int kInitDisplayHeight = k720pHeight; | |
30 | |
31 } // namespace | 21 } // namespace |
32 | 22 |
33 CastScreen::~CastScreen() { | 23 CastScreen::~CastScreen() { |
34 } | 24 } |
35 | 25 |
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() { | 26 gfx::Point CastScreen::GetCursorScreenPoint() { |
48 return aura::Env::GetInstance()->last_mouse_location(); | 27 return aura::Env::GetInstance()->last_mouse_location(); |
49 } | 28 } |
50 | 29 |
51 bool CastScreen::IsWindowUnderCursor(gfx::NativeWindow window) { | 30 bool CastScreen::IsWindowUnderCursor(gfx::NativeWindow window) { |
52 NOTIMPLEMENTED(); | 31 NOTIMPLEMENTED(); |
53 return false; | 32 return false; |
54 } | 33 } |
55 | 34 |
56 gfx::NativeWindow CastScreen::GetWindowAtScreenPoint(const gfx::Point& point) { | 35 gfx::NativeWindow CastScreen::GetWindowAtScreenPoint(const gfx::Point& point) { |
(...skipping 24 matching lines...) Expand all Loading... |
81 } | 60 } |
82 | 61 |
83 display::Display CastScreen::GetPrimaryDisplay() const { | 62 display::Display CastScreen::GetPrimaryDisplay() const { |
84 return display_; | 63 return display_; |
85 } | 64 } |
86 | 65 |
87 void CastScreen::AddObserver(display::DisplayObserver* observer) {} | 66 void CastScreen::AddObserver(display::DisplayObserver* observer) {} |
88 | 67 |
89 void CastScreen::RemoveObserver(display::DisplayObserver* observer) {} | 68 void CastScreen::RemoveObserver(display::DisplayObserver* observer) {} |
90 | 69 |
91 CastScreen::CastScreen() : display_(kDisplayId) { | 70 CastScreen::CastScreen(const gfx::Size& size) : display_(kDisplayId) { |
92 display_.SetScaleAndBounds(1.0f, | 71 // Device scale factor computed relative to 720p display |
93 gfx::Rect(kInitDisplayWidth, kInitDisplayHeight)); | 72 const float device_scale_factor = size.height() / 720.0f; |
| 73 display_.SetScaleAndBounds(device_scale_factor, gfx::Rect(size)); |
94 } | 74 } |
95 | 75 |
96 } // namespace chromecast | 76 } // namespace chromecast |
OLD | NEW |