| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_EXO_SURFACE_H_ | 5 #ifndef COMPONENTS_EXO_SURFACE_H_ |
| 6 #define COMPONENTS_EXO_SURFACE_H_ | 6 #define COMPONENTS_EXO_SURFACE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 bool HasPendingDamageForTesting() const { return !pending_damage_.IsEmpty(); } | 92 bool HasPendingDamageForTesting() const { return !pending_damage_.IsEmpty(); } |
| 93 | 93 |
| 94 // Overridden from views::View: | 94 // Overridden from views::View: |
| 95 gfx::Size GetPreferredSize() const override; | 95 gfx::Size GetPreferredSize() const override; |
| 96 | 96 |
| 97 // Overridden from ui::CompositorObserver: | 97 // Overridden from ui::CompositorObserver: |
| 98 void OnCompositingDidCommit(ui::Compositor* compositor) override; | 98 void OnCompositingDidCommit(ui::Compositor* compositor) override; |
| 99 void OnCompositingStarted(ui::Compositor* compositor, | 99 void OnCompositingStarted(ui::Compositor* compositor, |
| 100 base::TimeTicks start_time) override; | 100 base::TimeTicks start_time) override; |
| 101 void OnCompositingEnded(ui::Compositor* compositor) override {} | 101 void OnCompositingEnded(ui::Compositor* compositor) override; |
| 102 void OnCompositingAborted(ui::Compositor* compositor) override {} | 102 void OnCompositingAborted(ui::Compositor* compositor) override; |
| 103 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} | 103 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} |
| 104 void OnCompositingShuttingDown(ui::Compositor* compositor) override; | 104 void OnCompositingShuttingDown(ui::Compositor* compositor) override; |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 bool needs_commit_surface_hierarchy() const { | 107 bool needs_commit_surface_hierarchy() const { |
| 108 return needs_commit_surface_hierarchy_; | 108 return needs_commit_surface_hierarchy_; |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool has_contents() const { return has_contents_; } | 111 // This returns true when the surface has some contents assigned to it. |
| 112 bool has_contents() const { return !!current_buffer_; } |
| 113 |
| 114 // This is true when Attach() has been called and new contents should take |
| 115 // effect next time Commit() is called. |
| 116 bool has_pending_contents_; |
| 112 | 117 |
| 113 // The buffer that will become the content of surface when Commit() is called. | 118 // The buffer that will become the content of surface when Commit() is called. |
| 114 base::WeakPtr<Buffer> pending_buffer_; | 119 base::WeakPtr<Buffer> pending_buffer_; |
| 115 | 120 |
| 116 // The damage region to schedule paint for when Commit() is called. | 121 // The damage region to schedule paint for when Commit() is called. |
| 117 // TODO(reveman): Use SkRegion here after adding a version of | 122 // TODO(reveman): Use SkRegion here after adding a version of |
| 118 // ui::Layer::SchedulePaint that takes a SkRegion. | 123 // ui::Layer::SchedulePaint that takes a SkRegion. |
| 119 gfx::Rect pending_damage_; | 124 gfx::Rect pending_damage_; |
| 120 | 125 |
| 121 // These lists contains the callbacks to notify the client when it is a good | 126 // These lists contains the callbacks to notify the client when it is a good |
| 122 // time to start producing a new frame. These callbacks move to | 127 // time to start producing a new frame. These callbacks move to |
| 123 // |frame_callbacks_| when Commit() is called. Later they are moved to | 128 // |frame_callbacks_| when Commit() is called. Later they are moved to |
| 124 // |active_frame_callbacks_| when the effect of the Commit() is reflected in | 129 // |active_frame_callbacks_| when the effect of the Commit() is reflected in |
| 125 // the compositor's active layer tree. The callbacks fire once we're notified | 130 // the compositor's active layer tree. The callbacks fire once we're notified |
| 126 // that the compositor started drawing that active layer tree. | 131 // that the compositor started drawing that active layer tree. |
| 127 std::list<FrameCallback> pending_frame_callbacks_; | 132 std::list<FrameCallback> pending_frame_callbacks_; |
| 128 std::list<FrameCallback> frame_callbacks_; | 133 std::list<FrameCallback> frame_callbacks_; |
| 129 std::list<FrameCallback> active_frame_callbacks_; | 134 std::list<FrameCallback> active_frame_callbacks_; |
| 130 | 135 |
| 131 // The opaque region to take effect when Commit() is called. | 136 // The opaque region to take effect when Commit() is called. |
| 132 SkRegion pending_opaque_region_; | 137 SkRegion pending_opaque_region_; |
| 133 | 138 |
| 134 // The stack of sub-surfaces to take effect when Commit() is called. | 139 // The stack of sub-surfaces to take effect when Commit() is called. |
| 135 // Bottom-most sub-surface at the front of the list and top-most sub-surface | 140 // Bottom-most sub-surface at the front of the list and top-most sub-surface |
| 136 // at the back. | 141 // at the back. |
| 137 using SubSurfaceEntry = std::pair<Surface*, gfx::Point>; | 142 using SubSurfaceEntry = std::pair<Surface*, gfx::Point>; |
| 138 using SubSurfaceEntryList = std::list<SubSurfaceEntry>; | 143 using SubSurfaceEntryList = std::list<SubSurfaceEntry>; |
| 139 SubSurfaceEntryList pending_sub_surfaces_; | 144 SubSurfaceEntryList pending_sub_surfaces_; |
| 140 | 145 |
| 146 // The buffer that is currently set as content of surface. |
| 147 base::WeakPtr<Buffer> current_buffer_; |
| 148 |
| 141 // This is true if a call to Commit() as been made but | 149 // This is true if a call to Commit() as been made but |
| 142 // CommitSurfaceHierarchy() has not yet been called. | 150 // CommitSurfaceHierarchy() has not yet been called. |
| 143 bool needs_commit_surface_hierarchy_; | 151 bool needs_commit_surface_hierarchy_; |
| 144 | 152 |
| 145 // This is true when surface has some contents assigned to it. | 153 // This is true when the contents of the surface should be updated next time |
| 146 bool has_contents_; | 154 // the compositor successfully ends compositing. |
| 155 bool update_contents_after_successful_compositing_; |
| 147 | 156 |
| 148 // The compsitor being observer or null if not observing a compositor. | 157 // The compsitor being observer or null if not observing a compositor. |
| 149 ui::Compositor* compositor_; | 158 ui::Compositor* compositor_; |
| 150 | 159 |
| 151 // This can be set to have some functions delegated. E.g. ShellSurface class | 160 // This can be set to have some functions delegated. E.g. ShellSurface class |
| 152 // can set this to handle Commit() and apply any double buffered state it | 161 // can set this to handle Commit() and apply any double buffered state it |
| 153 // maintains. | 162 // maintains. |
| 154 SurfaceDelegate* delegate_; | 163 SurfaceDelegate* delegate_; |
| 155 | 164 |
| 156 // Surface observer list. Surface does not own the observers. | 165 // Surface observer list. Surface does not own the observers. |
| 157 base::ObserverList<SurfaceObserver, true> observers_; | 166 base::ObserverList<SurfaceObserver, true> observers_; |
| 158 | 167 |
| 159 DISALLOW_COPY_AND_ASSIGN(Surface); | 168 DISALLOW_COPY_AND_ASSIGN(Surface); |
| 160 }; | 169 }; |
| 161 | 170 |
| 162 } // namespace exo | 171 } // namespace exo |
| 163 | 172 |
| 164 #endif // COMPONENTS_EXO_SURFACE_H_ | 173 #endif // COMPONENTS_EXO_SURFACE_H_ |
| OLD | NEW |