| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/node_def.h" | 5 #include "services/gfx/compositor/graph/node_def.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "mojo/services/gfx/composition/cpp/formatting.h" | 10 #include "mojo/services/gfx/composition/cpp/formatting.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 | 34 |
| 35 bool Contains(const SkRect& bounds, const SkPoint& point) { | 35 bool Contains(const SkRect& bounds, const SkPoint& point) { |
| 36 return point.x() >= bounds.left() && point.x() < bounds.right() && | 36 return point.x() >= bounds.left() && point.x() < bounds.right() && |
| 37 point.y() >= bounds.top() && point.y() < bounds.bottom(); | 37 point.y() >= bounds.top() && point.y() < bounds.bottom(); |
| 38 } | 38 } |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 NodeDef::NodeDef(uint32_t node_id, | 41 NodeDef::NodeDef(uint32_t node_id, |
| 42 mojo::TransformPtr content_transform, | 42 mojo::TransformPtr content_transform, |
| 43 mojo::RectPtr content_clip, | 43 mojo::RectFPtr content_clip, |
| 44 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, | 44 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, |
| 45 Combinator combinator, | 45 Combinator combinator, |
| 46 const std::vector<uint32_t>& child_node_ids) | 46 const std::vector<uint32_t>& child_node_ids) |
| 47 : node_id_(node_id), | 47 : node_id_(node_id), |
| 48 content_transform_(content_transform.Pass()), | 48 content_transform_(content_transform.Pass()), |
| 49 content_clip_(content_clip.Pass()), | 49 content_clip_(content_clip.Pass()), |
| 50 hit_test_behavior_(hit_test_behavior.Pass()), | 50 hit_test_behavior_(hit_test_behavior.Pass()), |
| 51 combinator_(combinator), | 51 combinator_(combinator), |
| 52 child_node_ids_(child_node_ids) {} | 52 child_node_ids_(child_node_ids) {} |
| 53 | 53 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 hit->get_node()->transform = | 324 hit->get_node()->transform = |
| 325 mojo::ConvertTo<mojo::TransformPtr>(global_to_local_transform); | 325 mojo::ConvertTo<mojo::TransformPtr>(global_to_local_transform); |
| 326 hits->push_back(hit.Pass()); | 326 hits->push_back(hit.Pass()); |
| 327 return hit_test_behavior_->visibility == | 327 return hit_test_behavior_->visibility == |
| 328 mojo::gfx::composition::HitTestBehavior::Visibility::OPAQUE; | 328 mojo::gfx::composition::HitTestBehavior::Visibility::OPAQUE; |
| 329 } | 329 } |
| 330 | 330 |
| 331 RectNodeDef::RectNodeDef( | 331 RectNodeDef::RectNodeDef( |
| 332 uint32_t node_id, | 332 uint32_t node_id, |
| 333 mojo::TransformPtr content_transform, | 333 mojo::TransformPtr content_transform, |
| 334 mojo::RectPtr content_clip, | 334 mojo::RectFPtr content_clip, |
| 335 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, | 335 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, |
| 336 Combinator combinator, | 336 Combinator combinator, |
| 337 const std::vector<uint32_t>& child_node_ids, | 337 const std::vector<uint32_t>& child_node_ids, |
| 338 const mojo::Rect& content_rect, | 338 const mojo::RectF& content_rect, |
| 339 const mojo::gfx::composition::Color& color) | 339 const mojo::gfx::composition::Color& color) |
| 340 : NodeDef(node_id, | 340 : NodeDef(node_id, |
| 341 content_transform.Pass(), | 341 content_transform.Pass(), |
| 342 content_clip.Pass(), | 342 content_clip.Pass(), |
| 343 hit_test_behavior.Pass(), | 343 hit_test_behavior.Pass(), |
| 344 combinator, | 344 combinator, |
| 345 child_node_ids), | 345 child_node_ids), |
| 346 content_rect_(content_rect), | 346 content_rect_(content_rect), |
| 347 color_(color) {} | 347 color_(color) {} |
| 348 | 348 |
| 349 RectNodeDef::~RectNodeDef() {} | 349 RectNodeDef::~RectNodeDef() {} |
| 350 | 350 |
| 351 void RectNodeDef::RecordPictureInner(const SceneContent* content, | 351 void RectNodeDef::RecordPictureInner(const SceneContent* content, |
| 352 const Snapshot* snapshot, | 352 const Snapshot* snapshot, |
| 353 SkCanvas* canvas) const { | 353 SkCanvas* canvas) const { |
| 354 DCHECK(content); | 354 DCHECK(content); |
| 355 DCHECK(snapshot); | 355 DCHECK(snapshot); |
| 356 DCHECK(canvas); | 356 DCHECK(canvas); |
| 357 | 357 |
| 358 SkPaint paint; | 358 SkPaint paint; |
| 359 paint.setColor(MakeSkColor(color_)); | 359 paint.setColor(MakeSkColor(color_)); |
| 360 canvas->drawRect(content_rect_.To<SkRect>(), paint); | 360 canvas->drawRect(content_rect_.To<SkRect>(), paint); |
| 361 | 361 |
| 362 NodeDef::RecordPictureInner(content, snapshot, canvas); | 362 NodeDef::RecordPictureInner(content, snapshot, canvas); |
| 363 } | 363 } |
| 364 | 364 |
| 365 ImageNodeDef::ImageNodeDef( | 365 ImageNodeDef::ImageNodeDef( |
| 366 uint32_t node_id, | 366 uint32_t node_id, |
| 367 mojo::TransformPtr content_transform, | 367 mojo::TransformPtr content_transform, |
| 368 mojo::RectPtr content_clip, | 368 mojo::RectFPtr content_clip, |
| 369 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, | 369 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, |
| 370 Combinator combinator, | 370 Combinator combinator, |
| 371 const std::vector<uint32_t>& child_node_ids, | 371 const std::vector<uint32_t>& child_node_ids, |
| 372 const mojo::Rect& content_rect, | 372 const mojo::RectF& content_rect, |
| 373 mojo::RectPtr image_rect, | 373 mojo::RectFPtr image_rect, |
| 374 uint32 image_resource_id, | 374 uint32 image_resource_id, |
| 375 mojo::gfx::composition::BlendPtr blend) | 375 mojo::gfx::composition::BlendPtr blend) |
| 376 : NodeDef(node_id, | 376 : NodeDef(node_id, |
| 377 content_transform.Pass(), | 377 content_transform.Pass(), |
| 378 content_clip.Pass(), | 378 content_clip.Pass(), |
| 379 hit_test_behavior.Pass(), | 379 hit_test_behavior.Pass(), |
| 380 combinator, | 380 combinator, |
| 381 child_node_ids), | 381 child_node_ids), |
| 382 content_rect_(content_rect), | 382 content_rect_(content_rect), |
| 383 image_rect_(image_rect.Pass()), | 383 image_rect_(image_rect.Pass()), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 414 : SkRect::MakeWH(image_resource->image()->width(), | 414 : SkRect::MakeWH(image_resource->image()->width(), |
| 415 image_resource->image()->height()), | 415 image_resource->image()->height()), |
| 416 content_rect_.To<SkRect>(), &paint); | 416 content_rect_.To<SkRect>(), &paint); |
| 417 | 417 |
| 418 NodeDef::RecordPictureInner(content, snapshot, canvas); | 418 NodeDef::RecordPictureInner(content, snapshot, canvas); |
| 419 } | 419 } |
| 420 | 420 |
| 421 SceneNodeDef::SceneNodeDef( | 421 SceneNodeDef::SceneNodeDef( |
| 422 uint32_t node_id, | 422 uint32_t node_id, |
| 423 mojo::TransformPtr content_transform, | 423 mojo::TransformPtr content_transform, |
| 424 mojo::RectPtr content_clip, | 424 mojo::RectFPtr content_clip, |
| 425 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, | 425 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, |
| 426 Combinator combinator, | 426 Combinator combinator, |
| 427 const std::vector<uint32_t>& child_node_ids, | 427 const std::vector<uint32_t>& child_node_ids, |
| 428 uint32_t scene_resource_id, | 428 uint32_t scene_resource_id, |
| 429 uint32_t scene_version) | 429 uint32_t scene_version) |
| 430 : NodeDef(node_id, | 430 : NodeDef(node_id, |
| 431 content_transform.Pass(), | 431 content_transform.Pass(), |
| 432 content_clip.Pass(), | 432 content_clip.Pass(), |
| 433 hit_test_behavior.Pass(), | 433 hit_test_behavior.Pass(), |
| 434 combinator, | 434 combinator, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 auto hit = mojo::gfx::composition::Hit::New(); | 513 auto hit = mojo::gfx::composition::Hit::New(); |
| 514 hit->set_scene(scene_hit.Pass()); | 514 hit->set_scene(scene_hit.Pass()); |
| 515 hits->push_back(hit.Pass()); | 515 hits->push_back(hit.Pass()); |
| 516 } | 516 } |
| 517 return opaque; | 517 return opaque; |
| 518 } | 518 } |
| 519 | 519 |
| 520 LayerNodeDef::LayerNodeDef( | 520 LayerNodeDef::LayerNodeDef( |
| 521 uint32_t node_id, | 521 uint32_t node_id, |
| 522 mojo::TransformPtr content_transform, | 522 mojo::TransformPtr content_transform, |
| 523 mojo::RectPtr content_clip, | 523 mojo::RectFPtr content_clip, |
| 524 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, | 524 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, |
| 525 Combinator combinator, | 525 Combinator combinator, |
| 526 const std::vector<uint32_t>& child_node_ids, | 526 const std::vector<uint32_t>& child_node_ids, |
| 527 const mojo::Size& size, | 527 const mojo::RectF& layer_rect, |
| 528 mojo::gfx::composition::BlendPtr blend) | 528 mojo::gfx::composition::BlendPtr blend) |
| 529 : NodeDef(node_id, | 529 : NodeDef(node_id, |
| 530 content_transform.Pass(), | 530 content_transform.Pass(), |
| 531 content_clip.Pass(), | 531 content_clip.Pass(), |
| 532 hit_test_behavior.Pass(), | 532 hit_test_behavior.Pass(), |
| 533 combinator, | 533 combinator, |
| 534 child_node_ids), | 534 child_node_ids), |
| 535 size_(size), | 535 layer_rect_(layer_rect), |
| 536 blend_(blend.Pass()) {} | 536 blend_(blend.Pass()) {} |
| 537 | 537 |
| 538 LayerNodeDef::~LayerNodeDef() {} | 538 LayerNodeDef::~LayerNodeDef() {} |
| 539 | 539 |
| 540 void LayerNodeDef::RecordPictureInner(const SceneContent* content, | 540 void LayerNodeDef::RecordPictureInner(const SceneContent* content, |
| 541 const Snapshot* snapshot, | 541 const Snapshot* snapshot, |
| 542 SkCanvas* canvas) const { | 542 SkCanvas* canvas) const { |
| 543 DCHECK(content); | 543 DCHECK(content); |
| 544 DCHECK(snapshot); | 544 DCHECK(snapshot); |
| 545 DCHECK(canvas); | 545 DCHECK(canvas); |
| 546 | 546 |
| 547 SkPaint paint; | 547 SkPaint paint; |
| 548 SetPaintForBlend(&paint, blend_.get()); | 548 SetPaintForBlend(&paint, blend_.get()); |
| 549 | 549 |
| 550 canvas->saveLayer(SkRect::MakeWH(size_.width, size_.height), &paint); | 550 canvas->saveLayer(layer_rect_.To<SkRect>(), &paint); |
| 551 NodeDef::RecordPictureInner(content, snapshot, canvas); | 551 NodeDef::RecordPictureInner(content, snapshot, canvas); |
| 552 canvas->restore(); | 552 canvas->restore(); |
| 553 } | 553 } |
| 554 | 554 |
| 555 } // namespace compositor | 555 } // namespace compositor |
| OLD | NEW |