| 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 "cc/surfaces/surface_id.h" | 
 |   22 #include "components/exo/exo_compositor_frame_sink.h" | 
|   21 #include "third_party/skia/include/core/SkRegion.h" |   23 #include "third_party/skia/include/core/SkRegion.h" | 
|   22 #include "third_party/skia/include/core/SkXfermode.h" |   24 #include "third_party/skia/include/core/SkXfermode.h" | 
|   23 #include "ui/aura/window.h" |   25 #include "ui/aura/window.h" | 
|   24 #include "ui/aura/window_observer.h" |   26 #include "ui/aura/window_observer.h" | 
|   25 #include "ui/gfx/geometry/rect.h" |   27 #include "ui/gfx/geometry/rect.h" | 
|   26  |   28  | 
|   27 namespace base { |   29 namespace base { | 
|   28 namespace trace_event { |   30 namespace trace_event { | 
|   29 class TracedValue; |   31 class TracedValue; | 
|   30 } |   32 } | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
|   50 struct SurfaceProperty; |   52 struct SurfaceProperty; | 
|   51  |   53  | 
|   52 namespace subtle { |   54 namespace subtle { | 
|   53 class PropertyHelper; |   55 class PropertyHelper; | 
|   54 } |   56 } | 
|   55  |   57  | 
|   56 // The pointer class is currently the only cursor provider class but this can |   58 // The pointer class is currently the only cursor provider class but this can | 
|   57 // change in the future when better hardware cursor support is added. |   59 // change in the future when better hardware cursor support is added. | 
|   58 using CursorProvider = Pointer; |   60 using CursorProvider = Pointer; | 
|   59  |   61  | 
|   60 // This class owns the SurfaceFactory and keeps track of references to the |  | 
|   61 // contents of Buffers. It's keeped alive by references from |  | 
|   62 // release_callbacks_. It's destroyed when its owning Surface is destroyed and |  | 
|   63 // the last outstanding release callback is called. |  | 
|   64 class SurfaceFactoryOwner : public base::RefCounted<SurfaceFactoryOwner>, |  | 
|   65                             public cc::SurfaceFactoryClient { |  | 
|   66  public: |  | 
|   67   SurfaceFactoryOwner(); |  | 
|   68  |  | 
|   69   // Overridden from cc::SurfaceFactoryClient: |  | 
|   70   void ReturnResources(const cc::ReturnedResourceArray& resources) override; |  | 
|   71   void WillDrawSurface(const cc::LocalFrameId& id, |  | 
|   72                        const gfx::Rect& damage_rect) override; |  | 
|   73   void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |  | 
|   74  |  | 
|   75  private: |  | 
|   76   friend class base::RefCounted<SurfaceFactoryOwner>; |  | 
|   77   friend class Surface; |  | 
|   78  |  | 
|   79   ~SurfaceFactoryOwner() override; |  | 
|   80  |  | 
|   81   std::map<int, |  | 
|   82            std::pair<scoped_refptr<SurfaceFactoryOwner>, |  | 
|   83                      std::unique_ptr<cc::SingleReleaseCallback>>> |  | 
|   84       release_callbacks_; |  | 
|   85   cc::FrameSinkId frame_sink_id_; |  | 
|   86   std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; |  | 
|   87   std::unique_ptr<cc::SurfaceFactory> surface_factory_; |  | 
|   88   Surface* surface_ = nullptr; |  | 
|   89 }; |  | 
|   90  |  | 
|   91 // This class represents a rectangular area that is displayed on the screen. |   62 // This class represents a rectangular area that is displayed on the screen. | 
|   92 // It has a location, size and pixel contents. |   63 // It has a location, size and pixel contents. | 
|   93 class Surface : public ui::ContextFactoryObserver, |   64 class Surface : public ui::ContextFactoryObserver, | 
|   94                 public aura::WindowObserver, |   65                 public aura::WindowObserver, | 
|   95                 public cc::BeginFrameObserver { |   66                 public cc::BeginFrameObserver { | 
|   96  public: |   67  public: | 
|   97   using PropertyDeallocator = void (*)(int64_t value); |   68   using PropertyDeallocator = void (*)(int64_t value); | 
|   98  |   69  | 
|   99   Surface(); |   70   Surface(); | 
|  100   ~Surface() override; |   71   ~Surface() override; | 
|  101  |   72  | 
|  102   // Type-checking downcast routine. |   73   // Type-checking downcast routine. | 
|  103   static Surface* AsSurface(const aura::Window* window); |   74   static Surface* AsSurface(const aura::Window* window); | 
|  104  |   75  | 
|  105   aura::Window* window() { return window_.get(); } |   76   aura::Window* window() { return window_.get(); } | 
|  106  |   77  | 
|  107   const cc::LocalFrameId& local_frame_id() const { return local_frame_id_; } |   78   const cc::LocalFrameId& local_frame_id() const { | 
 |   79     return surface_id_.local_frame_id(); | 
 |   80   } | 
 |   81  | 
|  108   cc::SurfaceId GetSurfaceId() const; |   82   cc::SurfaceId GetSurfaceId() const; | 
|  109  |   83  | 
|  110   // Set a buffer as the content of this surface. A buffer can only be attached |   84   // Set a buffer as the content of this surface. A buffer can only be attached | 
|  111   // to one surface at a time. |   85   // to one surface at a time. | 
|  112   void Attach(Buffer* buffer); |   86   void Attach(Buffer* buffer); | 
|  113  |   87  | 
|  114   // Describe the regions where the pending buffer is different from the |   88   // Describe the regions where the pending buffer is different from the | 
|  115   // current surface contents, and where the surface therefore needs to be |   89   // current surface contents, and where the surface therefore needs to be | 
|  116   // repainted. |   90   // repainted. | 
|  117   void Damage(const gfx::Rect& rect); |   91   void Damage(const gfx::Rect& rect); | 
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  345  |  319  | 
|  346   // 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 | 
|  347   // effect next time Commit() is called. |  321   // effect next time Commit() is called. | 
|  348   bool has_pending_contents_ = false; |  322   bool has_pending_contents_ = false; | 
|  349  |  323  | 
|  350   // 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. | 
|  351   BufferAttachment pending_buffer_; |  325   BufferAttachment pending_buffer_; | 
|  352  |  326  | 
|  353   cc::SurfaceManager* surface_manager_; |  327   cc::SurfaceManager* surface_manager_; | 
|  354  |  328  | 
|  355   scoped_refptr<SurfaceFactoryOwner> factory_owner_; |  329   scoped_refptr<ExoCompositorFrameSink> compositor_frame_sink_; | 
|  356  |  | 
|  357   // The Surface Id currently attached to the window. |  | 
|  358   cc::LocalFrameId local_frame_id_; |  | 
|  359  |  330  | 
|  360   // The next resource id the buffer will be attached to. |  331   // The next resource id the buffer will be attached to. | 
|  361   int next_resource_id_ = 1; |  332   int next_resource_id_ = 1; | 
|  362  |  333  | 
|  363   // The damage region to schedule paint for when Commit() is called. |  334   // The damage region to schedule paint for when Commit() is called. | 
|  364   SkRegion pending_damage_; |  335   SkRegion pending_damage_; | 
|  365  |  336  | 
|  366   // These lists contains the callbacks to notify the client when it is a good |  337   // These lists contains the callbacks to notify the client when it is a good | 
|  367   // time to start producing a new frame. These callbacks move to |  338   // time to start producing a new frame. These callbacks move to | 
|  368   // |frame_callbacks_| when Commit() is called. Later they are moved to |  339   // |frame_callbacks_| when Commit() is called. Later they are moved to | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  416     const char* name; |  387     const char* name; | 
|  417     int64_t value; |  388     int64_t value; | 
|  418     PropertyDeallocator deallocator; |  389     PropertyDeallocator deallocator; | 
|  419   }; |  390   }; | 
|  420  |  391  | 
|  421   std::map<const void*, Value> prop_map_; |  392   std::map<const void*, Value> prop_map_; | 
|  422  |  393  | 
|  423   // Surface observer list. Surface does not own the observers. |  394   // Surface observer list. Surface does not own the observers. | 
|  424   base::ObserverList<SurfaceObserver, true> observers_; |  395   base::ObserverList<SurfaceObserver, true> observers_; | 
|  425  |  396  | 
 |  397   cc::SurfaceId surface_id_; | 
 |  398  | 
|  426   DISALLOW_COPY_AND_ASSIGN(Surface); |  399   DISALLOW_COPY_AND_ASSIGN(Surface); | 
|  427 }; |  400 }; | 
|  428  |  401  | 
|  429 }  // namespace exo |  402 }  // namespace exo | 
|  430  |  403  | 
|  431 #endif  // COMPONENTS_EXO_SURFACE_H_ |  404 #endif  // COMPONENTS_EXO_SURFACE_H_ | 
| OLD | NEW |