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

Unified Diff: ui/gfx/display.cc

Issue 1563183008: Added capability on Windows to get the physical dimensions of your attached monitors. Also added th… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments 2 Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/display.cc
diff --git a/ui/gfx/display.cc b/ui/gfx/display.cc
index 1777e87e5433822f6769e053a6459a0cd18499dd..fcd860ee29de907e72a531fc438dd591664dea32 100644
--- a/ui/gfx/display.cc
+++ b/ui/gfx/display.cc
@@ -5,6 +5,7 @@
#include "ui/gfx/display.h"
#include <algorithm>
+#include <vector>
#include "base/command_line.h"
#include "base/logging.h"
@@ -77,14 +78,17 @@ Display::Display()
: id_(kInvalidDisplayID),
device_scale_factor_(GetForcedDeviceScaleFactor()),
rotation_(ROTATE_0),
- touch_support_(TOUCH_SUPPORT_UNKNOWN) {
-}
+ touch_support_(TOUCH_SUPPORT_UNKNOWN),
+ physical_width_mm_(0),
+ physical_height_mm_(0) {}
Display::Display(int64_t id)
: id_(id),
device_scale_factor_(GetForcedDeviceScaleFactor()),
rotation_(ROTATE_0),
- touch_support_(TOUCH_SUPPORT_UNKNOWN) {}
+ touch_support_(TOUCH_SUPPORT_UNKNOWN),
+ physical_width_mm_(0),
+ physical_height_mm_(0) {}
Display::Display(int64_t id, const gfx::Rect& bounds)
: id_(id),
@@ -92,7 +96,9 @@ Display::Display(int64_t id, const gfx::Rect& bounds)
work_area_(bounds),
device_scale_factor_(GetForcedDeviceScaleFactor()),
rotation_(ROTATE_0),
- touch_support_(TOUCH_SUPPORT_UNKNOWN) {
+ touch_support_(TOUCH_SUPPORT_UNKNOWN),
+ physical_width_mm_(0),
+ physical_height_mm_(0) {
#if defined(USE_AURA)
SetScaleAndBounds(device_scale_factor_, bounds);
#endif
@@ -195,6 +201,20 @@ bool Display::IsInternal() const {
return is_valid() && (id_ == internal_display_id_);
}
+bool Display::IsPhysicalSizeAvailable() const {
+ return physical_width_mm_ != 0 && physical_height_mm_ != 0;
+}
+
+gfx::Size Display::GetPhysicalSizeMm() const {
+ DCHECK(IsPhysicalSizeAvailable());
+ return gfx::Size(physical_width_mm_, physical_height_mm_);
+}
+
+void Display::SetPhysicalSize(int width_mm, int height_mm) {
+ physical_width_mm_ = width_mm;
+ physical_height_mm_ = height_mm;
+}
+
// static
int64_t Display::InternalDisplayId() {
DCHECK_NE(kInvalidDisplayID, internal_display_id_);

Powered by Google App Engine
This is Rietveld 408576698