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 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 } | 327 } |
| 328 | 328 |
| 329 void Layer::SetBackgroundZoom(float zoom, int inset) { | 329 void Layer::SetBackgroundZoom(float zoom, int inset) { |
| 330 zoom_ = zoom; | 330 zoom_ = zoom; |
| 331 zoom_inset_ = inset; | 331 zoom_inset_ = inset; |
| 332 | 332 |
| 333 SetLayerBackgroundFilters(); | 333 SetLayerBackgroundFilters(); |
| 334 } | 334 } |
| 335 | 335 |
| 336 void Layer::SetAlphaShape(scoped_ptr<SkRegion> region) { | 336 void Layer::SetAlphaShape(scoped_ptr<SkRegion> region) { |
| 337 alpha_shape_ = region.Pass(); | 337 dips_alpha_shape_ = region.Pass(); |
| 338 RecomputeAlphaShape(); | |
| 338 | 339 |
| 339 SetLayerFilters(); | 340 SetLayerFilters(); |
| 340 } | 341 } |
| 341 | 342 |
| 342 void Layer::SetLayerFilters() { | 343 void Layer::SetLayerFilters() { |
| 343 cc::FilterOperations filters; | 344 cc::FilterOperations filters; |
| 344 if (layer_saturation_) { | 345 if (layer_saturation_) { |
| 345 filters.Append(cc::FilterOperation::CreateSaturateFilter( | 346 filters.Append(cc::FilterOperation::CreateSaturateFilter( |
| 346 layer_saturation_)); | 347 layer_saturation_)); |
| 347 } | 348 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 } | 615 } |
| 615 | 616 |
| 616 void Layer::OnDeviceScaleFactorChanged(float device_scale_factor) { | 617 void Layer::OnDeviceScaleFactorChanged(float device_scale_factor) { |
| 617 if (device_scale_factor_ == device_scale_factor) | 618 if (device_scale_factor_ == device_scale_factor) |
| 618 return; | 619 return; |
| 619 if (animator_.get()) | 620 if (animator_.get()) |
| 620 animator_->StopAnimatingProperty(LayerAnimationElement::TRANSFORM); | 621 animator_->StopAnimatingProperty(LayerAnimationElement::TRANSFORM); |
| 621 device_scale_factor_ = device_scale_factor; | 622 device_scale_factor_ = device_scale_factor; |
| 622 RecomputeDrawsContentAndUVRect(); | 623 RecomputeDrawsContentAndUVRect(); |
| 623 RecomputePosition(); | 624 RecomputePosition(); |
| 625 RecomputeAlphaShape(); | |
| 624 SchedulePaint(gfx::Rect(bounds_.size())); | 626 SchedulePaint(gfx::Rect(bounds_.size())); |
| 625 if (delegate_) | 627 if (delegate_) |
| 626 delegate_->OnDeviceScaleFactorChanged(device_scale_factor); | 628 delegate_->OnDeviceScaleFactorChanged(device_scale_factor); |
| 627 for (size_t i = 0; i < children_.size(); ++i) | 629 for (size_t i = 0; i < children_.size(); ++i) |
| 628 children_[i]->OnDeviceScaleFactorChanged(device_scale_factor); | 630 children_[i]->OnDeviceScaleFactorChanged(device_scale_factor); |
| 629 if (layer_mask_) | 631 if (layer_mask_) |
| 630 layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor); | 632 layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor); |
| 631 } | 633 } |
| 632 | 634 |
| 633 void Layer::RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) { | 635 void Layer::RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 923 size.SetToMin(frame_size_in_dip_); | 925 size.SetToMin(frame_size_in_dip_); |
| 924 delegated_renderer_layer_->SetDisplaySize(frame_size_in_dip_); | 926 delegated_renderer_layer_->SetDisplaySize(frame_size_in_dip_); |
| 925 } | 927 } |
| 926 cc_layer_->SetBounds(size); | 928 cc_layer_->SetBounds(size); |
| 927 } | 929 } |
| 928 | 930 |
| 929 void Layer::RecomputePosition() { | 931 void Layer::RecomputePosition() { |
| 930 cc_layer_->SetPosition(gfx::PointF(bounds_.x(), bounds_.y())); | 932 cc_layer_->SetPosition(gfx::PointF(bounds_.x(), bounds_.y())); |
| 931 } | 933 } |
| 932 | 934 |
| 935 void Layer::RecomputeAlphaShape() { | |
| 936 if (dips_alpha_shape_) { | |
| 937 // Scale the region by the device_scale_factor to properly handle | |
| 938 // HiDPI devices. Since there is no SkRegion scaling, we convert to | |
| 939 // a path, scale the path and then convert back to a SkRegion. | |
|
danakj
2014/06/09 22:21:39
:/ Storing 2 regions now, regions are costly, so I
garykac
2014/07/10 23:02:23
Acknowledged.
| |
| 940 SkPath path; | |
| 941 dips_alpha_shape_->getBoundaryPath(&path); | |
| 942 SkMatrix scale; | |
| 943 scale.setScale(device_scale_factor_, device_scale_factor_); | |
| 944 path.transform(scale); | |
| 945 SkRegion clip; | |
| 946 clip.setRect(0, 0, bounds_.width(), bounds_.height()); | |
| 947 | |
| 948 alpha_shape_->setPath(path, clip); | |
| 949 } | |
| 950 } | |
| 951 | |
| 933 } // namespace ui | 952 } // namespace ui |
| OLD | NEW |