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 #include "services/gfx/compositor/scene_state.h" | 5 #include "services/gfx/compositor/scene_state.h" |
6 | 6 |
7 namespace compositor { | 7 namespace compositor { |
8 | 8 |
9 SceneState::SceneState(mojo::gfx::composition::SceneTokenPtr scene_token, | 9 SceneState::SceneState(mojo::gfx::composition::SceneTokenPtr scene_token, |
10 const std::string& label) | 10 const std::string& label) |
11 : scene_token_(scene_token.Pass()), | 11 : scene_token_(scene_token.Pass()), |
12 scene_def_(SceneLabel(scene_token_->value, label)), | 12 scene_def_(SceneLabel(scene_token_->value, label)), |
13 weak_factory_(this) { | 13 weak_factory_(this) { |
14 DCHECK(scene_token_); | 14 DCHECK(scene_token_); |
15 } | 15 } |
16 | 16 |
17 SceneState::~SceneState() { | 17 SceneState::~SceneState() {} |
18 // The scene implementation and all of its bindings must be destroyed | |
19 // before any pending callbacks are dropped on the floor. | |
20 scene_impl_.reset(); | |
21 pending_frame_callbacks_.clear(); | |
22 } | |
23 | |
24 void SceneState::AddSceneFrameCallback(const SceneFrameCallback& callback) { | |
25 pending_frame_callbacks_.push_back(callback); | |
26 } | |
27 | |
28 void SceneState::DispatchSceneFrameCallbacks( | |
29 const mojo::gfx::composition::FrameInfo& frame_info) { | |
30 for (auto& callback : pending_frame_callbacks_) { | |
31 callback.Run(frame_info.Clone()); | |
32 } | |
33 pending_frame_callbacks_.clear(); | |
34 } | |
35 | 18 |
36 std::ostream& operator<<(std::ostream& os, SceneState* scene_state) { | 19 std::ostream& operator<<(std::ostream& os, SceneState* scene_state) { |
37 if (!scene_state) | 20 if (!scene_state) |
38 return os << "null"; | 21 return os << "null"; |
39 return os << scene_state->scene_def()->FormattedLabel(); | 22 return os << scene_state->scene_def()->FormattedLabel(); |
40 } | 23 } |
41 | 24 |
42 } // namespace compositor | 25 } // namespace compositor |
OLD | NEW |