Chromium Code Reviews| 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 } | 442 } |
| 439 return layer_grayscale(); | 443 return layer_grayscale(); |
| 440 } | 444 } |
| 441 | 445 |
| 442 void Layer::SetLayerInverted(bool inverted) { | 446 void Layer::SetLayerInverted(bool inverted) { |
| 443 layer_inverted_ = inverted; | 447 layer_inverted_ = inverted; |
| 444 SetLayerFilters(); | 448 SetLayerFilters(); |
| 445 } | 449 } |
| 446 | 450 |
| 447 void Layer::SetMaskLayer(Layer* layer_mask) { | 451 void Layer::SetMaskLayer(Layer* layer_mask) { |
| 448 if (layer_mask_ == layer_mask) | 452 if (layer_mask_ == layer_mask) |
|
danakj
2017/07/26 16:06:04
usually nice to keep DCHECKs at the top of the fun
malaykeshav
2017/07/26 18:34:45
This modification is not a part of this CL.
https
| |
| 449 return; | 453 return; |
| 450 // The provided mask should not have a layer mask itself. | 454 // The provided mask should not have a layer mask itself. |
| 451 DCHECK(!layer_mask || | 455 DCHECK(!layer_mask || |
| 452 (!layer_mask->layer_mask_layer() && layer_mask->children().empty() && | 456 (!layer_mask->layer_mask_layer() && layer_mask->children().empty() && |
| 453 !layer_mask->layer_mask_back_link_)); | 457 !layer_mask->layer_mask_back_link_)); |
| 454 DCHECK(!layer_mask_back_link_); | 458 DCHECK(!layer_mask_back_link_); |
| 455 // We need to de-reference the currently linked object so that no problem | 459 // We need to de-reference the currently linked object so that no problem |
| 456 // arises if the mask layer gets deleted before this object. | 460 // arises if the mask layer gets deleted before this object. |
| 457 if (layer_mask_) | 461 if (layer_mask_) |
| 458 layer_mask_->layer_mask_back_link_ = NULL; | 462 layer_mask_->layer_mask_back_link_ = NULL; |
| (...skipping 467 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 |