| OLD | NEW | 
|    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 #ifndef COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ |    5 #ifndef COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ | 
|    6 #define COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ |    6 #define COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ | 
|    7  |    7  | 
|    8 #include <vector> |    8 #include <vector> | 
|    9  |    9  | 
|   10 #include "base/logging.h" |   10 #include "base/logging.h" | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|   24 // Server side representation of a view. Delegate is informed of interesting |   24 // Server side representation of a view. Delegate is informed of interesting | 
|   25 // events. |   25 // events. | 
|   26 // |   26 // | 
|   27 // It is assumed that all functions that mutate the tree have validated the |   27 // It is assumed that all functions that mutate the tree have validated the | 
|   28 // mutation is possible before hand. For example, Reorder() assumes the supplied |   28 // mutation is possible before hand. For example, Reorder() assumes the supplied | 
|   29 // view is a child and not already in position. |   29 // view is a child and not already in position. | 
|   30 // |   30 // | 
|   31 // ServerViews do not own their children. If you delete a view that has children |   31 // ServerViews do not own their children. If you delete a view that has children | 
|   32 // the children are implicitly removed. Similarly if a view has a parent and the |   32 // the children are implicitly removed. Similarly if a view has a parent and the | 
|   33 // view is deleted the deleted view is implicitly removed from the parent. |   33 // view is deleted the deleted view is implicitly removed from the parent. | 
|   34 class ServerView { |   34 class ServerView : public mojo::CompositorFrameReceiver { | 
|   35  public: |   35  public: | 
|   36   ServerView(ServerViewDelegate* delegate, const ViewId& id); |   36   ServerView(ServerViewDelegate* delegate, const ViewId& id); | 
|   37   virtual ~ServerView(); |   37   ~ServerView() override; | 
|   38  |   38  | 
|   39   void AddObserver(ServerViewObserver* observer); |   39   void AddObserver(ServerViewObserver* observer); | 
|   40   void RemoveObserver(ServerViewObserver* observer); |   40   void RemoveObserver(ServerViewObserver* observer); | 
|   41  |   41  | 
 |   42   void Bind(mojo::InterfaceRequest<CompositorFrameReceiver> request); | 
 |   43  | 
|   42   const ViewId& id() const { return id_; } |   44   const ViewId& id() const { return id_; } | 
|   43  |   45  | 
|   44   void Add(ServerView* child); |   46   void Add(ServerView* child); | 
|   45   void Remove(ServerView* child); |   47   void Remove(ServerView* child); | 
|   46   void Reorder(ServerView* child, |   48   void Reorder(ServerView* child, | 
|   47                ServerView* relative, |   49                ServerView* relative, | 
|   48                mojo::OrderDirection direction); |   50                mojo::OrderDirection direction); | 
|   49  |   51  | 
|   50   const gfx::Rect& bounds() const { return bounds_; } |   52   const gfx::Rect& bounds() const { return bounds_; } | 
|   51   void SetBounds(const gfx::Rect& bounds); |   53   void SetBounds(const gfx::Rect& bounds); | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   86     return text_input_state_; |   88     return text_input_state_; | 
|   87   } |   89   } | 
|   88  |   90  | 
|   89   // Returns true if this view is attached to a root and all ancestors are |   91   // Returns true if this view is attached to a root and all ancestors are | 
|   90   // visible. |   92   // visible. | 
|   91   bool IsDrawn() const; |   93   bool IsDrawn() const; | 
|   92  |   94  | 
|   93   void SetSurfaceId(cc::SurfaceId surface_id); |   95   void SetSurfaceId(cc::SurfaceId surface_id); | 
|   94   const cc::SurfaceId& surface_id() const { return surface_id_; } |   96   const cc::SurfaceId& surface_id() const { return surface_id_; } | 
|   95  |   97  | 
 |   98   const gfx::Size& last_submitted_frame_size() { | 
 |   99     return last_submitted_frame_size_; | 
 |  100   } | 
 |  101  | 
|   96   // See mojom for for details. |  102   // See mojom for for details. | 
|   97   void set_allows_reembed(bool value) { allows_reembed_ = value; } |  103   void set_allows_reembed(bool value) { allows_reembed_ = value; } | 
|   98   bool allows_reembed() const { return allows_reembed_; } |  104   bool allows_reembed() const { return allows_reembed_; } | 
|   99  |  105  | 
 |  106   // mojo::CompositorFrameReceiver: | 
 |  107   void SubmitFrame(mojo::CompositorFramePtr frame, | 
 |  108                    const SubmitFrameCallback& callback) override; | 
 |  109  | 
|  100 #if !defined(NDEBUG) |  110 #if !defined(NDEBUG) | 
|  101   std::string GetDebugWindowHierarchy() const; |  111   std::string GetDebugWindowHierarchy() const; | 
|  102   void BuildDebugInfo(const std::string& depth, std::string* result) const; |  112   void BuildDebugInfo(const std::string& depth, std::string* result) const; | 
|  103 #endif |  113 #endif | 
|  104  |  114  | 
|  105  private: |  115  private: | 
|  106   typedef std::vector<ServerView*> Views; |  116   typedef std::vector<ServerView*> Views; | 
|  107  |  117  | 
|  108   // Implementation of removing a view. Doesn't send any notification. |  118   // Implementation of removing a view. Doesn't send any notification. | 
|  109   void RemoveImpl(ServerView* view); |  119   void RemoveImpl(ServerView* view); | 
|  110  |  120  | 
|  111   ServerViewDelegate* delegate_; |  121   ServerViewDelegate* delegate_; | 
|  112   const ViewId id_; |  122   const ViewId id_; | 
|  113   ServerView* parent_; |  123   ServerView* parent_; | 
|  114   Views children_; |  124   Views children_; | 
|  115   bool visible_; |  125   bool visible_; | 
|  116   gfx::Rect bounds_; |  126   gfx::Rect bounds_; | 
|  117   cc::SurfaceId surface_id_; |  127   cc::SurfaceId surface_id_; | 
|  118   float opacity_; |  128   float opacity_; | 
|  119   gfx::Transform transform_; |  129   gfx::Transform transform_; | 
|  120   bool allows_reembed_; |  130   bool allows_reembed_; | 
|  121   ui::TextInputState text_input_state_; |  131   ui::TextInputState text_input_state_; | 
 |  132   gfx::Size last_submitted_frame_size_; | 
|  122  |  133  | 
|  123   std::map<std::string, std::vector<uint8_t>> properties_; |  134   std::map<std::string, std::vector<uint8_t>> properties_; | 
|  124  |  135  | 
|  125   base::ObserverList<ServerViewObserver> observers_; |  136   base::ObserverList<ServerViewObserver> observers_; | 
 |  137   mojo::Binding<CompositorFrameReceiver> binding_; | 
|  126  |  138  | 
|  127   DISALLOW_COPY_AND_ASSIGN(ServerView); |  139   DISALLOW_COPY_AND_ASSIGN(ServerView); | 
|  128 }; |  140 }; | 
|  129  |  141  | 
|  130 }  // namespace view_manager |  142 }  // namespace view_manager | 
|  131  |  143  | 
|  132 #endif  // COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ |  144 #endif  // COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ | 
| OLD | NEW |