| 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 22 matching lines...) Expand all Loading... |
| 33 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" |
| 34 #include "ui/gfx/geometry/dip_util.h" | 34 #include "ui/gfx/geometry/dip_util.h" |
| 35 #include "ui/gfx/geometry/point3_f.h" | 35 #include "ui/gfx/geometry/point3_f.h" |
| 36 #include "ui/gfx/geometry/point_conversions.h" | 36 #include "ui/gfx/geometry/point_conversions.h" |
| 37 #include "ui/gfx/geometry/size_conversions.h" | 37 #include "ui/gfx/geometry/size_conversions.h" |
| 38 #include "ui/gfx/interpolated_transform.h" | 38 #include "ui/gfx/interpolated_transform.h" |
| 39 | 39 |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 const ui::Layer* GetRoot(const ui::Layer* layer) { | 42 const ui::Layer* GetRoot(const ui::Layer* layer) { |
| 43 // Parent walk cannot be done on a layer that is being used as a mask. Get the |
| 44 // layer to which this layer is a mask of. |
| 45 if (layer->layer_mask_back_link()) |
| 46 layer = layer->layer_mask_back_link(); |
| 43 while (layer->parent()) | 47 while (layer->parent()) |
| 44 layer = layer->parent(); | 48 layer = layer->parent(); |
| 45 return layer; | 49 return layer; |
| 46 } | 50 } |
| 47 | 51 |
| 48 } // namespace | 52 } // namespace |
| 49 | 53 |
| 50 namespace ui { | 54 namespace ui { |
| 51 | 55 |
| 52 class Layer::LayerMirror : public LayerDelegate, LayerObserver { | 56 class Layer::LayerMirror : public LayerDelegate, LayerObserver { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 if (parent == this) | 312 if (parent == this) |
| 309 return true; | 313 return true; |
| 310 } | 314 } |
| 311 return false; | 315 return false; |
| 312 } | 316 } |
| 313 | 317 |
| 314 void Layer::SetAnimator(LayerAnimator* animator) { | 318 void Layer::SetAnimator(LayerAnimator* animator) { |
| 315 Compositor* compositor = GetCompositor(); | 319 Compositor* compositor = GetCompositor(); |
| 316 | 320 |
| 317 if (animator_) { | 321 if (animator_) { |
| 318 if (compositor) | 322 if (compositor && !layer_mask_back_link()) |
| 319 animator_->DetachLayerAndTimeline(compositor); | 323 animator_->DetachLayerAndTimeline(compositor); |
| 320 animator_->SetDelegate(nullptr); | 324 animator_->SetDelegate(nullptr); |
| 321 } | 325 } |
| 322 | 326 |
| 323 animator_ = animator; | 327 animator_ = animator; |
| 324 | 328 |
| 325 if (animator_) { | 329 if (animator_) { |
| 326 animator_->SetDelegate(this); | 330 animator_->SetDelegate(this); |
| 327 if (compositor) | 331 if (compositor && !layer_mask_back_link()) |
| 328 animator_->AttachLayerAndTimeline(compositor); | 332 animator_->AttachLayerAndTimeline(compositor); |
| 329 } | 333 } |
| 330 } | 334 } |
| 331 | 335 |
| 332 LayerAnimator* Layer::GetAnimator() { | 336 LayerAnimator* Layer::GetAnimator() { |
| 333 if (!animator_) | 337 if (!animator_) |
| 334 SetAnimator(LayerAnimator::CreateDefaultAnimator()); | 338 SetAnimator(LayerAnimator::CreateDefaultAnimator()); |
| 335 return animator_.get(); | 339 return animator_.get(); |
| 336 } | 340 } |
| 337 | 341 |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 | 930 |
| 927 scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList( | 931 scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList( |
| 928 ContentLayerClient::PaintingControlSetting painting_control) { | 932 ContentLayerClient::PaintingControlSetting painting_control) { |
| 929 TRACE_EVENT1("ui", "Layer::PaintContentsToDisplayList", "name", name_); | 933 TRACE_EVENT1("ui", "Layer::PaintContentsToDisplayList", "name", name_); |
| 930 gfx::Rect local_bounds(bounds().size()); | 934 gfx::Rect local_bounds(bounds().size()); |
| 931 gfx::Rect invalidation( | 935 gfx::Rect invalidation( |
| 932 gfx::IntersectRects(paint_region_.bounds(), local_bounds)); | 936 gfx::IntersectRects(paint_region_.bounds(), local_bounds)); |
| 933 paint_region_.Clear(); | 937 paint_region_.Clear(); |
| 934 auto display_list = make_scoped_refptr(new cc::DisplayItemList); | 938 auto display_list = make_scoped_refptr(new cc::DisplayItemList); |
| 935 if (delegate_) { | 939 if (delegate_) { |
| 936 delegate_->OnPaintLayer( | 940 delegate_->OnPaintLayer(PaintContext(display_list.get(), |
| 937 PaintContext(display_list.get(), device_scale_factor_, invalidation)); | 941 device_scale_factor_, invalidation, |
| 942 GetCompositor()->is_pixel_canvas())); |
| 938 } | 943 } |
| 939 display_list->Finalize(); | 944 display_list->Finalize(); |
| 940 // TODO(domlaskowski): Move mirror invalidation to Layer::SchedulePaint. | 945 // TODO(domlaskowski): Move mirror invalidation to Layer::SchedulePaint. |
| 941 for (const auto& mirror : mirrors_) | 946 for (const auto& mirror : mirrors_) |
| 942 mirror->dest()->SchedulePaint(invalidation); | 947 mirror->dest()->SchedulePaint(invalidation); |
| 943 return display_list; | 948 return display_list; |
| 944 } | 949 } |
| 945 | 950 |
| 946 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } | 951 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } |
| 947 | 952 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), | 1259 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), |
| 1255 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { | 1260 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { |
| 1256 return mirror_ptr.get() == mirror; | 1261 return mirror_ptr.get() == mirror; |
| 1257 }); | 1262 }); |
| 1258 | 1263 |
| 1259 DCHECK(it != mirrors_.end()); | 1264 DCHECK(it != mirrors_.end()); |
| 1260 mirrors_.erase(it); | 1265 mirrors_.erase(it); |
| 1261 } | 1266 } |
| 1262 | 1267 |
| 1263 } // namespace ui | 1268 } // namespace ui |
| OLD | NEW |