OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "services/gfx/compositor/graph/scene_content.h" | 5 #include "services/gfx/compositor/graph/scene_content.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "services/gfx/compositor/graph/scene_def.h" | 10 #include "services/gfx/compositor/graph/scene_def.h" |
11 | 11 |
12 namespace compositor { | 12 namespace compositor { |
13 | 13 |
14 SceneContent::SceneContent(const SceneLabel& label, | 14 SceneContent::SceneContent(const SceneLabel& label, |
15 uint32_t version, | 15 uint32_t version, |
16 size_t max_resources, | 16 size_t max_resources, |
17 size_t max_nodes) | 17 size_t max_nodes) |
18 : label_(label), | 18 : label_(label), |
19 version_(version), | 19 version_(version), |
20 resources_(max_resources), | 20 resources_(max_resources), |
21 nodes_(max_nodes) {} | 21 nodes_(max_nodes) {} |
22 | 22 |
23 SceneContent::~SceneContent() {} | 23 SceneContent::~SceneContent() {} |
24 | 24 |
| 25 void SceneContent::RecordPicture(const Snapshot* snapshot, |
| 26 SkCanvas* canvas) const { |
| 27 const NodeDef* root = GetRootNodeIfExists(); |
| 28 if (root) |
| 29 root->RecordPicture(this, snapshot, canvas); |
| 30 } |
| 31 |
| 32 bool SceneContent::HitTest( |
| 33 const Snapshot* snapshot, |
| 34 const SkPoint& scene_point, |
| 35 const SkMatrix& global_to_scene_transform, |
| 36 mojo::gfx::composition::SceneHitPtr* out_scene_hit) const { |
| 37 DCHECK(snapshot); |
| 38 DCHECK(out_scene_hit); |
| 39 |
| 40 const NodeDef* root = GetRootNodeIfExists(); |
| 41 if (!root) |
| 42 return false; |
| 43 |
| 44 mojo::Array<mojo::gfx::composition::HitPtr> hits; |
| 45 bool opaque = root->HitTest(this, snapshot, scene_point, |
| 46 global_to_scene_transform, &hits); |
| 47 if (hits.size()) { |
| 48 auto scene_hit = mojo::gfx::composition::SceneHit::New(); |
| 49 scene_hit->scene_token = mojo::gfx::composition::SceneToken::New(); |
| 50 scene_hit->scene_token->value = label_.token(); |
| 51 scene_hit->scene_version = version_; |
| 52 scene_hit->hits = hits.Pass(); |
| 53 *out_scene_hit = scene_hit.Pass(); |
| 54 } |
| 55 return opaque; |
| 56 } |
| 57 |
25 const ResourceDef* SceneContent::GetResource( | 58 const ResourceDef* SceneContent::GetResource( |
26 uint32_t resource_id, | 59 uint32_t resource_id, |
27 ResourceDef::Type resource_type) const { | 60 ResourceDef::Type resource_type) const { |
28 auto it = resources_.find(resource_id); | 61 auto it = resources_.find(resource_id); |
29 DCHECK(it != resources_.end()); | 62 DCHECK(it != resources_.end()); |
30 DCHECK(it->second->type() == resource_type); | 63 DCHECK(it->second->type() == resource_type); |
31 return it->second.get(); | 64 return it->second.get(); |
32 } | 65 } |
33 | 66 |
34 const NodeDef* SceneContent::GetNode(uint32_t node_id) const { | 67 const NodeDef* SceneContent::GetNode(uint32_t node_id) const { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 166 } |
134 | 167 |
135 scoped_refptr<const SceneContent> SceneContentBuilder::Build() { | 168 scoped_refptr<const SceneContent> SceneContentBuilder::Build() { |
136 DCHECK(content_); | 169 DCHECK(content_); |
137 | 170 |
138 const NodeDef* root = scene_->FindRootNode(); | 171 const NodeDef* root = scene_->FindRootNode(); |
139 return !root || AddNode(root) ? std::move(content_) : nullptr; | 172 return !root || AddNode(root) ? std::move(content_) : nullptr; |
140 } | 173 } |
141 | 174 |
142 } // namespace compositor | 175 } // namespace compositor |
OLD | NEW |