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

Side by Side Diff: ui/display/chromeos/x11/native_display_delegate_x11.cc

Issue 2348953002: Remove stl_util's STLDeleteContainerPairSecondPointers from ui/. (Closed)
Patch Set: fix Created 4 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/display/chromeos/x11/native_display_delegate_x11.h" 5 #include "ui/display/chromeos/x11/native_display_delegate_x11.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 #include <X11/extensions/dpms.h> 9 #include <X11/extensions/dpms.h>
10 #include <X11/extensions/Xrandr.h> 10 #include <X11/extensions/Xrandr.h>
11 #include <X11/extensions/XInput2.h> 11 #include <X11/extensions/XInput2.h>
12 12
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/stl_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "ui/display/chromeos/x11/display_mode_x11.h" 18 #include "ui/display/chromeos/x11/display_mode_x11.h"
19 #include "ui/display/chromeos/x11/display_snapshot_x11.h" 19 #include "ui/display/chromeos/x11/display_snapshot_x11.h"
20 #include "ui/display/chromeos/x11/display_util_x11.h" 20 #include "ui/display/chromeos/x11/display_util_x11.h"
21 #include "ui/display/chromeos/x11/native_display_event_dispatcher_x11.h" 21 #include "ui/display/chromeos/x11/native_display_event_dispatcher_x11.h"
22 #include "ui/display/types/native_display_observer.h" 22 #include "ui/display/types/native_display_observer.h"
23 #include "ui/display/util/x11/edid_parser_x11.h" 23 #include "ui/display/util/x11/edid_parser_x11.h"
24 #include "ui/events/platform/platform_event_source.h" 24 #include "ui/events/platform/platform_event_source.h"
25 #include "ui/gfx/geometry/rect.h" 25 #include "ui/gfx/geometry/rect.h"
26 #include "ui/gfx/x/x11_error_tracker.h" 26 #include "ui/gfx/x/x11_error_tracker.h"
27 #include "ui/gfx/x/x11_types.h" 27 #include "ui/gfx/x/x11_types.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 : display_(gfx::GetXDisplay()), 107 : display_(gfx::GetXDisplay()),
108 window_(DefaultRootWindow(display_)), 108 window_(DefaultRootWindow(display_)),
109 background_color_argb_(0) {} 109 background_color_argb_(0) {}
110 110
111 NativeDisplayDelegateX11::~NativeDisplayDelegateX11() { 111 NativeDisplayDelegateX11::~NativeDisplayDelegateX11() {
112 if (ui::PlatformEventSource::GetInstance() && 112 if (ui::PlatformEventSource::GetInstance() &&
113 platform_event_dispatcher_.get()) { 113 platform_event_dispatcher_.get()) {
114 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher( 114 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(
115 platform_event_dispatcher_.get()); 115 platform_event_dispatcher_.get());
116 } 116 }
117
118 base::STLDeleteContainerPairSecondPointers(modes_.begin(), modes_.end());
119 } 117 }
120 118
121 void NativeDisplayDelegateX11::Initialize() { 119 void NativeDisplayDelegateX11::Initialize() {
122 int error_base_ignored = 0; 120 int error_base_ignored = 0;
123 int xrandr_event_base = 0; 121 int xrandr_event_base = 0;
124 XRRQueryExtension(display_, &xrandr_event_base, &error_base_ignored); 122 XRRQueryExtension(display_, &xrandr_event_base, &error_base_ignored);
125 123
126 helper_delegate_.reset(new HelperDelegateX11(this)); 124 helper_delegate_.reset(new HelperDelegateX11(this));
127 platform_event_dispatcher_.reset(new NativeDisplayEventDispatcherX11( 125 platform_event_dispatcher_.reset(new NativeDisplayEventDispatcherX11(
128 helper_delegate_.get(), xrandr_event_base)); 126 helper_delegate_.get(), xrandr_event_base));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 observers_.AddObserver(observer); 276 observers_.AddObserver(observer);
279 } 277 }
280 278
281 void NativeDisplayDelegateX11::RemoveObserver(NativeDisplayObserver* observer) { 279 void NativeDisplayDelegateX11::RemoveObserver(NativeDisplayObserver* observer) {
282 observers_.RemoveObserver(observer); 280 observers_.RemoveObserver(observer);
283 } 281 }
284 282
285 void NativeDisplayDelegateX11::InitModes() { 283 void NativeDisplayDelegateX11::InitModes() {
286 CHECK(screen_) << "Server not grabbed"; 284 CHECK(screen_) << "Server not grabbed";
287 285
288 base::STLDeleteContainerPairSecondPointers(modes_.begin(), modes_.end());
289 modes_.clear(); 286 modes_.clear();
290 287
291 for (int i = 0; i < screen_->nmode; ++i) { 288 for (int i = 0; i < screen_->nmode; ++i) {
292 const XRRModeInfo& info = screen_->modes[i]; 289 const XRRModeInfo& info = screen_->modes[i];
293 float refresh_rate = 0.0f; 290 float refresh_rate = 0.0f;
294 if (info.hTotal && info.vTotal) { 291 if (info.hTotal && info.vTotal) {
295 refresh_rate = 292 refresh_rate =
296 static_cast<float>(info.dotClock) / 293 static_cast<float>(info.dotClock) /
297 (static_cast<float>(info.hTotal) * static_cast<float>(info.vTotal)); 294 (static_cast<float>(info.hTotal) * static_cast<float>(info.vTotal));
298 } 295 }
299 296
300 modes_.insert( 297 modes_.insert(std::make_pair(
301 std::make_pair(info.id, 298 info.id, base::MakeUnique<DisplayModeX11>(
302 new DisplayModeX11(gfx::Size(info.width, info.height), 299 gfx::Size(info.width, info.height),
303 info.modeFlags & RR_Interlace, 300 info.modeFlags & RR_Interlace, refresh_rate, info.id)));
304 refresh_rate,
305 info.id)));
306 } 301 }
307 } 302 }
308 303
309 DisplaySnapshotX11* NativeDisplayDelegateX11::InitDisplaySnapshot( 304 DisplaySnapshotX11* NativeDisplayDelegateX11::InitDisplaySnapshot(
310 RROutput output, 305 RROutput output,
311 XRROutputInfo* info, 306 XRROutputInfo* info,
312 std::set<RRCrtc>* last_used_crtcs, 307 std::set<RRCrtc>* last_used_crtcs,
313 int index) { 308 int index) {
314 int64_t display_id = 0; 309 int64_t display_id = 0;
315 display::EDIDParserX11 edid_parser(output); 310 display::EDIDParserX11 edid_parser(output);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 XSetForeground(display_, gc, color.pixel); 650 XSetForeground(display_, gc, color.pixel);
656 XSetFillStyle(display_, gc, FillSolid); 651 XSetFillStyle(display_, gc, FillSolid);
657 int width = DisplayWidth(display_, DefaultScreen(display_)); 652 int width = DisplayWidth(display_, DefaultScreen(display_));
658 int height = DisplayHeight(display_, DefaultScreen(display_)); 653 int height = DisplayHeight(display_, DefaultScreen(display_));
659 XFillRectangle(display_, window_, gc, 0, 0, width, height); 654 XFillRectangle(display_, window_, gc, 0, 0, width, height);
660 XFreeGC(display_, gc); 655 XFreeGC(display_, gc);
661 XFreeColors(display_, colormap, &color.pixel, 1, 0); 656 XFreeColors(display_, colormap, &color.pixel, 1, 0);
662 } 657 }
663 658
664 } // namespace ui 659 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698