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