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

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: Review comments 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
« no previous file with comments | « 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..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
« no previous file with comments | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698