| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "cc/resources/transferable_resource.h" | 18 #include "cc/resources/transferable_resource.h" |
| 19 #include "cc/scheduler/begin_frame_source.h" | 19 #include "cc/scheduler/begin_frame_source.h" |
| 20 #include "cc/surfaces/surface_factory_client.h" | 20 #include "cc/surfaces/surface_factory_client.h" |
| 21 #include "components/exo/exo_compositor_frame_sink.h" |
| 21 #include "third_party/skia/include/core/SkRegion.h" | 22 #include "third_party/skia/include/core/SkRegion.h" |
| 22 #include "third_party/skia/include/core/SkXfermode.h" | 23 #include "third_party/skia/include/core/SkXfermode.h" |
| 23 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 24 #include "ui/aura/window_observer.h" | 25 #include "ui/aura/window_observer.h" |
| 25 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
| 26 | 27 |
| 27 namespace base { | 28 namespace base { |
| 28 namespace trace_event { | 29 namespace trace_event { |
| 29 class TracedValue; | 30 class TracedValue; |
| 30 } | 31 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 } | 54 } |
| 54 | 55 |
| 55 // The pointer class is currently the only cursor provider class but this can | 56 // The pointer class is currently the only cursor provider class but this can |
| 56 // change in the future when better hardware cursor support is added. | 57 // change in the future when better hardware cursor support is added. |
| 57 using CursorProvider = Pointer; | 58 using CursorProvider = Pointer; |
| 58 | 59 |
| 59 // This class owns the SurfaceFactory and keeps track of references to the | 60 // This class owns the SurfaceFactory and keeps track of references to the |
| 60 // contents of Buffers. It's keeped alive by references from | 61 // contents of Buffers. It's keeped alive by references from |
| 61 // release_callbacks_. It's destroyed when its owning Surface is destroyed and | 62 // release_callbacks_. It's destroyed when its owning Surface is destroyed and |
| 62 // the last outstanding release callback is called. | 63 // the last outstanding release callback is called. |
| 63 class SurfaceFactoryOwner : public base::RefCounted<SurfaceFactoryOwner>, | |
| 64 public cc::SurfaceFactoryClient { | |
| 65 public: | |
| 66 SurfaceFactoryOwner(); | |
| 67 | |
| 68 // Overridden from cc::SurfaceFactoryClient: | |
| 69 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | |
| 70 void WillDrawSurface(const cc::LocalFrameId& id, | |
| 71 const gfx::Rect& damage_rect) override; | |
| 72 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | |
| 73 | |
| 74 private: | |
| 75 friend class base::RefCounted<SurfaceFactoryOwner>; | |
| 76 friend class Surface; | |
| 77 | |
| 78 ~SurfaceFactoryOwner() override; | |
| 79 | |
| 80 std::map<int, | |
| 81 std::pair<scoped_refptr<SurfaceFactoryOwner>, | |
| 82 std::unique_ptr<cc::SingleReleaseCallback>>> | |
| 83 release_callbacks_; | |
| 84 cc::FrameSinkId frame_sink_id_; | |
| 85 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; | |
| 86 std::unique_ptr<cc::SurfaceFactory> surface_factory_; | |
| 87 Surface* surface_ = nullptr; | |
| 88 }; | |
| 89 | 64 |
| 90 // This class represents a rectangular area that is displayed on the screen. | 65 // This class represents a rectangular area that is displayed on the screen. |
| 91 // It has a location, size and pixel contents. | 66 // It has a location, size and pixel contents. |
| 92 class Surface : public ui::ContextFactoryObserver, | 67 class Surface : public ui::ContextFactoryObserver, |
| 93 public aura::WindowObserver, | 68 public aura::WindowObserver, |
| 94 public cc::BeginFrameObserver { | 69 public cc::BeginFrameObserver { |
| 95 public: | 70 public: |
| 96 using PropertyDeallocator = void (*)(int64_t value); | 71 using PropertyDeallocator = void (*)(int64_t value); |
| 97 | 72 |
| 98 Surface(); | 73 Surface(); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 319 |
| 345 // This is true when Attach() has been called and new contents should take | 320 // This is true when Attach() has been called and new contents should take |
| 346 // effect next time Commit() is called. | 321 // effect next time Commit() is called. |
| 347 bool has_pending_contents_ = false; | 322 bool has_pending_contents_ = false; |
| 348 | 323 |
| 349 // The buffer that will become the content of surface when Commit() is called. | 324 // The buffer that will become the content of surface when Commit() is called. |
| 350 BufferAttachment pending_buffer_; | 325 BufferAttachment pending_buffer_; |
| 351 | 326 |
| 352 cc::SurfaceManager* surface_manager_; | 327 cc::SurfaceManager* surface_manager_; |
| 353 | 328 |
| 354 scoped_refptr<SurfaceFactoryOwner> factory_owner_; | 329 scoped_refptr<ExoCompositorFrameSink> factory_owner_; |
| 355 | 330 |
| 356 // The Surface Id currently attached to the window. | 331 // The Surface Id currently attached to the window. |
| 357 cc::LocalFrameId local_frame_id_; | 332 cc::LocalFrameId local_frame_id_; |
| 358 | 333 |
| 359 // The next resource id the buffer will be attached to. | 334 // The next resource id the buffer will be attached to. |
| 360 int next_resource_id_ = 1; | 335 int next_resource_id_ = 1; |
| 361 | 336 |
| 362 // The damage region to schedule paint for when Commit() is called. | 337 // The damage region to schedule paint for when Commit() is called. |
| 363 SkRegion pending_damage_; | 338 SkRegion pending_damage_; |
| 364 | 339 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 396 |
| 422 // Surface observer list. Surface does not own the observers. | 397 // Surface observer list. Surface does not own the observers. |
| 423 base::ObserverList<SurfaceObserver, true> observers_; | 398 base::ObserverList<SurfaceObserver, true> observers_; |
| 424 | 399 |
| 425 DISALLOW_COPY_AND_ASSIGN(Surface); | 400 DISALLOW_COPY_AND_ASSIGN(Surface); |
| 426 }; | 401 }; |
| 427 | 402 |
| 428 } // namespace exo | 403 } // namespace exo |
| 429 | 404 |
| 430 #endif // COMPONENTS_EXO_SURFACE_H_ | 405 #endif // COMPONENTS_EXO_SURFACE_H_ |
| OLD | NEW |