| 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 mojo::gfx::composition::SceneHitPtr SceneContent::HitTest( |
| 33 const Snapshot* snapshot, |
| 34 const SkPoint& global_point, |
| 35 const SkMatrix& scene_transform, |
| 36 bool* opaque) const { |
| 37 DCHECK(snapshot); |
| 38 DCHECK(opaque); |
| 39 |
| 40 mojo::Array<mojo::gfx::composition::HitPtr> hits; |
| 41 const NodeDef* root = GetRootNodeIfExists(); |
| 42 if (root) |
| 43 root->HitTest(this, snapshot, global_point, scene_transform, opaque, &hits); |
| 44 if (!hits.size()) |
| 45 return nullptr; |
| 46 |
| 47 auto scene_hit = mojo::gfx::composition::SceneHit::New(); |
| 48 scene_hit->scene_token = mojo::gfx::composition::SceneToken::New(); |
| 49 scene_hit->scene_token->value = label_.token(); |
| 50 scene_hit->scene_version = version_; |
| 51 scene_hit->hits = hits.Pass(); |
| 52 return scene_hit.Pass(); |
| 53 } |
| 54 |
| 25 const ResourceDef* SceneContent::GetResource( | 55 const ResourceDef* SceneContent::GetResource( |
| 26 uint32_t resource_id, | 56 uint32_t resource_id, |
| 27 ResourceDef::Type resource_type) const { | 57 ResourceDef::Type resource_type) const { |
| 28 auto it = resources_.find(resource_id); | 58 auto it = resources_.find(resource_id); |
| 29 DCHECK(it != resources_.end()); | 59 DCHECK(it != resources_.end()); |
| 30 DCHECK(it->second->type() == resource_type); | 60 DCHECK(it->second->type() == resource_type); |
| 31 return it->second.get(); | 61 return it->second.get(); |
| 32 } | 62 } |
| 33 | 63 |
| 34 const NodeDef* SceneContent::GetNode(uint32_t node_id) const { | 64 const NodeDef* SceneContent::GetNode(uint32_t node_id) const { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 163 } |
| 134 | 164 |
| 135 scoped_refptr<const SceneContent> SceneContentBuilder::Build() { | 165 scoped_refptr<const SceneContent> SceneContentBuilder::Build() { |
| 136 DCHECK(content_); | 166 DCHECK(content_); |
| 137 | 167 |
| 138 const NodeDef* root = scene_->FindRootNode(); | 168 const NodeDef* root = scene_->FindRootNode(); |
| 139 return !root || AddNode(root) ? std::move(content_) : nullptr; | 169 return !root || AddNode(root) ? std::move(content_) : nullptr; |
| 140 } | 170 } |
| 141 | 171 |
| 142 } // namespace compositor | 172 } // namespace compositor |
| OLD | NEW |