summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorerg <erg@chromium.org>2016-01-22 11:11:30 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-22 19:13:45 +0000
commit3537f56b3e87d722b1e7caa3d996874f3199f750 (patch)
treef539a80b6dc8c224b338f2649995bdbdae64077e /ash
parentce56df4e76af412e75b758fe33b304bc4971ab7a (diff)
downloadchromium_src-3537f56b3e87d722b1e7caa3d996874f3199f750.zip
chromium_src-3537f56b3e87d722b1e7caa3d996874f3199f750.tar.gz
chromium_src-3537f56b3e87d722b1e7caa3d996874f3199f750.tar.bz2
Revert of Start of display management for mus (patchset #5 id:80001 of https://codereview.chromium.org/1615023004/ )
Reason for revert: Consistently causing crashes on mash startup: [0122/110054:FATAL:default_logger_impl.cc(51)] Check failed: ptr_. #0 0x7fc46007507e base::debug::StackTrace::StackTrace() #1 0x7fc4600c0bcf logging::LogMessage::~LogMessage() #2 0x7fc45fe9ac30 mojo::internal::(anonymous namespace)::LogMessage() #3 0x7fc45fe9a2e5 mojo::internal::LogMessage::~LogMessage() #4 0x7fc45de1a33c mojo::StructPtr<>::operator->() #5 0x7fc45fff3fc7 mus::ws::ConnectionManager::AddObserver() #6 0x7fc45fe327f3 mus::mojom::DisplayManagerStub::Accept() #7 0x7fc45fe07f64 mojo::internal::Router::HandleIncomingMessage() #8 0x7fc45fe07b41 mojo::internal::Router::HandleIncomingMessageThunk::Accept() #9 0x7fc45fe32a9e mus::mojom::DisplayManagerRequestValidator::Accept() Original issue's description: > Start of display management for mus > > This adds a DisplayManager interface that you get from mus. You can > then attach an observer to observe display related changes. > > BUG=548429 > TEST=none > R=ben@chromium.org > > Committed: https://crrev.com/bc2281a7a7576f5b4da85986298322b3c9d2234e > Cr-Commit-Position: refs/heads/master@{#370880} TBR=ben@chromium.org,sky@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=548429 Review URL: https://codereview.chromium.org/1618963005 Cr-Commit-Position: refs/heads/master@{#371005}
Diffstat (limited to 'ash')
-rw-r--r--ash/display/screen_ash.cc47
1 files changed, 41 insertions, 6 deletions
diff --git a/ash/display/screen_ash.cc b/ash/display/screen_ash.cc
index 477c710..6008922 100644
--- a/ash/display/screen_ash.cc
+++ b/ash/display/screen_ash.cc
@@ -17,7 +17,6 @@
#include "ui/aura/env.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/gfx/display.h"
-#include "ui/gfx/display_finder.h"
#include "ui/gfx/screen.h"
namespace ash {
@@ -28,6 +27,42 @@ DisplayManager* GetDisplayManager() {
return Shell::GetInstance()->display_manager();
}
+gfx::Display FindDisplayNearestPoint(const std::vector<gfx::Display>& displays,
+ const gfx::Point& point) {
+ int min_distance = INT_MAX;
+ const gfx::Display* nearest_display = NULL;
+ for (std::vector<gfx::Display>::const_iterator iter = displays.begin();
+ iter != displays.end(); ++iter) {
+ const gfx::Display& display = *iter;
+ int distance = display.bounds().ManhattanDistanceToPoint(point);
+ if (distance < min_distance) {
+ min_distance = distance;
+ nearest_display = &display;
+ }
+ }
+ // There should always be at least one display that is less than INT_MAX away.
+ DCHECK(nearest_display);
+ return *nearest_display;
+}
+
+const gfx::Display* FindDisplayMatching(
+ const std::vector<gfx::Display>& displays,
+ const gfx::Rect& match_rect) {
+ int max_area = 0;
+ const gfx::Display* matching = NULL;
+ for (std::vector<gfx::Display>::const_iterator iter = displays.begin();
+ iter != displays.end(); ++iter) {
+ const gfx::Display& display = *iter;
+ gfx::Rect intersect = gfx::IntersectRects(display.bounds(), match_rect);
+ int area = intersect.width() * intersect.height();
+ if (area > max_area) {
+ max_area = area;
+ matching = &display;
+ }
+ }
+ return matching;
+}
+
class ScreenForShutdown : public gfx::Screen {
public:
explicit ScreenForShutdown(ScreenAsh* screen_ash)
@@ -49,11 +84,11 @@ class ScreenForShutdown : public gfx::Screen {
return primary_display_;
}
gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override {
- return *gfx::FindDisplayNearestPoint(display_list_, point);
+ return FindDisplayNearestPoint(display_list_, point);
}
gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override {
const gfx::Display* matching =
- gfx::FindDisplayWithBiggestIntersection(display_list_, match_rect);
+ FindDisplayMatching(display_list_, match_rect);
// Fallback to the primary display if there is no matching display.
return matching ? *matching : GetPrimaryDisplay();
}
@@ -152,14 +187,14 @@ gfx::Display ScreenAsh::GetDisplayNearestPoint(const gfx::Point& point) const {
// Fallback to the display that has the shortest Manhattan distance from
// the |point|. This is correct in the only areas that matter, namely in the
// corners between the physical screens.
- return *gfx::FindDisplayNearestPoint(
- GetDisplayManager()->active_display_list(), point);
+ return FindDisplayNearestPoint(GetDisplayManager()->active_display_list(),
+ point);
}
gfx::Display ScreenAsh::GetDisplayMatching(const gfx::Rect& match_rect) const {
if (match_rect.IsEmpty())
return GetDisplayNearestPoint(match_rect.origin());
- const gfx::Display* matching = gfx::FindDisplayWithBiggestIntersection(
+ const gfx::Display* matching = FindDisplayMatching(
GetDisplayManager()->active_display_list(), match_rect);
// Fallback to the primary display if there is no matching display.
return matching ? *matching : GetPrimaryDisplay();