Home | History | Annotate | Download | only in display
      1 // Copyright 2013 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.
      4 
      5 #ifndef ASH_DISPLAY_DISPLAY_LAYOUT_STORE_H_
      6 #define ASH_DISPLAY_DISPLAY_LAYOUT_STORE_H_
      7 
      8 #include <map>
      9 
     10 #include "ash/ash_export.h"
     11 #include "ash/display/display_layout.h"
     12 
     13 namespace ash {
     14 namespace internal {
     15 
     16 class ASH_EXPORT DisplayLayoutStore {
     17  public:
     18   DisplayLayoutStore();
     19   ~DisplayLayoutStore();
     20 
     21   const DisplayLayout& default_display_layout() const {
     22     return default_display_layout_;
     23   }
     24   void SetDefaultDisplayLayout(const DisplayLayout& layout);
     25 
     26   // Registeres the display layout info for the specified display(s).
     27   void RegisterLayoutForDisplayIdPair(int64 id1,
     28                                       int64 id2,
     29                                       const DisplayLayout& layout);
     30 
     31   // If no layout is registered, it creatas new layout using
     32   // |default_display_layout_|.
     33   DisplayLayout GetRegisteredDisplayLayout(const DisplayIdPair& pair);
     34 
     35   // Returns the display layout for the display id pair
     36   // with display swapping applied.  That is, this returns
     37   // flipped layout if the displays are swapped.
     38   DisplayLayout ComputeDisplayLayoutForDisplayIdPair(
     39       const DisplayIdPair& display_pair);
     40 
     41   // Update the mirrored flag in the display layout for
     42   // |display_pair|.  This creates new display layout if no layout is
     43   // registered for |display_pair|.
     44   void UpdateMirrorStatus(const DisplayIdPair& display_pair,
     45                           bool mirrored);
     46 
     47   // Update the |primary_id| in the display layout for
     48   // |display_pair|.  This creates new display layout if no layout is
     49   // registered for |display_pair|.
     50   void UpdatePrimaryDisplayId(const DisplayIdPair& display_pair,
     51                               int64 display_id);
     52 
     53  private:
     54   // Creates new layout for display pair from |default_display_layout_|.
     55   DisplayLayout CreateDisplayLayout(const DisplayIdPair& display_pair);
     56 
     57   // The default display layout.
     58   DisplayLayout default_display_layout_;
     59 
     60   // Display layout per pair of devices.
     61   std::map<DisplayIdPair, DisplayLayout> paired_layouts_;
     62 
     63   DISALLOW_COPY_AND_ASSIGN(DisplayLayoutStore);
     64 };
     65 
     66 }  // namespace internal
     67 }  // namespace ash
     68 
     69 #endif  // ASH_DISPLAY_DISPLAY_LAYOUT_STORE_H_
     70