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

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

Issue 1552963002: Initial checkin of the new Mozart compositor. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-11
Patch Set: Created 4 years, 11 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
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_RENDERER_STATE_H_
6 #define SERVICES_GFX_COMPOSITOR_RENDERER_STATE_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "mojo/services/gfx/composition/cpp/logging.h"
14 #include "mojo/services/gfx/composition/interfaces/compositor.mojom.h"
15 #include "services/gfx/compositor/backend/output.h"
16 #include "services/gfx/compositor/graph/snapshot.h"
17 #include "services/gfx/compositor/scene_state.h"
18
19 namespace compositor {
20
21 class Snapshot;
22
23 // Describes the state of a particular renderer.
24 // This object is owned by the CompositorEngine that created it.
25 class RendererState {
26 public:
27 RendererState(uint32_t id, const std::string& label);
28 ~RendererState();
29
30 base::WeakPtr<RendererState> GetWeakPtr() {
31 return weak_factory_.GetWeakPtr();
32 }
33
34 // Sets the associated renderer implementation and takes ownership of it.
35 void set_renderer_impl(mojo::gfx::composition::Renderer* impl) {
36 renderer_impl_.reset(impl);
37 }
38
39 // The underlying backend output.
40 void set_output(std::unique_ptr<Output> output) {
41 output_ = std::move(output);
42 }
43 Output* output() { return output_.get(); }
44
45 // Gets the root scene, may be null if none set yet.
46 SceneState* root_scene() { return root_scene_; }
47 uint32_t root_scene_version() { return root_scene_version_; }
48 const mojo::Rect& root_scene_viewport() { return root_scene_viewport_; }
49
50 // Sets the root scene and clears the current frame and cached dependencies.
51 // If different, invalidates the snapshot and returns true.
52 bool SetRootScene(SceneState* scene,
53 uint32_t version,
54 const mojo::Rect& viewport);
55
56 // The currently composited frame, may be null if none.
57 const std::shared_ptr<RenderFrame>& frame() { return frame_; }
58
59 // The current scene graph snapshot, may be null if none.
60 const std::unique_ptr<Snapshot>& snapshot() { return snapshot_; }
61
62 // Returns true if the renderer has a snapshot and it is valid.
63 // This implies that |frame()| is also non-null.
64 bool valid() { return snapshot_ && snapshot_->valid(); }
65
66 // Sets the snapshot, or null if none.
67 // If the snapshot is valid, updates |frame()| to point to the snapshot's
68 // new frame, otherwise leaves it alone.
69 // Returns true if the snapshot is valid.
70 bool SetSnapshot(std::unique_ptr<Snapshot> snapshot);
71
72 const std::string& label() { return label_; }
73 std::string FormattedLabel();
74
75 private:
76 std::unique_ptr<Output> output_;
77 const uint32_t id_;
78 const std::string label_;
79 std::string formatted_label_cache_;
80
81 std::unique_ptr<mojo::gfx::composition::Renderer> renderer_impl_;
82
83 SceneState* root_scene_ = nullptr;
84 uint32_t root_scene_version_ = mojo::gfx::composition::kSceneVersionNone;
85 mojo::Rect root_scene_viewport_;
86
87 std::shared_ptr<RenderFrame> frame_;
88 std::unique_ptr<Snapshot> snapshot_;
89
90 base::WeakPtrFactory<RendererState> weak_factory_; // must be last
abarth 2016/01/10 22:55:36 You can skip this comment. weak_factory_ always n
jeffbrown 2016/01/16 03:28:32 Done.
91
92 DISALLOW_COPY_AND_ASSIGN(RendererState);
93 };
94
95 std::ostream& operator<<(std::ostream& os, RendererState* renderer_state);
96
97 } // namespace compositor
98
99 #endif // SERVICES_GFX_COMPOSITOR_RENDERER_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698