Mailbox support for texture layers.
[chromium-blink-merge.git] / ui / gfx / display.h
blob5abe1be2cbc8a78c16a33b5da44c9695a323ddc3
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_GFX_DISPLAY_H_
6 #define UI_GFX_DISPLAY_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "ui/base/ui_export.h"
11 #include "ui/gfx/rect.h"
13 namespace gfx {
15 // Note: The screen and display currently uses pixel coordinate
16 // system. For platforms that support DIP (density independent pixel),
17 // |bounds()| and |work_area| will return values in DIP coordinate
18 // system, not in backing pixels.
19 class UI_EXPORT Display {
20 public:
21 // Creates a display with kInvalidDisplayID as default.
22 Display();
23 explicit Display(int64 id);
24 Display(int64 id, const Rect& bounds);
25 ~Display();
27 // Returns the forced device scale factor, which is given by
28 // "--force-device-scale-factor".
29 static float GetForcedDeviceScaleFactor();
31 // Returns 64-bit persistent ID for the specified manufacturer's ID and
32 // serial#.
33 static int64 GetID(uint16 manufacturer_id, uint32 serial_number);
35 // Sets/Gets unique identifier associated with the display.
36 // -1 means invalid display and it doesn't not exit.
37 int64 id() const { return id_; }
38 void set_id(int64 id) { id_ = id; }
40 // Gets/Sets the display's bounds in gfx::Screen's coordinates.
41 const Rect& bounds() const { return bounds_; }
42 void set_bounds(const Rect& bounds) { bounds_ = bounds; }
44 // Gets/Sets the display's work area in gfx::Screen's coordinates.
45 const Rect& work_area() const { return work_area_; }
46 void set_work_area(const Rect& work_area) { work_area_ = work_area; }
48 // Output device's pixel scale factor. This specifies how much the
49 // UI should be scaled when the actual output has more pixels than
50 // standard displays (which is around 100~120dpi.) The potential return
51 // values depend on each platforms.
52 float device_scale_factor() const { return device_scale_factor_; }
53 void set_device_scale_factor(float scale) { device_scale_factor_ = scale; }
55 // Utility functions that just return the size of display and
56 // work area.
57 const Size& size() const { return bounds_.size(); }
58 const Size& work_area_size() const { return work_area_.size(); }
60 // Returns the work area insets.
61 Insets GetWorkAreaInsets() const;
63 // Sets the device scale factor and display bounds in pixel. This
64 // updates the work are using the same insets between old bounds and
65 // work area.
66 void SetScaleAndBounds(float device_scale_factor,
67 const gfx::Rect& bounds_in_pixel);
69 // Sets the display's size. This updates the work area using the same insets
70 // between old bounds and work area.
71 void SetSize(const gfx::Size& size_in_pixel);
73 // Computes and updates the display's work are using
74 // |work_area_insets| and the bounds.
75 void UpdateWorkAreaFromInsets(const gfx::Insets& work_area_insets);
77 // Returns the display's size in pixel coordinates.
78 gfx::Size GetSizeInPixel() const;
80 #if defined(USE_AURA)
81 // TODO(oshima|skuhne): Eliminate the use of bounds_in_pixel in events_x.cc
82 // and remove bounds_in_pixel from gfx::Display.
83 // Returns the display's bounds in pixel coordinates.
84 const Rect& bounds_in_pixel() const { return bounds_in_pixel_; }
85 #endif
87 // Returns a string representation of the display;
88 std::string ToString() const;
90 // True if the display contains valid display id.
91 bool is_valid() const { return id_ != kInvalidDisplayID; }
93 static const int64 kInvalidDisplayID;
95 private:
96 int64 id_;
97 Rect bounds_;
98 Rect work_area_;
99 #if defined(USE_AURA)
100 Rect bounds_in_pixel_;
101 #endif
102 float device_scale_factor_;
105 } // namespace gfx
107 #endif // UI_GFX_DISPLAY_H_