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

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: Created 4 years, 12 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
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..7b173da64e29dae5ee474369f0c3c4dd840ee57a
--- /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 skia_viewport =
abarth 2016/01/10 22:55:36 sk_viewport We usually use "sk" rather than "skia
jeffbrown 2016/01/16 03:28:32 Done.
+ SkRect::MakeXYWH(viewport.x, viewport.y, viewport.width, viewport.height);
+ RenderLayerBuilder layer_builder(&skia_viewport);
+ if (root_scene->Snapshot(this, &layer_builder)) {
+ snapshot_->frame_ =
+ RenderFrame::New(layer_builder.Build(), skia_viewport, frame_info);
+ } else {
+ snapshot_->valid_ = false;
+ }
+ return std::move(snapshot_);
+}
+
+} // namespace compositor

Powered by Google App Engine
This is Rietveld 408576698