Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 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.
| |
| 56 SkRect::MakeXYWH(viewport.x, viewport.y, viewport.width, viewport.height); | |
| 57 RenderLayerBuilder layer_builder(&skia_viewport); | |
| 58 if (root_scene->Snapshot(this, &layer_builder)) { | |
| 59 snapshot_->frame_ = | |
| 60 RenderFrame::New(layer_builder.Build(), skia_viewport, frame_info); | |
| 61 } else { | |
| 62 snapshot_->valid_ = false; | |
| 63 } | |
| 64 return std::move(snapshot_); | |
| 65 } | |
| 66 | |
| 67 } // namespace compositor | |
| OLD | NEW |