Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: ui/compositor/layer.cc

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

Powered by Google App Engine
This is Rietveld 408576698