| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/compositor/layer.h" | 5 #include "ui/compositor/layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const ui::Layer* GetRoot(const ui::Layer* layer) { | 42 const ui::Layer* GetRoot(const ui::Layer* layer) { |
| 43 while (layer->parent()) | 43 while (layer->parent()) |
| 44 layer = layer->parent(); | 44 layer = layer->parent(); |
| 45 return layer; | 45 return layer; |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 namespace ui { | 50 namespace ui { |
| 51 | 51 |
| 52 class Layer::LayerMirror : public LayerDelegate, LayerObserver { |
| 53 public: |
| 54 LayerMirror(Layer* source, Layer* dest) |
| 55 : source_(source), dest_(dest) { |
| 56 dest->AddObserver(this); |
| 57 dest->set_delegate(this); |
| 58 } |
| 59 |
| 60 ~LayerMirror() override { |
| 61 dest_->RemoveObserver(this); |
| 62 dest_->set_delegate(nullptr); |
| 63 } |
| 64 |
| 65 Layer* dest() { return dest_; } |
| 66 |
| 67 // LayerDelegate: |
| 68 void OnPaintLayer(const PaintContext& context) override { |
| 69 if (auto* delegate = source_->delegate()) |
| 70 delegate->OnPaintLayer(context); |
| 71 } |
| 72 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} |
| 73 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
| 74 |
| 75 // LayerObserver: |
| 76 void LayerDestroyed(Layer* layer) override { |
| 77 DCHECK_EQ(dest_, layer); |
| 78 source_->OnMirrorDestroyed(this); |
| 79 } |
| 80 |
| 81 private: |
| 82 Layer* const source_; |
| 83 Layer* const dest_; |
| 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(LayerMirror); |
| 86 }; |
| 87 |
| 52 Layer::Layer() | 88 Layer::Layer() |
| 53 : type_(LAYER_TEXTURED), | 89 : type_(LAYER_TEXTURED), |
| 54 compositor_(NULL), | 90 compositor_(NULL), |
| 55 parent_(NULL), | 91 parent_(NULL), |
| 56 visible_(true), | 92 visible_(true), |
| 57 fills_bounds_opaquely_(true), | 93 fills_bounds_opaquely_(true), |
| 58 fills_bounds_completely_(false), | 94 fills_bounds_completely_(false), |
| 59 background_blur_radius_(0), | 95 background_blur_radius_(0), |
| 60 layer_saturation_(0.0f), | 96 layer_saturation_(0.0f), |
| 61 layer_brightness_(0.0f), | 97 layer_brightness_(0.0f), |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (layer_mask_back_link_) | 147 if (layer_mask_back_link_) |
| 112 layer_mask_back_link_->SetMaskLayer(NULL); | 148 layer_mask_back_link_->SetMaskLayer(NULL); |
| 113 for (size_t i = 0; i < children_.size(); ++i) | 149 for (size_t i = 0; i < children_.size(); ++i) |
| 114 children_[i]->parent_ = NULL; | 150 children_[i]->parent_ = NULL; |
| 115 | 151 |
| 116 cc_layer_->RemoveFromParent(); | 152 cc_layer_->RemoveFromParent(); |
| 117 if (mailbox_release_callback_) | 153 if (mailbox_release_callback_) |
| 118 mailbox_release_callback_->Run(gpu::SyncToken(), false); | 154 mailbox_release_callback_->Run(gpu::SyncToken(), false); |
| 119 } | 155 } |
| 120 | 156 |
| 157 std::unique_ptr<Layer> Layer::Clone() const { |
| 158 auto clone = base::MakeUnique<Layer>(type_); |
| 159 |
| 160 clone->SetTransform(GetTargetTransform()); |
| 161 clone->SetBounds(bounds_); |
| 162 clone->SetSubpixelPositionOffset(subpixel_position_offset_); |
| 163 clone->SetMasksToBounds(GetMasksToBounds()); |
| 164 clone->SetOpacity(GetTargetOpacity()); |
| 165 clone->SetVisible(GetTargetVisibility()); |
| 166 clone->SetFillsBoundsOpaquely(fills_bounds_opaquely_); |
| 167 clone->SetFillsBoundsCompletely(fills_bounds_completely_); |
| 168 clone->set_name(name_); |
| 169 |
| 170 // Background filters. |
| 171 clone->SetBackgroundBlur(background_blur_radius_); |
| 172 clone->SetBackgroundZoom(zoom_, zoom_inset_); |
| 173 |
| 174 // Filters. |
| 175 clone->SetLayerSaturation(layer_saturation_); |
| 176 clone->SetLayerBrightness(GetTargetBrightness()); |
| 177 clone->SetLayerGrayscale(GetTargetGrayscale()); |
| 178 clone->SetLayerInverted(layer_inverted_); |
| 179 if (alpha_shape_) |
| 180 clone->SetAlphaShape(base::MakeUnique<SkRegion>(*alpha_shape_)); |
| 181 |
| 182 // cc::Layer state. |
| 183 if (surface_layer_ && !surface_layer_->surface_id().is_null()) { |
| 184 clone->SetShowSurface( |
| 185 surface_layer_->surface_id(), |
| 186 surface_layer_->satisfy_callback(), |
| 187 surface_layer_->require_callback(), |
| 188 surface_layer_->surface_size(), |
| 189 surface_layer_->surface_scale(), |
| 190 frame_size_in_dip_); |
| 191 } else if (type_ == LAYER_SOLID_COLOR) { |
| 192 clone->SetColor(GetTargetColor()); |
| 193 } |
| 194 return clone; |
| 195 } |
| 196 |
| 197 std::unique_ptr<Layer> Layer::Mirror() { |
| 198 auto mirror = Clone(); |
| 199 mirrors_.emplace_back(base::MakeUnique<LayerMirror>(this, mirror.get())); |
| 200 return mirror; |
| 201 } |
| 202 |
| 121 const Compositor* Layer::GetCompositor() const { | 203 const Compositor* Layer::GetCompositor() const { |
| 122 return GetRoot(this)->compositor_; | 204 return GetRoot(this)->compositor_; |
| 123 } | 205 } |
| 124 | 206 |
| 125 float Layer::opacity() const { | 207 float Layer::opacity() const { |
| 126 return cc_layer_->opacity(); | 208 return cc_layer_->opacity(); |
| 127 } | 209 } |
| 128 | 210 |
| 129 void Layer::SetCompositor(Compositor* compositor, | 211 void Layer::SetCompositor(Compositor* compositor, |
| 130 scoped_refptr<cc::Layer> root_layer) { | 212 scoped_refptr<cc::Layer> root_layer) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 animator_ = animator; | 312 animator_ = animator; |
| 231 | 313 |
| 232 if (animator_) { | 314 if (animator_) { |
| 233 animator_->SetDelegate(this); | 315 animator_->SetDelegate(this); |
| 234 if (compositor) | 316 if (compositor) |
| 235 animator_->AttachLayerAndTimeline(compositor); | 317 animator_->AttachLayerAndTimeline(compositor); |
| 236 } | 318 } |
| 237 } | 319 } |
| 238 | 320 |
| 239 LayerAnimator* Layer::GetAnimator() { | 321 LayerAnimator* Layer::GetAnimator() { |
| 240 if (!animator_.get()) | 322 if (!animator_) |
| 241 SetAnimator(LayerAnimator::CreateDefaultAnimator()); | 323 SetAnimator(LayerAnimator::CreateDefaultAnimator()); |
| 242 return animator_.get(); | 324 return animator_.get(); |
| 243 } | 325 } |
| 244 | 326 |
| 245 void Layer::SetTransform(const gfx::Transform& transform) { | 327 void Layer::SetTransform(const gfx::Transform& transform) { |
| 246 GetAnimator()->SetTransform(transform); | 328 GetAnimator()->SetTransform(transform); |
| 247 } | 329 } |
| 248 | 330 |
| 249 gfx::Transform Layer::GetTargetTransform() const { | 331 gfx::Transform Layer::GetTargetTransform() const { |
| 250 if (animator_.get() && animator_->IsAnimatingProperty( | 332 if (animator_ && animator_->IsAnimatingProperty( |
| 251 LayerAnimationElement::TRANSFORM)) { | 333 LayerAnimationElement::TRANSFORM)) { |
| 252 return animator_->GetTargetTransform(); | 334 return animator_->GetTargetTransform(); |
| 253 } | 335 } |
| 254 return transform(); | 336 return transform(); |
| 255 } | 337 } |
| 256 | 338 |
| 257 void Layer::SetBounds(const gfx::Rect& bounds) { | 339 void Layer::SetBounds(const gfx::Rect& bounds) { |
| 258 GetAnimator()->SetBounds(bounds); | 340 GetAnimator()->SetBounds(bounds); |
| 259 } | 341 } |
| 260 | 342 |
| 261 void Layer::SetSubpixelPositionOffset(const gfx::Vector2dF& offset) { | 343 void Layer::SetSubpixelPositionOffset(const gfx::Vector2dF& offset) { |
| 262 subpixel_position_offset_ = offset; | 344 subpixel_position_offset_ = offset; |
| 263 RecomputePosition(); | 345 RecomputePosition(); |
| 264 } | 346 } |
| 265 | 347 |
| 266 gfx::Rect Layer::GetTargetBounds() const { | 348 gfx::Rect Layer::GetTargetBounds() const { |
| 267 if (animator_.get() && animator_->IsAnimatingProperty( | 349 if (animator_ && animator_->IsAnimatingProperty( |
| 268 LayerAnimationElement::BOUNDS)) { | 350 LayerAnimationElement::BOUNDS)) { |
| 269 return animator_->GetTargetBounds(); | 351 return animator_->GetTargetBounds(); |
| 270 } | 352 } |
| 271 return bounds_; | 353 return bounds_; |
| 272 } | 354 } |
| 273 | 355 |
| 274 void Layer::SetMasksToBounds(bool masks_to_bounds) { | 356 void Layer::SetMasksToBounds(bool masks_to_bounds) { |
| 275 cc_layer_->SetMasksToBounds(masks_to_bounds); | 357 cc_layer_->SetMasksToBounds(masks_to_bounds); |
| 276 } | 358 } |
| 277 | 359 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 302 void Layer::SetLayerSaturation(float saturation) { | 384 void Layer::SetLayerSaturation(float saturation) { |
| 303 layer_saturation_ = saturation; | 385 layer_saturation_ = saturation; |
| 304 SetLayerFilters(); | 386 SetLayerFilters(); |
| 305 } | 387 } |
| 306 | 388 |
| 307 void Layer::SetLayerBrightness(float brightness) { | 389 void Layer::SetLayerBrightness(float brightness) { |
| 308 GetAnimator()->SetBrightness(brightness); | 390 GetAnimator()->SetBrightness(brightness); |
| 309 } | 391 } |
| 310 | 392 |
| 311 float Layer::GetTargetBrightness() const { | 393 float Layer::GetTargetBrightness() const { |
| 312 if (animator_.get() && animator_->IsAnimatingProperty( | 394 if (animator_ && animator_->IsAnimatingProperty( |
| 313 LayerAnimationElement::BRIGHTNESS)) { | 395 LayerAnimationElement::BRIGHTNESS)) { |
| 314 return animator_->GetTargetBrightness(); | 396 return animator_->GetTargetBrightness(); |
| 315 } | 397 } |
| 316 return layer_brightness(); | 398 return layer_brightness(); |
| 317 } | 399 } |
| 318 | 400 |
| 319 void Layer::SetLayerGrayscale(float grayscale) { | 401 void Layer::SetLayerGrayscale(float grayscale) { |
| 320 GetAnimator()->SetGrayscale(grayscale); | 402 GetAnimator()->SetGrayscale(grayscale); |
| 321 } | 403 } |
| 322 | 404 |
| 323 float Layer::GetTargetGrayscale() const { | 405 float Layer::GetTargetGrayscale() const { |
| 324 if (animator_.get() && animator_->IsAnimatingProperty( | 406 if (animator_ && animator_->IsAnimatingProperty( |
| 325 LayerAnimationElement::GRAYSCALE)) { | 407 LayerAnimationElement::GRAYSCALE)) { |
| 326 return animator_->GetTargetGrayscale(); | 408 return animator_->GetTargetGrayscale(); |
| 327 } | 409 } |
| 328 return layer_grayscale(); | 410 return layer_grayscale(); |
| 329 } | 411 } |
| 330 | 412 |
| 331 void Layer::SetLayerInverted(bool inverted) { | 413 void Layer::SetLayerInverted(bool inverted) { |
| 332 layer_inverted_ = inverted; | 414 layer_inverted_ = inverted; |
| 333 SetLayerFilters(); | 415 SetLayerFilters(); |
| 334 } | 416 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 485 |
| 404 if (background_blur_radius_) { | 486 if (background_blur_radius_) { |
| 405 filters.Append(cc::FilterOperation::CreateBlurFilter( | 487 filters.Append(cc::FilterOperation::CreateBlurFilter( |
| 406 background_blur_radius_)); | 488 background_blur_radius_)); |
| 407 } | 489 } |
| 408 | 490 |
| 409 cc_layer_->SetBackgroundFilters(filters); | 491 cc_layer_->SetBackgroundFilters(filters); |
| 410 } | 492 } |
| 411 | 493 |
| 412 float Layer::GetTargetOpacity() const { | 494 float Layer::GetTargetOpacity() const { |
| 413 if (animator_.get() && animator_->IsAnimatingProperty( | 495 if (animator_ && animator_->IsAnimatingProperty( |
| 414 LayerAnimationElement::OPACITY)) | 496 LayerAnimationElement::OPACITY)) |
| 415 return animator_->GetTargetOpacity(); | 497 return animator_->GetTargetOpacity(); |
| 416 return opacity(); | 498 return opacity(); |
| 417 } | 499 } |
| 418 | 500 |
| 419 void Layer::SetVisible(bool visible) { | 501 void Layer::SetVisible(bool visible) { |
| 420 GetAnimator()->SetVisibility(visible); | 502 GetAnimator()->SetVisibility(visible); |
| 421 } | 503 } |
| 422 | 504 |
| 423 bool Layer::GetTargetVisibility() const { | 505 bool Layer::GetTargetVisibility() const { |
| 424 if (animator_.get() && animator_->IsAnimatingProperty( | 506 if (animator_ && animator_->IsAnimatingProperty( |
| 425 LayerAnimationElement::VISIBILITY)) | 507 LayerAnimationElement::VISIBILITY)) |
| 426 return animator_->GetTargetVisibility(); | 508 return animator_->GetTargetVisibility(); |
| 427 return visible_; | 509 return visible_; |
| 428 } | 510 } |
| 429 | 511 |
| 430 bool Layer::IsDrawn() const { | 512 bool Layer::IsDrawn() const { |
| 431 const Layer* layer = this; | 513 const Layer* layer = this; |
| 432 while (layer && layer->visible_) | 514 while (layer && layer->visible_) |
| 433 layer = layer->parent_; | 515 layer = layer->parent_; |
| 434 return layer == NULL; | 516 return layer == NULL; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 560 |
| 479 cc_layer_->SetContentsOpaque(fills_bounds_opaquely); | 561 cc_layer_->SetContentsOpaque(fills_bounds_opaquely); |
| 480 } | 562 } |
| 481 | 563 |
| 482 void Layer::SetFillsBoundsCompletely(bool fills_bounds_completely) { | 564 void Layer::SetFillsBoundsCompletely(bool fills_bounds_completely) { |
| 483 fills_bounds_completely_ = fills_bounds_completely; | 565 fills_bounds_completely_ = fills_bounds_completely; |
| 484 } | 566 } |
| 485 | 567 |
| 486 void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) { | 568 void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) { |
| 487 // Finish animations being handled by cc_layer_. | 569 // Finish animations being handled by cc_layer_. |
| 488 if (animator_.get()) { | 570 if (animator_) { |
| 489 animator_->StopAnimatingProperty(LayerAnimationElement::TRANSFORM); | 571 animator_->StopAnimatingProperty(LayerAnimationElement::TRANSFORM); |
| 490 animator_->StopAnimatingProperty(LayerAnimationElement::OPACITY); | 572 animator_->StopAnimatingProperty(LayerAnimationElement::OPACITY); |
| 491 animator_->SwitchToLayer(new_layer); | 573 animator_->SwitchToLayer(new_layer); |
| 492 } | 574 } |
| 493 | 575 |
| 494 if (texture_layer_.get()) | 576 if (texture_layer_.get()) |
| 495 texture_layer_->ClearClient(); | 577 texture_layer_->ClearClient(); |
| 496 | 578 |
| 497 cc_layer_->RemoveAllChildren(); | 579 cc_layer_->RemoveAllChildren(); |
| 498 if (cc_layer_->parent()) { | 580 if (cc_layer_->parent()) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 | 667 |
| 586 scoped_refptr<cc::SurfaceLayer> new_layer = | 668 scoped_refptr<cc::SurfaceLayer> new_layer = |
| 587 cc::SurfaceLayer::Create(satisfy_callback, require_callback); | 669 cc::SurfaceLayer::Create(satisfy_callback, require_callback); |
| 588 new_layer->SetSurfaceId(surface_id, scale, surface_size); | 670 new_layer->SetSurfaceId(surface_id, scale, surface_size); |
| 589 SwitchToLayer(new_layer); | 671 SwitchToLayer(new_layer); |
| 590 surface_layer_ = new_layer; | 672 surface_layer_ = new_layer; |
| 591 | 673 |
| 592 frame_size_in_dip_ = frame_size_in_dip; | 674 frame_size_in_dip_ = frame_size_in_dip; |
| 593 RecomputeDrawsContentAndUVRect(); | 675 RecomputeDrawsContentAndUVRect(); |
| 594 | 676 |
| 595 FOR_EACH_OBSERVER(LayerObserver, observer_list_, SurfaceChanged(this)); | 677 for (const auto& mirror : mirrors_) { |
| 678 mirror->dest()->SetShowSurface( |
| 679 surface_id, satisfy_callback, require_callback, |
| 680 surface_size, scale, frame_size_in_dip); |
| 681 } |
| 596 } | 682 } |
| 597 | 683 |
| 598 void Layer::SetShowSolidColorContent() { | 684 void Layer::SetShowSolidColorContent() { |
| 599 DCHECK_EQ(type_, LAYER_SOLID_COLOR); | 685 DCHECK_EQ(type_, LAYER_SOLID_COLOR); |
| 600 | 686 |
| 601 if (solid_color_layer_.get()) | 687 if (solid_color_layer_.get()) |
| 602 return; | 688 return; |
| 603 | 689 |
| 604 scoped_refptr<cc::SolidColorLayer> new_layer = cc::SolidColorLayer::Create(); | 690 scoped_refptr<cc::SolidColorLayer> new_layer = cc::SolidColorLayer::Create(); |
| 605 SwitchToLayer(new_layer); | 691 SwitchToLayer(new_layer); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 nine_patch_layer_->SetBorder(border); | 728 nine_patch_layer_->SetBorder(border); |
| 643 } | 729 } |
| 644 | 730 |
| 645 void Layer::UpdateNinePatchOcclusion(const gfx::Rect& occlusion) { | 731 void Layer::UpdateNinePatchOcclusion(const gfx::Rect& occlusion) { |
| 646 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); | 732 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); |
| 647 nine_patch_layer_->SetLayerOcclusion(occlusion); | 733 nine_patch_layer_->SetLayerOcclusion(occlusion); |
| 648 } | 734 } |
| 649 | 735 |
| 650 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } | 736 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } |
| 651 | 737 |
| 652 SkColor Layer::GetTargetColor() { | 738 SkColor Layer::GetTargetColor() const { |
| 653 if (GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR)) | 739 if (animator_ && animator_->IsAnimatingProperty( |
| 654 return GetAnimator()->GetTargetColor(); | 740 LayerAnimationElement::COLOR)) |
| 741 return animator_->GetTargetColor(); |
| 655 return cc_layer_->background_color(); | 742 return cc_layer_->background_color(); |
| 656 } | 743 } |
| 657 | 744 |
| 658 SkColor Layer::background_color() const { | 745 SkColor Layer::background_color() const { |
| 659 return cc_layer_->background_color(); | 746 return cc_layer_->background_color(); |
| 660 } | 747 } |
| 661 | 748 |
| 662 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { | 749 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { |
| 663 if ((type_ == LAYER_SOLID_COLOR && !texture_layer_.get()) || | 750 if ((type_ == LAYER_SOLID_COLOR && !texture_layer_.get()) || |
| 664 type_ == LAYER_NINE_PATCH || (!delegate_ && !mailbox_.IsValid())) | 751 type_ == LAYER_NINE_PATCH || (!delegate_ && !mailbox_.IsValid())) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 if (!delegate_) | 798 if (!delegate_) |
| 712 return; | 799 return; |
| 713 delegate_ = NULL; | 800 delegate_ = NULL; |
| 714 for (size_t i = 0; i < children_.size(); ++i) | 801 for (size_t i = 0; i < children_.size(); ++i) |
| 715 children_[i]->SuppressPaint(); | 802 children_[i]->SuppressPaint(); |
| 716 } | 803 } |
| 717 | 804 |
| 718 void Layer::OnDeviceScaleFactorChanged(float device_scale_factor) { | 805 void Layer::OnDeviceScaleFactorChanged(float device_scale_factor) { |
| 719 if (device_scale_factor_ == device_scale_factor) | 806 if (device_scale_factor_ == device_scale_factor) |
| 720 return; | 807 return; |
| 721 if (animator_.get()) | 808 if (animator_) |
| 722 animator_->StopAnimatingProperty(LayerAnimationElement::TRANSFORM); | 809 animator_->StopAnimatingProperty(LayerAnimationElement::TRANSFORM); |
| 723 device_scale_factor_ = device_scale_factor; | 810 device_scale_factor_ = device_scale_factor; |
| 724 RecomputeDrawsContentAndUVRect(); | 811 RecomputeDrawsContentAndUVRect(); |
| 725 RecomputePosition(); | 812 RecomputePosition(); |
| 726 if (nine_patch_layer_) { | 813 if (nine_patch_layer_) { |
| 727 UpdateNinePatchLayerImage(nine_patch_layer_image_); | 814 UpdateNinePatchLayerImage(nine_patch_layer_image_); |
| 728 UpdateNinePatchLayerAperture(nine_patch_layer_aperture_); | 815 UpdateNinePatchLayerAperture(nine_patch_layer_aperture_); |
| 729 } | 816 } |
| 730 SchedulePaint(gfx::Rect(bounds_.size())); | 817 SchedulePaint(gfx::Rect(bounds_.size())); |
| 731 if (delegate_) | 818 if (delegate_) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 paint_region_.Clear(); | 875 paint_region_.Clear(); |
| 789 cc::DisplayItemListSettings settings; | 876 cc::DisplayItemListSettings settings; |
| 790 settings.use_cached_picture = false; | 877 settings.use_cached_picture = false; |
| 791 scoped_refptr<cc::DisplayItemList> display_list = | 878 scoped_refptr<cc::DisplayItemList> display_list = |
| 792 cc::DisplayItemList::Create(settings); | 879 cc::DisplayItemList::Create(settings); |
| 793 if (delegate_) { | 880 if (delegate_) { |
| 794 delegate_->OnPaintLayer( | 881 delegate_->OnPaintLayer( |
| 795 PaintContext(display_list.get(), device_scale_factor_, invalidation)); | 882 PaintContext(display_list.get(), device_scale_factor_, invalidation)); |
| 796 } | 883 } |
| 797 display_list->Finalize(); | 884 display_list->Finalize(); |
| 798 FOR_EACH_OBSERVER(LayerObserver, observer_list_, | 885 // TODO(domlaskowski): Move mirror invalidation to Layer::SchedulePaint. |
| 799 DidPaintLayer(this, invalidation)); | 886 for (const auto& mirror : mirrors_) |
| 887 mirror->dest()->SchedulePaint(invalidation); |
| 800 return display_list; | 888 return display_list; |
| 801 } | 889 } |
| 802 | 890 |
| 803 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } | 891 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } |
| 804 | 892 |
| 805 size_t Layer::GetApproximateUnsharedMemoryUsage() const { | 893 size_t Layer::GetApproximateUnsharedMemoryUsage() const { |
| 806 // Most of the "picture memory" is shared with the cc::DisplayItemList, so | 894 // Most of the "picture memory" is shared with the cc::DisplayItemList, so |
| 807 // there's nothing significant to report here. | 895 // there's nothing significant to report here. |
| 808 return 0; | 896 return 0; |
| 809 } | 897 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 | 997 |
| 910 if (was_move) { | 998 if (was_move) { |
| 911 // Don't schedule a draw if we're invisible. We'll schedule one | 999 // Don't schedule a draw if we're invisible. We'll schedule one |
| 912 // automatically when we get visible. | 1000 // automatically when we get visible. |
| 913 if (IsDrawn()) | 1001 if (IsDrawn()) |
| 914 ScheduleDraw(); | 1002 ScheduleDraw(); |
| 915 } else { | 1003 } else { |
| 916 // Always schedule a paint, even if we're invisible. | 1004 // Always schedule a paint, even if we're invisible. |
| 917 SchedulePaint(gfx::Rect(bounds.size())); | 1005 SchedulePaint(gfx::Rect(bounds.size())); |
| 918 } | 1006 } |
| 1007 |
| 1008 if (sync_bounds_) { |
| 1009 for (const auto& mirror : mirrors_) |
| 1010 mirror->dest()->SetBounds(bounds); |
| 1011 } |
| 919 } | 1012 } |
| 920 | 1013 |
| 921 void Layer::SetTransformFromAnimation(const gfx::Transform& transform) { | 1014 void Layer::SetTransformFromAnimation(const gfx::Transform& transform) { |
| 922 cc_layer_->SetTransform(transform); | 1015 cc_layer_->SetTransform(transform); |
| 923 } | 1016 } |
| 924 | 1017 |
| 925 void Layer::SetOpacityFromAnimation(float opacity) { | 1018 void Layer::SetOpacityFromAnimation(float opacity) { |
| 926 cc_layer_->SetOpacity(opacity); | 1019 cc_layer_->SetOpacity(opacity); |
| 927 ScheduleDraw(); | 1020 ScheduleDraw(); |
| 928 } | 1021 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 | 1162 |
| 1070 if (animator_) { | 1163 if (animator_) { |
| 1071 animator_->DetachLayerAndTimeline(compositor); | 1164 animator_->DetachLayerAndTimeline(compositor); |
| 1072 animator_->RemoveFromCollection(collection); | 1165 animator_->RemoveFromCollection(collection); |
| 1073 } | 1166 } |
| 1074 | 1167 |
| 1075 for (auto* child : children_) | 1168 for (auto* child : children_) |
| 1076 child->ResetCompositorForAnimatorsInTree(compositor); | 1169 child->ResetCompositorForAnimatorsInTree(compositor); |
| 1077 } | 1170 } |
| 1078 | 1171 |
| 1172 void Layer::OnMirrorDestroyed(LayerMirror* mirror) { |
| 1173 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), |
| 1174 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { |
| 1175 return mirror_ptr.get() == mirror; |
| 1176 }); |
| 1177 |
| 1178 DCHECK(it != mirrors_.end()); |
| 1179 mirrors_.erase(it); |
| 1180 } |
| 1181 |
| 1079 } // namespace ui | 1182 } // namespace ui |
| OLD | NEW |