Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: services/gfx/compositor/scene_state.h

Issue 1552963002: Initial checkin of the new Mozart compositor. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-11
Patch Set: fix android build Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/gfx/compositor/scene_impl.cc ('k') | services/gfx/compositor/scene_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #ifndef SERVICES_GFX_COMPOSITOR_SCENE_STATE_H_
6 #define SERVICES_GFX_COMPOSITOR_SCENE_STATE_H_
7
8 #include <memory>
9 #include <string>
10 #include <unordered_map>
11 #include <vector>
12
13 #include "base/callback.h"
14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h"
16 #include "mojo/services/gfx/composition/cpp/formatting.h"
17 #include "mojo/services/gfx/composition/interfaces/scenes.mojom.h"
18 #include "services/gfx/compositor/graph/scene_def.h"
19
20 namespace compositor {
21
22 using SceneFrameCallback =
23 base::Callback<void(mojo::gfx::composition::FrameInfoPtr)>;
24
25 // Describes the state of a particular scene.
26 // This object is owned by the CompositorEngine that created it.
27 class SceneState {
28 public:
29 SceneState(mojo::gfx::composition::SceneTokenPtr scene_token,
30 const std::string& label);
31 ~SceneState();
32
33 base::WeakPtr<SceneState> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
34
35 // Gets the token used to refer to this scene globally.
36 // Caller does not obtain ownership of the token.
37 mojo::gfx::composition::SceneToken* scene_token() {
38 return scene_def_.scene_token();
39 }
40
41 // Gets or sets the scene listener interface.
42 mojo::gfx::composition::SceneListener* scene_listener() {
43 return scene_listener_.get();
44 }
45 void set_scene_listener(mojo::gfx::composition::SceneListenerPtr listener) {
46 scene_listener_ = listener.Pass();
47 }
48
49 // Sets the associated scene implementation and takes ownership of it.
50 void set_scene_impl(mojo::gfx::composition::Scene* impl) {
51 scene_impl_.reset(impl);
52 }
53
54 // Gets the underlying scene definition, never null.
55 SceneDef* scene_def() { return &scene_def_; }
56
57 void AddSceneFrameCallback(const SceneFrameCallback& callback);
58 void DispatchSceneFrameCallbacks(
59 const mojo::gfx::composition::FrameInfo& frame_info);
60
61 const std::string& label() { return scene_def_.label(); }
62 std::string FormattedLabel() { return scene_def_.FormattedLabel(); }
63
64 private:
65 std::unique_ptr<mojo::gfx::composition::Scene> scene_impl_;
66 mojo::gfx::composition::SceneListenerPtr scene_listener_;
67 std::vector<SceneFrameCallback> pending_frame_callbacks_;
68
69 SceneDef scene_def_;
70
71 base::WeakPtrFactory<SceneState> weak_factory_;
72
73 DISALLOW_COPY_AND_ASSIGN(SceneState);
74 };
75
76 std::ostream& operator<<(std::ostream& os, SceneState* scene_state);
77
78 } // namespace compositor
79
80 #endif // SERVICES_GFX_COMPOSITOR_SCENE_STATE_H_
OLDNEW
« no previous file with comments | « services/gfx/compositor/scene_impl.cc ('k') | services/gfx/compositor/scene_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698