forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcast_screen.cc
77 lines (61 loc) · 2.19 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
// 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 "base/feature_list.h"
#include "chromecast/base/cast_features.h"
#include "chromecast/public/graphics_properties_shlib.h"
#include "ui/aura/env.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 (base::FeatureList::IsEnabled(kTripleBuffer720)) {
return gfx::Size(1280, 720);
} else 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);
}
display::Display CastScreen::GetDisplayNearestWindow(
gfx::NativeWindow window) const {
return GetPrimaryDisplay();
}
CastScreen::CastScreen() {
// Device scale factor computed relative to 720p display
const gfx::Size size = GetScreenResolution();
const float device_scale_factor = size.height() / 720.0f;
OnDisplayChanged(device_scale_factor, gfx::Rect(size));
}
void CastScreen::OnDisplayChanged(float device_scale_factor, gfx::Rect bounds) {
VLOG(1) << __func__ << " device_scale_factor=" << device_scale_factor
<< " bounds=" << bounds.ToString();
display::Display display(kDisplayId);
display.SetScaleAndBounds(device_scale_factor, bounds);
ProcessDisplayChanged(display, true /* is_primary */);
}
} // namespace chromecast