Chromium Code Reviews| Index: ui/compositor/layer.cc |
| diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc |
| index ca3ff288ee293a43b49d39bee0f6f97311e6a0cd..9d6b57134fdc1d567c6d37c2b9497db8b5a04966 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(); |
| + raw_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 (raw_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. |
|
Wez
2014/06/08 00:55:53
Should we add an SkRegion scaler? Or pass SkPaths
garykac
2014/06/09 21:29:59
My first approach was to add a SkRegion scaler. Se
|
| + SkPath path; |
| + raw_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); |
|
Wez
2014/06/08 00:55:54
This won't work for |raw_alpha_shape_|s that are n
garykac
2014/06/09 21:29:59
It worked when I tried it (with 3 non-overlapping
|
| + } |
| +} |
| + |
| } // namespace ui |