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

Side by Side 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 unified diff | 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 »
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/graph/snapshot.h"
6
7 #include "base/logging.h"
8 #include "services/gfx/compositor/graph/scene_def.h"
9 #include "services/gfx/compositor/render/render_frame.h"
10 #include "services/gfx/compositor/render/render_layer.h"
11 #include "third_party/skia/include/core/SkRect.h"
12
13 namespace compositor {
14
15 Snapshot::Snapshot() {}
16
17 Snapshot::~Snapshot() {}
18
19 bool Snapshot::Invalidate() {
20 if (valid_) {
21 valid_ = false;
22 dependencies_.clear();
23 frame_.reset();
24 return true;
25 }
26 return false;
27 }
28
29 bool Snapshot::InvalidateScene(SceneDef* scene_def) {
30 DCHECK(scene_def);
31
32 if (valid_ && dependencies_.find(scene_def) != dependencies_.end()) {
33 return Invalidate();
34 }
35 return false;
36 }
37
38 SnapshotBuilder::SnapshotBuilder(std::ostream* block_log)
39 : block_log_(block_log), snapshot_(new Snapshot()) {}
40
41 SnapshotBuilder::~SnapshotBuilder() {}
42
43 void SnapshotBuilder::AddSceneDependency(SceneDef* scene) {
44 DCHECK(snapshot_);
45 snapshot_->dependencies_.insert(scene);
46 }
47
48 std::unique_ptr<Snapshot> SnapshotBuilder::Build(
49 SceneDef* root_scene,
50 const mojo::Rect& viewport,
51 const mojo::gfx::composition::FrameInfo& frame_info) {
52 DCHECK(snapshot_);
53 DCHECK(root_scene);
54
55 SkRect sk_viewport =
56 SkRect::MakeXYWH(viewport.x, viewport.y, viewport.width, viewport.height);
57 RenderLayerBuilder layer_builder(&sk_viewport);
58 if (root_scene->Snapshot(this, &layer_builder)) {
59 snapshot_->frame_ =
60 RenderFrame::Create(layer_builder.Build(), sk_viewport, frame_info);
61 } else {
62 snapshot_->valid_ = false;
63 }
64 return std::move(snapshot_);
65 }
66
67 } // namespace compositor
OLDNEW
« 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