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