Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "components/exo/compositor_frame_sink_holder.h" | 5 #include "components/exo/compositor_frame_sink_holder.h" |
| 6 | 6 |
| 7 #include "cc/resources/returned_resource.h" | 7 #include "cc/resources/returned_resource.h" |
| 8 #include "components/exo/surface.h" | 8 #include "components/exo/surface.h" |
| 9 | 9 |
| 10 namespace exo { | 10 namespace exo { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 active_frame_callbacks_.pop_front(); | 76 active_frame_callbacks_.pop_front(); |
| 77 } | 77 } |
| 78 begin_frame_source_->OnBeginFrame(args); | 78 begin_frame_source_->OnBeginFrame(args); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void CompositorFrameSinkHolder::ReclaimResources( | 81 void CompositorFrameSinkHolder::ReclaimResources( |
| 82 const cc::ReturnedResourceArray& resources) { | 82 const cc::ReturnedResourceArray& resources) { |
| 83 for (auto& resource : resources) { | 83 for (auto& resource : resources) { |
| 84 auto it = release_callbacks_.find(resource.id); | 84 auto it = release_callbacks_.find(resource.id); |
| 85 DCHECK(it != release_callbacks_.end()); | 85 DCHECK(it != release_callbacks_.end()); |
| 86 std::unique_ptr<cc::SingleReleaseCallback> callback = | 86 |
| 87 std::move(it->second.second); | 87 // |callback_pair| is a std::pair<scoped_refptr<CompositorFrameSinkHolder>, |
|
reveman
2016/12/19 18:20:02
So why doesn't simply:
it->second.second->Run(res
Alex Z.
2016/12/19 18:34:03
The erase() triggers Release() of the scoped_refpt
reveman
2016/12/19 19:30:02
Ok, thanks for explaining. Instead of "auto callba
Alex Z.
2016/12/19 19:37:50
With that, the code would look really similar to w
Alex Z.
2016/12/19 20:05:39
In addition, it could still crash if more code is
reveman
2016/12/19 20:18:15
Yes, except the "holder(this)" part that is surpri
Alex Z.
2016/12/19 20:54:07
How do I post the task to the current message loop
| |
| 88 // std::unique_ptr<cc::SingleReleaseCallback>>. The | |
| 89 // scoped_refptr<CompositorFrameSinkHolder> inside prevent | |
| 90 // CompositorFrameSinkHolder being destroyed before ReclaimResources() | |
| 91 // returns. | |
| 92 auto callback_pair = std::move(it->second); | |
| 88 release_callbacks_.erase(it); | 93 release_callbacks_.erase(it); |
| 89 callback->Run(resource.sync_token, resource.lost); | 94 callback_pair.second->Run(resource.sync_token, resource.lost); |
| 90 } | 95 } |
| 91 } | 96 } |
| 92 | 97 |
| 93 void CompositorFrameSinkHolder::WillDrawSurface() { | 98 void CompositorFrameSinkHolder::WillDrawSurface() { |
| 94 if (surface_) | 99 if (surface_) |
| 95 surface_->WillDraw(); | 100 surface_->WillDraw(); |
| 96 | 101 |
| 97 UpdateNeedsBeginFrame(); | 102 UpdateNeedsBeginFrame(); |
| 98 } | 103 } |
| 99 | 104 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 | 138 |
| 134 bool needs_begin_frame = !active_frame_callbacks_.empty(); | 139 bool needs_begin_frame = !active_frame_callbacks_.empty(); |
| 135 if (needs_begin_frame == needs_begin_frame_) | 140 if (needs_begin_frame == needs_begin_frame_) |
| 136 return; | 141 return; |
| 137 | 142 |
| 138 needs_begin_frame_ = needs_begin_frame; | 143 needs_begin_frame_ = needs_begin_frame; |
| 139 OnNeedsBeginFrames(needs_begin_frame_); | 144 OnNeedsBeginFrames(needs_begin_frame_); |
| 140 } | 145 } |
| 141 | 146 |
| 142 } // namespace exo | 147 } // namespace exo |
| OLD | NEW |