Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: ui/ozone/platform/dri/chromeos/display_message_handler.cc

Issue 522463005: [Ozone-GBM] Handle GPU crashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reland of: [Ozone-GBM] Handle GPU crashes Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/ozone/platform/dri/chromeos/display_message_handler.h" 5 #include "ui/ozone/platform/dri/chromeos/display_message_handler.h"
6 6
7 #include "ui/display/types/chromeos/display_mode.h" 7 #include "ui/display/types/chromeos/display_mode.h"
8 #include "ui/display/types/chromeos/display_snapshot.h" 8 #include "ui/display/types/chromeos/display_snapshot.h"
9 #include "ui/ozone/common/chromeos/display_util.h" 9 #include "ui/ozone/common/chromeos/display_util.h"
10 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" 10 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
11 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" 11 #include "ui/ozone/common/gpu/ozone_gpu_messages.h"
12 #include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h" 12 #include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 namespace {
17
18 class FindDisplayById {
19 public:
20 FindDisplayById(int64_t display_id) : display_id_(display_id) {}
21
22 bool operator()(const DisplaySnapshot_Params& display) const {
23 return display.display_id == display_id_;
24 }
25
26 private:
27 int64_t display_id_;
28 };
29
30 } // namespace
31
16 DisplayMessageHandler::DisplayMessageHandler( 32 DisplayMessageHandler::DisplayMessageHandler(
17 scoped_ptr<NativeDisplayDelegateDri> ndd) 33 scoped_ptr<NativeDisplayDelegateDri> ndd)
18 : sender_(NULL), 34 : sender_(NULL),
19 ndd_(ndd.Pass()) {} 35 ndd_(ndd.Pass()) {}
20 36
21 DisplayMessageHandler::~DisplayMessageHandler() {} 37 DisplayMessageHandler::~DisplayMessageHandler() {}
22 38
23 void DisplayMessageHandler::OnChannelEstablished(IPC::Sender* sender) { 39 void DisplayMessageHandler::OnChannelEstablished(IPC::Sender* sender) {
24 sender_ = sender; 40 sender_ = sender;
25 } 41 }
(...skipping 12 matching lines...) Expand all
38 IPC_MESSAGE_UNHANDLED(handled = false); 54 IPC_MESSAGE_UNHANDLED(handled = false);
39 IPC_END_MESSAGE_MAP() 55 IPC_END_MESSAGE_MAP()
40 56
41 return handled; 57 return handled;
42 } 58 }
43 59
44 void DisplayMessageHandler::OnForceDPMSOn() { 60 void DisplayMessageHandler::OnForceDPMSOn() {
45 ndd_->ForceDPMSOn(); 61 ndd_->ForceDPMSOn();
46 } 62 }
47 63
48 void DisplayMessageHandler::OnRefreshNativeDisplays() { 64 void DisplayMessageHandler::OnRefreshNativeDisplays(
65 const std::vector<DisplaySnapshot_Params>& cached_displays) {
49 std::vector<DisplaySnapshot_Params> displays; 66 std::vector<DisplaySnapshot_Params> displays;
50 std::vector<DisplaySnapshot*> native_displays = ndd_->GetDisplays(); 67 std::vector<DisplaySnapshot*> native_displays = ndd_->GetDisplays();
68
69 // If any of the cached displays are in the list of new displays then apply
70 // their configuration immediately.
71 for (size_t i = 0; i < native_displays.size(); ++i) {
72 std::vector<DisplaySnapshot_Params>::const_iterator it =
73 std::find_if(cached_displays.begin(),
74 cached_displays.end(),
75 FindDisplayById(native_displays[i]->display_id()));
76
77 if (it == cached_displays.end())
78 continue;
79
80 if (it->has_current_mode)
81 OnConfigureNativeDisplay(it->display_id, it->current_mode, it->origin);
82 else
83 OnDisableNativeDisplay(it->display_id);
84 }
85
51 for (size_t i = 0; i < native_displays.size(); ++i) 86 for (size_t i = 0; i < native_displays.size(); ++i)
52 displays.push_back(GetDisplaySnapshotParams(*native_displays[i])); 87 displays.push_back(GetDisplaySnapshotParams(*native_displays[i]));
53 88
54 sender_->Send(new OzoneHostMsg_UpdateNativeDisplays(displays)); 89 sender_->Send(new OzoneHostMsg_UpdateNativeDisplays(displays));
55 } 90 }
56 91
57 void DisplayMessageHandler::OnConfigureNativeDisplay( 92 void DisplayMessageHandler::OnConfigureNativeDisplay(
58 int64_t id, 93 int64_t id,
59 const DisplayMode_Params& mode_param, 94 const DisplayMode_Params& mode_param,
60 const gfx::Point& origin) { 95 const gfx::Point& origin) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 130
96 void DisplayMessageHandler::OnDisableNativeDisplay(int64_t id) { 131 void DisplayMessageHandler::OnDisableNativeDisplay(int64_t id) {
97 DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id); 132 DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id);
98 if (display) 133 if (display)
99 ndd_->Configure(*display, NULL, gfx::Point()); 134 ndd_->Configure(*display, NULL, gfx::Point());
100 else 135 else
101 LOG(ERROR) << "There is no display with ID " << id; 136 LOG(ERROR) << "There is no display with ID " << id;
102 } 137 }
103 138
104 } // namespace ui 139 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698