Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Unified Diff: ui/compositor/layer.cc

Issue 317663005: Scale the ALPHA_THRESHOLD filter's region based on the device scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert surface filter changes Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/compositor/layer.h ('K') | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« ui/compositor/layer.h ('K') | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698