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

Side by Side Diff: ui/display/types/display_mode.cc

Issue 2646213002: Write mojom and StructTraits for DisplaySnapshot. (Closed)
Patch Set: Add Clone() for DisplaySnapShotMojo and refactor unit test. Created 3 years, 10 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/types/display_mode.h" 5 #include "ui/display/types/display_mode.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 9
10 namespace display { 10 namespace display {
11 11
12 DisplayMode::DisplayMode(const gfx::Size& size, 12 DisplayMode::DisplayMode(const gfx::Size& size,
13 bool interlaced, 13 bool interlaced,
14 float refresh_rate) 14 float refresh_rate)
15 : size_(size), 15 : size_(size),
16 is_interlaced_(interlaced), 16 is_interlaced_(interlaced),
17 refresh_rate_(refresh_rate) {} 17 refresh_rate_(refresh_rate) {}
18 18
19 DisplayMode::~DisplayMode() {} 19 DisplayMode::~DisplayMode() {}
20 20
21 std::unique_ptr<DisplayMode> DisplayMode::Clone() const { 21 bool DisplayMode::operator==(const DisplayMode& other) const {
22 return base::WrapUnique(new DisplayMode(size_, 22 return this->size() == other.size() &&
23 is_interlaced_, 23 this->is_interlaced() == other.is_interlaced() &&
24 refresh_rate_)); 24 this->refresh_rate() == other.refresh_rate();
25 }
26
27 bool DisplayMode::operator!=(const DisplayMode& other) const {
28 return !operator==(other);
25 } 29 }
26 30
27 std::string DisplayMode::ToString() const { 31 std::string DisplayMode::ToString() const {
28 return base::StringPrintf("[%dx%d %srate=%f]", 32 return base::StringPrintf("[%dx%d %srate=%f]",
29 size_.width(), 33 size_.width(),
30 size_.height(), 34 size_.height(),
31 is_interlaced_ ? "interlaced " : "", 35 is_interlaced_ ? "interlaced " : "",
32 refresh_rate_); 36 refresh_rate_);
33 } 37 }
34 38
39 std::unique_ptr<DisplayMode> DisplayMode::Clone() const {
kylechar 2017/02/15 16:48:45 Please keep the order consistent between header an
thanhph 2017/02/16 11:48:21 Nice catch. Thanks!
40 return base::WrapUnique(
41 new DisplayMode(size_, is_interlaced_, refresh_rate_));
42 }
43
35 void PrintTo(const DisplayMode& mode, std::ostream* os) { 44 void PrintTo(const DisplayMode& mode, std::ostream* os) {
36 *os << mode.ToString(); 45 *os << mode.ToString();
37 } 46 }
38 47
39 } // namespace display 48 } // namespace display
OLDNEW
« ui/display/mojo/display_struct_traits_unittest.cc ('K') | « ui/display/types/display_mode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698