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

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

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, 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
« no previous file with comments | « services/gfx/compositor/renderer_state.h ('k') | services/gfx/compositor/scene_impl.h » ('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 #include "services/gfx/compositor/renderer_state.h"
6
7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h"
9
10 namespace compositor {
11
12 RendererState::RendererState(uint32_t id, const std::string& label)
13 : id_(id), label_(label), weak_factory_(this) {}
14
15 RendererState::~RendererState() {}
16
17 bool RendererState::SetRootScene(SceneState* scene,
18 uint32_t version,
19 const mojo::Rect& viewport) {
20 DCHECK(scene);
21 DCHECK(version);
22
23 if (root_scene_ != scene || root_scene_version_ != version ||
24 !root_scene_viewport_.Equals(viewport)) {
25 root_scene_ = scene;
26 root_scene_version_ = version;
27 root_scene_viewport_ = viewport;
28 SetSnapshot(nullptr);
29 return true;
30 }
31 return false;
32 }
33
34 bool RendererState::SetSnapshot(std::unique_ptr<Snapshot> snapshot) {
35 snapshot_ = std::move(snapshot);
36 if (snapshot_ && snapshot_->valid()) {
37 frame_ = snapshot_->frame();
38 DCHECK(frame_);
39 return true;
40 }
41 return false;
42 }
43
44 std::string RendererState::FormattedLabel() {
45 if (formatted_label_cache_.empty()) {
46 formatted_label_cache_ =
47 label_.empty() ? base::StringPrintf("<%d>", id_)
48 : base::StringPrintf("<%d:%s>", id_, label_.c_str());
49 }
50 return formatted_label_cache_;
51 }
52
53 std::ostream& operator<<(std::ostream& os, RendererState* renderer_state) {
54 if (!renderer_state)
55 return os << "null";
56 return os << renderer_state->FormattedLabel();
57 }
58
59 } // namespace compositor
OLDNEW
« no previous file with comments | « services/gfx/compositor/renderer_state.h ('k') | services/gfx/compositor/scene_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698