| 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 #ifndef SERVICES_GFX_COMPOSITOR_SCENE_STATE_H_ | 5 #ifndef SERVICES_GFX_COMPOSITOR_SCENE_STATE_H_ |
| 6 #define SERVICES_GFX_COMPOSITOR_SCENE_STATE_H_ | 6 #define SERVICES_GFX_COMPOSITOR_SCENE_STATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| 11 #include <vector> | |
| 12 | 11 |
| 13 #include "base/callback.h" | 12 #include "base/callback.h" |
| 14 #include "base/macros.h" | 13 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 16 #include "mojo/services/gfx/composition/cpp/formatting.h" | 15 #include "mojo/services/gfx/composition/cpp/formatting.h" |
| 17 #include "mojo/services/gfx/composition/interfaces/scenes.mojom.h" | 16 #include "mojo/services/gfx/composition/interfaces/scenes.mojom.h" |
| 17 #include "services/gfx/compositor/frame_dispatcher.h" |
| 18 #include "services/gfx/compositor/graph/scene_def.h" | 18 #include "services/gfx/compositor/graph/scene_def.h" |
| 19 | 19 |
| 20 namespace compositor { | 20 namespace compositor { |
| 21 | 21 |
| 22 using SceneFrameCallback = | |
| 23 base::Callback<void(mojo::gfx::composition::FrameInfoPtr)>; | |
| 24 | |
| 25 // Describes the state of a particular scene. | 22 // Describes the state of a particular scene. |
| 26 // This object is owned by the CompositorEngine that created it. | 23 // This object is owned by the CompositorEngine that created it. |
| 27 class SceneState { | 24 class SceneState { |
| 28 public: | 25 public: |
| 29 SceneState(mojo::gfx::composition::SceneTokenPtr scene_token, | 26 SceneState(mojo::gfx::composition::SceneTokenPtr scene_token, |
| 30 const std::string& label); | 27 const std::string& label); |
| 31 ~SceneState(); | 28 ~SceneState(); |
| 32 | 29 |
| 33 base::WeakPtr<SceneState> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } | 30 base::WeakPtr<SceneState> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } |
| 34 | 31 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 47 } | 44 } |
| 48 | 45 |
| 49 // Sets the associated scene implementation and takes ownership of it. | 46 // Sets the associated scene implementation and takes ownership of it. |
| 50 void set_scene_impl(mojo::gfx::composition::Scene* impl) { | 47 void set_scene_impl(mojo::gfx::composition::Scene* impl) { |
| 51 scene_impl_.reset(impl); | 48 scene_impl_.reset(impl); |
| 52 } | 49 } |
| 53 | 50 |
| 54 // Gets the underlying scene definition, never null. | 51 // Gets the underlying scene definition, never null. |
| 55 SceneDef* scene_def() { return &scene_def_; } | 52 SceneDef* scene_def() { return &scene_def_; } |
| 56 | 53 |
| 57 void AddSceneFrameCallback(const SceneFrameCallback& callback); | 54 FrameDispatcher& frame_dispatcher() { return frame_dispatcher_; } |
| 58 void DispatchSceneFrameCallbacks( | |
| 59 const mojo::gfx::composition::FrameInfo& frame_info); | |
| 60 | 55 |
| 61 private: | 56 private: |
| 62 mojo::gfx::composition::SceneTokenPtr scene_token_; | 57 mojo::gfx::composition::SceneTokenPtr scene_token_; |
| 58 |
| 59 FrameDispatcher frame_dispatcher_; // must be before scene_impl_ |
| 63 std::unique_ptr<mojo::gfx::composition::Scene> scene_impl_; | 60 std::unique_ptr<mojo::gfx::composition::Scene> scene_impl_; |
| 61 |
| 64 mojo::gfx::composition::SceneListenerPtr scene_listener_; | 62 mojo::gfx::composition::SceneListenerPtr scene_listener_; |
| 65 std::vector<SceneFrameCallback> pending_frame_callbacks_; | |
| 66 | 63 |
| 67 SceneDef scene_def_; | 64 SceneDef scene_def_; |
| 68 | 65 |
| 69 base::WeakPtrFactory<SceneState> weak_factory_; | 66 base::WeakPtrFactory<SceneState> weak_factory_; |
| 70 | 67 |
| 71 DISALLOW_COPY_AND_ASSIGN(SceneState); | 68 DISALLOW_COPY_AND_ASSIGN(SceneState); |
| 72 }; | 69 }; |
| 73 | 70 |
| 74 std::ostream& operator<<(std::ostream& os, SceneState* scene_state); | 71 std::ostream& operator<<(std::ostream& os, SceneState* scene_state); |
| 75 | 72 |
| 76 } // namespace compositor | 73 } // namespace compositor |
| 77 | 74 |
| 78 #endif // SERVICES_GFX_COMPOSITOR_SCENE_STATE_H_ | 75 #endif // SERVICES_GFX_COMPOSITOR_SCENE_STATE_H_ |
| OLD | NEW |