| 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 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "third_party/skia/include/core/SkRegion.h" | 15 #include "third_party/skia/include/core/SkRegion.h" |
| 16 #include "ui/aura/window.h" |
| 16 #include "ui/compositor/compositor_observer.h" | 17 #include "ui/compositor/compositor_observer.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 18 #include "ui/views/view.h" | |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 namespace trace_event { | 21 namespace trace_event { |
| 22 class TracedValue; | 22 class TracedValue; |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace exo { | 26 namespace exo { |
| 27 class Buffer; | 27 class Buffer; |
| 28 class SurfaceDelegate; | 28 class SurfaceDelegate; |
| 29 class SurfaceObserver; | 29 class SurfaceObserver; |
| 30 | 30 |
| 31 // This class represents a rectangular area that is displayed on the screen. | 31 // This class represents a rectangular area that is displayed on the screen. |
| 32 // It has a location, size and pixel contents. | 32 // It has a location, size and pixel contents. |
| 33 class Surface : public views::View, public ui::CompositorObserver { | 33 class Surface : public aura::Window, public ui::CompositorObserver { |
| 34 public: | 34 public: |
| 35 Surface(); | 35 Surface(); |
| 36 ~Surface() override; | 36 ~Surface() override; |
| 37 | 37 |
| 38 // Set a buffer as the content of this surface. A buffer can only be attached | 38 // Set a buffer as the content of this surface. A buffer can only be attached |
| 39 // to one surface at a time. | 39 // to one surface at a time. |
| 40 void Attach(Buffer* buffer); | 40 void Attach(Buffer* buffer); |
| 41 | 41 |
| 42 // Describe the regions where the pending buffer is different from the | 42 // Describe the regions where the pending buffer is different from the |
| 43 // current surface contents, and where the surface therefore needs to be | 43 // current surface contents, and where the surface therefore needs to be |
| (...skipping 23 matching lines...) Expand all Loading... |
| 67 void Commit(); | 67 void Commit(); |
| 68 | 68 |
| 69 // This will synchronously commit all pending state of the surface and its | 69 // This will synchronously commit all pending state of the surface and its |
| 70 // descendants by recursively calling CommitSurfaceHierarchy() for each | 70 // descendants by recursively calling CommitSurfaceHierarchy() for each |
| 71 // sub-surface with pending state. | 71 // sub-surface with pending state. |
| 72 void CommitSurfaceHierarchy(); | 72 void CommitSurfaceHierarchy(); |
| 73 | 73 |
| 74 // Returns true if surface is in synchronized mode. | 74 // Returns true if surface is in synchronized mode. |
| 75 bool IsSynchronized() const; | 75 bool IsSynchronized() const; |
| 76 | 76 |
| 77 // Returns the preferred size of surface. |
| 78 gfx::Size GetPreferredSize() const; |
| 79 |
| 77 // Set the surface delegate. | 80 // Set the surface delegate. |
| 78 void SetSurfaceDelegate(SurfaceDelegate* delegate); | 81 void SetSurfaceDelegate(SurfaceDelegate* delegate); |
| 79 | 82 |
| 80 // Returns true if surface has been assigned a surface delegate. | 83 // Returns true if surface has been assigned a surface delegate. |
| 81 bool HasSurfaceDelegate() const; | 84 bool HasSurfaceDelegate() const; |
| 82 | 85 |
| 83 // Surface does not own observers. It is the responsibility of the observer | 86 // Surface does not own observers. It is the responsibility of the observer |
| 84 // to remove itself when it is done observing. | 87 // to remove itself when it is done observing. |
| 85 void AddSurfaceObserver(SurfaceObserver* observer); | 88 void AddSurfaceObserver(SurfaceObserver* observer); |
| 86 void RemoveSurfaceObserver(SurfaceObserver* observer); | 89 void RemoveSurfaceObserver(SurfaceObserver* observer); |
| 87 bool HasSurfaceObserver(const SurfaceObserver* observer) const; | 90 bool HasSurfaceObserver(const SurfaceObserver* observer) const; |
| 88 | 91 |
| 89 // Returns a trace value representing the state of the surface. | 92 // Returns a trace value representing the state of the surface. |
| 90 scoped_refptr<base::trace_event::TracedValue> AsTracedValue() const; | 93 scoped_refptr<base::trace_event::TracedValue> AsTracedValue() const; |
| 91 | 94 |
| 92 bool HasPendingDamageForTesting() const { return !pending_damage_.IsEmpty(); } | 95 bool HasPendingDamageForTesting() const { return !pending_damage_.IsEmpty(); } |
| 93 | 96 |
| 94 // Overridden from views::View: | |
| 95 gfx::Size GetPreferredSize() const override; | |
| 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: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 // Surface observer list. Surface does not own the observers. | 165 // Surface observer list. Surface does not own the observers. |
| 166 base::ObserverList<SurfaceObserver, true> observers_; | 166 base::ObserverList<SurfaceObserver, true> observers_; |
| 167 | 167 |
| 168 DISALLOW_COPY_AND_ASSIGN(Surface); | 168 DISALLOW_COPY_AND_ASSIGN(Surface); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 } // namespace exo | 171 } // namespace exo |
| 172 | 172 |
| 173 #endif // COMPONENTS_EXO_SURFACE_H_ | 173 #endif // COMPONENTS_EXO_SURFACE_H_ |
| OLD | NEW |