| 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 <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // contents of Buffers. It's keeped alive by references from | 60 // contents of Buffers. It's keeped alive by references from |
| 61 // release_callbacks_. It's destroyed when its owning Surface is destroyed and | 61 // release_callbacks_. It's destroyed when its owning Surface is destroyed and |
| 62 // the last outstanding release callback is called. | 62 // the last outstanding release callback is called. |
| 63 class SurfaceFactoryOwner : public base::RefCounted<SurfaceFactoryOwner>, | 63 class SurfaceFactoryOwner : public base::RefCounted<SurfaceFactoryOwner>, |
| 64 public cc::SurfaceFactoryClient { | 64 public cc::SurfaceFactoryClient { |
| 65 public: | 65 public: |
| 66 SurfaceFactoryOwner(); | 66 SurfaceFactoryOwner(); |
| 67 | 67 |
| 68 // Overridden from cc::SurfaceFactoryClient: | 68 // Overridden from cc::SurfaceFactoryClient: |
| 69 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 69 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 70 void WillDrawSurface(const cc::SurfaceId& id, | 70 void WillDrawSurface(const cc::LocalFrameId& id, |
| 71 const gfx::Rect& damage_rect) override; | 71 const gfx::Rect& damage_rect) override; |
| 72 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | 72 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 friend class base::RefCounted<SurfaceFactoryOwner>; | 75 friend class base::RefCounted<SurfaceFactoryOwner>; |
| 76 friend class Surface; | 76 friend class Surface; |
| 77 | 77 |
| 78 ~SurfaceFactoryOwner() override; | 78 ~SurfaceFactoryOwner() override; |
| 79 | 79 |
| 80 std::map<int, | 80 std::map<int, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 95 using PropertyDeallocator = void (*)(int64_t value); | 95 using PropertyDeallocator = void (*)(int64_t value); |
| 96 | 96 |
| 97 Surface(); | 97 Surface(); |
| 98 ~Surface() override; | 98 ~Surface() override; |
| 99 | 99 |
| 100 // Type-checking downcast routine. | 100 // Type-checking downcast routine. |
| 101 static Surface* AsSurface(const aura::Window* window); | 101 static Surface* AsSurface(const aura::Window* window); |
| 102 | 102 |
| 103 aura::Window* window() { return window_.get(); } | 103 aura::Window* window() { return window_.get(); } |
| 104 | 104 |
| 105 const cc::SurfaceId& surface_id() const { return surface_id_; } | 105 const cc::LocalFrameId& local_frame_id() const { return local_frame_id_; } |
| 106 cc::SurfaceId GetSurfaceId() const; |
| 106 | 107 |
| 107 // Set a buffer as the content of this surface. A buffer can only be attached | 108 // Set a buffer as the content of this surface. A buffer can only be attached |
| 108 // to one surface at a time. | 109 // to one surface at a time. |
| 109 void Attach(Buffer* buffer); | 110 void Attach(Buffer* buffer); |
| 110 | 111 |
| 111 // Describe the regions where the pending buffer is different from the | 112 // Describe the regions where the pending buffer is different from the |
| 112 // current surface contents, and where the surface therefore needs to be | 113 // current surface contents, and where the surface therefore needs to be |
| 113 // repainted. | 114 // repainted. |
| 114 void Damage(const gfx::Rect& rect); | 115 void Damage(const gfx::Rect& rect); |
| 115 | 116 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 bool HasPendingDamageForTesting(const gfx::Rect& damage) const { | 209 bool HasPendingDamageForTesting(const gfx::Rect& damage) const { |
| 209 return pending_damage_.contains(gfx::RectToSkIRect(damage)); | 210 return pending_damage_.contains(gfx::RectToSkIRect(damage)); |
| 210 } | 211 } |
| 211 | 212 |
| 212 // Overridden from ui::LayerOwnerDelegate: | 213 // Overridden from ui::LayerOwnerDelegate: |
| 213 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override; | 214 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override; |
| 214 | 215 |
| 215 // Overridden from ui::ContextFactoryObserver. | 216 // Overridden from ui::ContextFactoryObserver. |
| 216 void OnLostResources() override; | 217 void OnLostResources() override; |
| 217 | 218 |
| 218 void WillDraw(const cc::SurfaceId& surface_id); | 219 void WillDraw(const cc::LocalFrameId& local_frame_id); |
| 219 | 220 |
| 220 // Check whether this Surface and its children need to create new cc::Surface | 221 // Check whether this Surface and its children need to create new cc::Surface |
| 221 // IDs for their contents next time they get new buffer contents. | 222 // IDs for their contents next time they get new buffer contents. |
| 222 void CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); | 223 void CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); |
| 223 | 224 |
| 224 gfx::Size content_size() const { return content_size_; } | 225 gfx::Size content_size() const { return content_size_; } |
| 225 | 226 |
| 226 // Sets the |value| of the given surface |property|. Setting to the default | 227 // Sets the |value| of the given surface |property|. Setting to the default |
| 227 // value (e.g., NULL) removes the property. The caller is responsible for the | 228 // value (e.g., NULL) removes the property. The caller is responsible for the |
| 228 // lifetime of any object set as a property on the Surface. | 229 // lifetime of any object set as a property on the Surface. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 bool has_pending_contents_ = false; | 331 bool has_pending_contents_ = false; |
| 331 | 332 |
| 332 // The buffer that will become the content of surface when Commit() is called. | 333 // The buffer that will become the content of surface when Commit() is called. |
| 333 BufferAttachment pending_buffer_; | 334 BufferAttachment pending_buffer_; |
| 334 | 335 |
| 335 cc::SurfaceManager* surface_manager_; | 336 cc::SurfaceManager* surface_manager_; |
| 336 | 337 |
| 337 scoped_refptr<SurfaceFactoryOwner> factory_owner_; | 338 scoped_refptr<SurfaceFactoryOwner> factory_owner_; |
| 338 | 339 |
| 339 // The Surface Id currently attached to the window. | 340 // The Surface Id currently attached to the window. |
| 340 cc::SurfaceId surface_id_; | 341 cc::LocalFrameId local_frame_id_; |
| 341 | 342 |
| 342 // The next resource id the buffer will be attached to. | 343 // The next resource id the buffer will be attached to. |
| 343 int next_resource_id_ = 1; | 344 int next_resource_id_ = 1; |
| 344 | 345 |
| 345 // The damage region to schedule paint for when Commit() is called. | 346 // The damage region to schedule paint for when Commit() is called. |
| 346 SkRegion pending_damage_; | 347 SkRegion pending_damage_; |
| 347 | 348 |
| 348 // These lists contains the callbacks to notify the client when it is a good | 349 // These lists contains the callbacks to notify the client when it is a good |
| 349 // time to start producing a new frame. These callbacks move to | 350 // time to start producing a new frame. These callbacks move to |
| 350 // |frame_callbacks_| when Commit() is called. Later they are moved to | 351 // |frame_callbacks_| when Commit() is called. Later they are moved to |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 | 401 |
| 401 // Surface observer list. Surface does not own the observers. | 402 // Surface observer list. Surface does not own the observers. |
| 402 base::ObserverList<SurfaceObserver, true> observers_; | 403 base::ObserverList<SurfaceObserver, true> observers_; |
| 403 | 404 |
| 404 DISALLOW_COPY_AND_ASSIGN(Surface); | 405 DISALLOW_COPY_AND_ASSIGN(Surface); |
| 405 }; | 406 }; |
| 406 | 407 |
| 407 } // namespace exo | 408 } // namespace exo |
| 408 | 409 |
| 409 #endif // COMPONENTS_EXO_SURFACE_H_ | 410 #endif // COMPONENTS_EXO_SURFACE_H_ |
| OLD | NEW |