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_H_ | 5 #ifndef CC_SURFACES_SURFACE_H_ |
6 #define CC_SURFACES_SURFACE_H_ | 6 #define CC_SURFACES_SURFACE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 return destruction_dependencies_.size(); | 73 return destruction_dependencies_.size(); |
74 } | 74 } |
75 | 75 |
76 const std::vector<SurfaceId>& referenced_surfaces() const { | 76 const std::vector<SurfaceId>& referenced_surfaces() const { |
77 return referenced_surfaces_; | 77 return referenced_surfaces_; |
78 } | 78 } |
79 | 79 |
80 bool destroyed() const { return destroyed_; } | 80 bool destroyed() const { return destroyed_; } |
81 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } | 81 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } |
82 | 82 |
83 void AddDisplay(Display* display) { | |
jbauman
2015/09/04 23:58:36
Probably best to use BeginFrameSource* everywhere
| |
84 if (!base::ContainsValue(currently_displayed_on_, display)) { | |
jbauman
2015/09/04 23:58:36
DCHECK this?
| |
85 currently_displayed_on_.push_back(display); | |
86 factory_->client()->SetBeginFrameSource(surface_id_, static_cast<BeginFram eSource*>(getPrimaryDisplay())); | |
jbauman
2015/09/04 23:58:36
Be careful, as factory_ can be an invalidated weak
| |
87 } | |
88 } | |
89 | |
90 void RemoveDisplay(Display* display) { | |
91 DCHECK(base::ContainsValue(current_displayed_on_, display)); | |
92 | |
93 base::RemoveValue(current_displayed_on_, display); | |
94 | |
95 factory_->client()->SetBeginFrameSource(surface_id_, static_cast<BeginFrameS ource*>(getPrimaryDisplay())); | |
96 } | |
97 | |
98 Display* getPrimaryDisplay() { | |
99 if (currently_displayed_on_.empty()) | |
100 return NULL; | |
101 return current_displayed_on_[0]; | |
102 } | |
103 | |
83 private: | 104 private: |
84 void ClearCopyRequests(); | 105 void ClearCopyRequests(); |
85 | 106 |
86 SurfaceId surface_id_; | 107 SurfaceId surface_id_; |
87 base::WeakPtr<SurfaceFactory> factory_; | 108 base::WeakPtr<SurfaceFactory> factory_; |
88 // TODO(jamesr): Support multiple frames in flight. | 109 // TODO(jamesr): Support multiple frames in flight. |
89 scoped_ptr<CompositorFrame> current_frame_; | 110 scoped_ptr<CompositorFrame> current_frame_; |
90 int frame_index_; | 111 int frame_index_; |
91 bool destroyed_; | 112 bool destroyed_; |
92 std::vector<SurfaceSequence> destruction_dependencies_; | 113 std::vector<SurfaceSequence> destruction_dependencies_; |
93 | 114 |
115 std::vector<Display*> currently_displayed_on_; | |
94 std::vector<SurfaceId> referenced_surfaces_; | 116 std::vector<SurfaceId> referenced_surfaces_; |
95 | 117 |
96 DrawCallback draw_callback_; | 118 DrawCallback draw_callback_; |
97 | 119 |
98 DISALLOW_COPY_AND_ASSIGN(Surface); | 120 DISALLOW_COPY_AND_ASSIGN(Surface); |
99 }; | 121 }; |
100 | 122 |
101 } // namespace cc | 123 } // namespace cc |
102 | 124 |
103 #endif // CC_SURFACES_SURFACE_H_ | 125 #endif // CC_SURFACES_SURFACE_H_ |
OLD | NEW |