Chromium Code Reviews| Index: ui/compositor/layer.cc |
| diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc |
| index ca3ff288ee293a43b49d39bee0f6f97311e6a0cd..d3bc3a4576f8227b7d34b33ae18b48459cadd9af 100644 |
| --- a/ui/compositor/layer.cc |
| +++ b/ui/compositor/layer.cc |
| @@ -334,7 +334,8 @@ void Layer::SetBackgroundZoom(float zoom, int inset) { |
| } |
| void Layer::SetAlphaShape(scoped_ptr<SkRegion> region) { |
| - alpha_shape_ = region.Pass(); |
| + dips_alpha_shape_ = region.Pass(); |
| + RecomputeAlphaShape(); |
| SetLayerFilters(); |
| } |
| @@ -621,6 +622,7 @@ void Layer::OnDeviceScaleFactorChanged(float device_scale_factor) { |
| device_scale_factor_ = device_scale_factor; |
| RecomputeDrawsContentAndUVRect(); |
| RecomputePosition(); |
| + RecomputeAlphaShape(); |
| SchedulePaint(gfx::Rect(bounds_.size())); |
| if (delegate_) |
| delegate_->OnDeviceScaleFactorChanged(device_scale_factor); |
| @@ -930,4 +932,21 @@ void Layer::RecomputePosition() { |
| cc_layer_->SetPosition(gfx::PointF(bounds_.x(), bounds_.y())); |
| } |
| +void Layer::RecomputeAlphaShape() { |
| + if (dips_alpha_shape_) { |
| + // Scale the region by the device_scale_factor to properly handle |
| + // HiDPI devices. Since there is no SkRegion scaling, we convert to |
| + // 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.
|
| + SkPath path; |
| + dips_alpha_shape_->getBoundaryPath(&path); |
| + SkMatrix scale; |
| + scale.setScale(device_scale_factor_, device_scale_factor_); |
| + path.transform(scale); |
| + SkRegion clip; |
| + clip.setRect(0, 0, bounds_.width(), bounds_.height()); |
| + |
| + alpha_shape_->setPath(path, clip); |
| + } |
| +} |
| + |
| } // namespace ui |