summaryrefslogtreecommitdiffstats
path: root/chromium/ash/display/display_layout_store.h
blob: 67c3c2e523c631b547b7003ff2e44fdfb09691b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_DISPLAY_DISPLAY_LAYOUT_STORE_H_
#define ASH_DISPLAY_DISPLAY_LAYOUT_STORE_H_

#include <map>

#include "ash/ash_export.h"
#include "ash/display/display_layout.h"

namespace ash {
namespace internal {

class ASH_EXPORT DisplayLayoutStore {
 public:
  DisplayLayoutStore();
  ~DisplayLayoutStore();

  const DisplayLayout& default_display_layout() const {
    return default_display_layout_;
  }
  void SetDefaultDisplayLayout(const DisplayLayout& layout);

  // Registeres the display layout info for the specified display(s).
  void RegisterLayoutForDisplayIdPair(int64 id1,
                                      int64 id2,
                                      const DisplayLayout& layout);

  // If no layout is registered, it creatas new layout using
  // |default_display_layout_|.
  DisplayLayout GetRegisteredDisplayLayout(const DisplayIdPair& pair);

  // Returns the display layout for the display id pair
  // with display swapping applied.  That is, this returns
  // flipped layout if the displays are swapped.
  DisplayLayout ComputeDisplayLayoutForDisplayIdPair(
      const DisplayIdPair& display_pair);

  // Update the mirrored flag in the display layout for
  // |display_pair|.  This creates new display layout if no layout is
  // registered for |display_pair|.
  void UpdateMirrorStatus(const DisplayIdPair& display_pair,
                          bool mirrored);

  // Update the |primary_id| in the display layout for
  // |display_pair|.  This creates new display layout if no layout is
  // registered for |display_pair|.
  void UpdatePrimaryDisplayId(const DisplayIdPair& display_pair,
                              int64 display_id);

 private:
  // Creates new layout for display pair from |default_display_layout_|.
  DisplayLayout CreateDisplayLayout(const DisplayIdPair& display_pair);

  // The default display layout.
  DisplayLayout default_display_layout_;

  // Display layout per pair of devices.
  std::map<DisplayIdPair, DisplayLayout> paired_layouts_;

  DISALLOW_COPY_AND_ASSIGN(DisplayLayoutStore);
};

}  // namespace internal
}  // namespace ash

#endif  // ASH_DISPLAY_DISPLAY_LAYOUT_STORE_H_