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

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

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