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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/gfx/compositor/renderer_state.cc
diff --git a/services/gfx/compositor/renderer_state.cc b/services/gfx/compositor/renderer_state.cc
new file mode 100644
index 0000000000000000000000000000000000000000..28ba6870bf9bfcdf18781cc332713d73dc5fe7f5
--- /dev/null
+++ b/services/gfx/compositor/renderer_state.cc
@@ -0,0 +1,59 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/gfx/compositor/renderer_state.h"
+
+#include "base/logging.h"
+#include "base/strings/stringprintf.h"
+
+namespace compositor {
+
+RendererState::RendererState(uint32_t id, const std::string& label)
+ : id_(id), label_(label), weak_factory_(this) {}
+
+RendererState::~RendererState() {}
+
+bool RendererState::SetRootScene(SceneState* scene,
+ uint32_t version,
+ const mojo::Rect& viewport) {
+ DCHECK(scene);
+ DCHECK(version);
+
+ if (root_scene_ != scene || root_scene_version_ != version ||
+ !root_scene_viewport_.Equals(viewport)) {
+ root_scene_ = scene;
+ root_scene_version_ = version;
+ root_scene_viewport_ = viewport;
+ SetSnapshot(nullptr);
+ return true;
+ }
+ return false;
+}
+
+bool RendererState::SetSnapshot(std::unique_ptr<Snapshot> snapshot) {
+ snapshot_ = std::move(snapshot);
+ if (snapshot_ && snapshot_->valid()) {
+ frame_ = snapshot_->frame();
+ DCHECK(frame_);
+ return true;
+ }
+ return false;
+}
+
+std::string RendererState::FormattedLabel() {
+ if (formatted_label_cache_.empty()) {
+ formatted_label_cache_ =
+ label_.empty() ? base::StringPrintf("<%d>", id_)
+ : base::StringPrintf("<%d:%s>", id_, label_.c_str());
+ }
+ return formatted_label_cache_;
+}
+
+std::ostream& operator<<(std::ostream& os, RendererState* renderer_state) {
+ if (!renderer_state)
+ return os << "null";
+ return os << renderer_state->FormattedLabel();
+}
+
+} // namespace compositor
« 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