OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CC_SURFACES_SURFACE_FACTORY_H_ | 5 #ifndef CC_SURFACES_SURFACE_FACTORY_H_ |
6 #define CC_SURFACES_SURFACE_FACTORY_H_ | 6 #define CC_SURFACES_SURFACE_FACTORY_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <unordered_map> | |
11 | 10 |
12 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
13 #include "base/macros.h" | 12 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
15 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
16 #include "cc/output/compositor_frame.h" | 15 #include "cc/output/compositor_frame.h" |
17 #include "cc/surfaces/surface_id.h" | 16 #include "cc/surfaces/surface_id.h" |
18 #include "cc/surfaces/surface_resource_holder.h" | 17 #include "cc/surfaces/surface_resource_holder.h" |
19 #include "cc/surfaces/surface_sequence.h" | 18 #include "cc/surfaces/surface_sequence.h" |
20 #include "cc/surfaces/surfaces_export.h" | 19 #include "cc/surfaces/surfaces_export.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
39 public: | 38 public: |
40 using DrawCallback = base::Callback<void()>; | 39 using DrawCallback = base::Callback<void()>; |
41 | 40 |
42 SurfaceFactory(const FrameSinkId& frame_sink_id, | 41 SurfaceFactory(const FrameSinkId& frame_sink_id, |
43 SurfaceManager* manager, | 42 SurfaceManager* manager, |
44 SurfaceFactoryClient* client); | 43 SurfaceFactoryClient* client); |
45 ~SurfaceFactory(); | 44 ~SurfaceFactory(); |
46 | 45 |
47 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } | 46 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
48 | 47 |
49 void Create(const LocalFrameId& local_frame_id); | 48 void EvictFrame(); |
piman
2016/11/12 00:19:10
EvictSurface maybe?
Trying to get consistent nami
danakj
2016/11/12 00:27:21
Please add a comment to explain what this does and
| |
50 void Destroy(const LocalFrameId& local_frame_id); | |
51 | |
52 // Destroys all surfaces. | |
53 void DestroyAll(); | |
54 | 49 |
55 // Destroys and disown all surfaces, and reset all resource references. This | 50 // Destroys and disown all surfaces, and reset all resource references. This |
danakj
2016/11/12 00:27:21
does the meaning of "all surfaces" change now?
Saman Sami
2016/11/14 23:39:01
Done.
| |
56 // is useful when resources are invalid (e.g. lost context). | 51 // is useful when resources are invalid (e.g. lost context). |
57 void Reset(); | 52 void Reset(); |
58 | 53 |
59 // Set that the current frame on new_id is to be treated as the successor to | |
60 // the current frame on old_id for the purposes of calculating damage. | |
61 void SetPreviousFrameSurface(const LocalFrameId& new_id, | |
62 const LocalFrameId& old_id); | |
63 | |
64 // A frame can only be submitted to a surface created by this factory, | 54 // A frame can only be submitted to a surface created by this factory, |
piman
2016/11/12 00:19:10
Documentation should be updated.
Saman Sami
2016/11/14 23:39:01
Done.
| |
65 // although the frame may reference surfaces created by other factories. | 55 // although the frame may reference surfaces created by other factories. |
66 // The callback is called the first time this frame is used to draw, or if | 56 // The callback is called the first time this frame is used to draw, or if |
67 // the frame is discarded. | 57 // the frame is discarded. |
68 void SubmitCompositorFrame(const LocalFrameId& local_frame_id, | 58 void SubmitCompositorFrame(const LocalFrameId& local_frame_id, |
69 CompositorFrame frame, | 59 CompositorFrame frame, |
70 const DrawCallback& callback); | 60 const DrawCallback& callback); |
71 void RequestCopyOfSurface(const LocalFrameId& local_frame_id, | 61 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> copy_request); |
72 std::unique_ptr<CopyOutputRequest> copy_request); | |
73 | 62 |
74 void WillDrawSurface(const LocalFrameId& id, const gfx::Rect& damage_rect); | 63 void WillDrawSurface(const LocalFrameId& id, const gfx::Rect& damage_rect); |
75 | 64 |
76 SurfaceFactoryClient* client() { return client_; } | 65 SurfaceFactoryClient* client() { return client_; } |
77 | 66 |
78 void ReceiveFromChild(const TransferableResourceArray& resources); | 67 void ReceiveFromChild(const TransferableResourceArray& resources); |
79 void RefResources(const TransferableResourceArray& resources); | 68 void RefResources(const TransferableResourceArray& resources); |
80 void UnrefResources(const ReturnedResourceArray& resources); | 69 void UnrefResources(const ReturnedResourceArray& resources); |
81 | 70 |
82 SurfaceManager* manager() { return manager_; } | 71 SurfaceManager* manager() { return manager_; } |
83 | 72 |
84 // This can be set to false if resources from this SurfaceFactory don't need | 73 // This can be set to false if resources from this SurfaceFactory don't need |
85 // to have sync points set on them when returned from the Display, for | 74 // to have sync points set on them when returned from the Display, for |
86 // example if the Display shares a context with the creator. | 75 // example if the Display shares a context with the creator. |
87 bool needs_sync_points() const { return needs_sync_points_; } | 76 bool needs_sync_points() const { return needs_sync_points_; } |
88 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } | 77 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } |
89 | 78 |
90 // SurfaceFactory's owner can call this when it finds out that SurfaceManager | 79 // SurfaceFactory's owner can call this when it finds out that SurfaceManager |
91 // is no longer alive during destruction. | 80 // is no longer alive during destruction. |
92 void DidDestroySurfaceManager() { manager_ = nullptr; } | 81 void DidDestroySurfaceManager() { manager_ = nullptr; } |
93 | 82 |
94 private: | 83 private: |
95 FrameSinkId frame_sink_id_; | 84 std::unique_ptr<Surface> Create(const LocalFrameId& local_frame_id); |
85 void Destroy(std::unique_ptr<Surface> surface); | |
86 | |
87 const FrameSinkId frame_sink_id_; | |
96 SurfaceManager* manager_; | 88 SurfaceManager* manager_; |
97 SurfaceFactoryClient* client_; | 89 SurfaceFactoryClient* client_; |
98 SurfaceResourceHolder holder_; | 90 SurfaceResourceHolder holder_; |
99 | |
100 bool needs_sync_points_; | 91 bool needs_sync_points_; |
101 | 92 std::unique_ptr<Surface> current_surface_; |
102 using OwningSurfaceMap = std:: | |
103 unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; | |
104 OwningSurfaceMap surface_map_; | |
105 | |
106 base::WeakPtrFactory<SurfaceFactory> weak_factory_; | 93 base::WeakPtrFactory<SurfaceFactory> weak_factory_; |
107 | 94 |
108 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); | 95 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); |
109 }; | 96 }; |
110 | 97 |
111 } // namespace cc | 98 } // namespace cc |
112 | 99 |
113 #endif // CC_SURFACES_SURFACE_FACTORY_H_ | 100 #endif // CC_SURFACES_SURFACE_FACTORY_H_ |
OLD | NEW |