forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcast_screen.cc
92 lines (70 loc) · 2.33 KB
/
cast_screen.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/graphics/cast_screen.h"
#include <stdint.h>
#include "base/command_line.h"
#include "chromecast/public/graphics_properties_shlib.h"
#include "ui/aura/env.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/native_widget_types.h"
namespace chromecast {
namespace {
const int64_t kDisplayId = 1;
// Helper to return the screen resolution (device pixels)
// to use.
gfx::Size GetScreenResolution() {
if (GraphicsPropertiesShlib::IsSupported(
GraphicsPropertiesShlib::k1080p,
base::CommandLine::ForCurrentProcess()->argv())) {
return gfx::Size(1920, 1080);
} else {
return gfx::Size(1280, 720);
}
}
} // namespace
CastScreen::~CastScreen() {
}
gfx::Point CastScreen::GetCursorScreenPoint() {
return aura::Env::GetInstance()->last_mouse_location();
}
bool CastScreen::IsWindowUnderCursor(gfx::NativeWindow window) {
NOTIMPLEMENTED();
return false;
}
gfx::NativeWindow CastScreen::GetWindowAtScreenPoint(const gfx::Point& point) {
return gfx::NativeWindow(nullptr);
}
int CastScreen::GetNumDisplays() const {
return 1;
}
std::vector<display::Display> CastScreen::GetAllDisplays() const {
return std::vector<display::Display>(1, display_);
}
display::Display CastScreen::GetDisplayNearestWindow(
gfx::NativeWindow window) const {
return display_;
}
display::Display CastScreen::GetDisplayNearestPoint(
const gfx::Point& point) const {
return display_;
}
display::Display CastScreen::GetDisplayMatching(
const gfx::Rect& match_rect) const {
return display_;
}
display::Display CastScreen::GetPrimaryDisplay() const {
return display_;
}
void CastScreen::AddObserver(display::DisplayObserver* observer) {}
void CastScreen::RemoveObserver(display::DisplayObserver* observer) {}
CastScreen::CastScreen() : display_(kDisplayId) {
// Device scale factor computed relative to 720p display
const gfx::Size size = GetScreenResolution();
const float device_scale_factor = size.height() / 720.0f;
display_.SetScaleAndBounds(device_scale_factor, gfx::Rect(size));
}
} // namespace chromecast