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

Unified Diff: services/gfx/compositor/graph/snapshot.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/graph/snapshot.h ('k') | services/gfx/compositor/main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/gfx/compositor/graph/snapshot.cc
diff --git a/services/gfx/compositor/graph/snapshot.cc b/services/gfx/compositor/graph/snapshot.cc
new file mode 100644
index 0000000000000000000000000000000000000000..935fa2055b790c2a5b402736cb9be84e08e02344
--- /dev/null
+++ b/services/gfx/compositor/graph/snapshot.cc
@@ -0,0 +1,67 @@
+// 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/graph/snapshot.h"
+
+#include "base/logging.h"
+#include "services/gfx/compositor/graph/scene_def.h"
+#include "services/gfx/compositor/render/render_frame.h"
+#include "services/gfx/compositor/render/render_layer.h"
+#include "third_party/skia/include/core/SkRect.h"
+
+namespace compositor {
+
+Snapshot::Snapshot() {}
+
+Snapshot::~Snapshot() {}
+
+bool Snapshot::Invalidate() {
+ if (valid_) {
+ valid_ = false;
+ dependencies_.clear();
+ frame_.reset();
+ return true;
+ }
+ return false;
+}
+
+bool Snapshot::InvalidateScene(SceneDef* scene_def) {
+ DCHECK(scene_def);
+
+ if (valid_ && dependencies_.find(scene_def) != dependencies_.end()) {
+ return Invalidate();
+ }
+ return false;
+}
+
+SnapshotBuilder::SnapshotBuilder(std::ostream* block_log)
+ : block_log_(block_log), snapshot_(new Snapshot()) {}
+
+SnapshotBuilder::~SnapshotBuilder() {}
+
+void SnapshotBuilder::AddSceneDependency(SceneDef* scene) {
+ DCHECK(snapshot_);
+ snapshot_->dependencies_.insert(scene);
+}
+
+std::unique_ptr<Snapshot> SnapshotBuilder::Build(
+ SceneDef* root_scene,
+ const mojo::Rect& viewport,
+ const mojo::gfx::composition::FrameInfo& frame_info) {
+ DCHECK(snapshot_);
+ DCHECK(root_scene);
+
+ SkRect sk_viewport =
+ SkRect::MakeXYWH(viewport.x, viewport.y, viewport.width, viewport.height);
+ RenderLayerBuilder layer_builder(&sk_viewport);
+ if (root_scene->Snapshot(this, &layer_builder)) {
+ snapshot_->frame_ =
+ RenderFrame::Create(layer_builder.Build(), sk_viewport, frame_info);
+ } else {
+ snapshot_->valid_ = false;
+ }
+ return std::move(snapshot_);
+}
+
+} // namespace compositor
« no previous file with comments | « services/gfx/compositor/graph/snapshot.h ('k') | services/gfx/compositor/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698