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

Unified Diff: cc/output/render_surface_filters.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: Remove call to SetAlphaShape from this cl 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
Index: cc/output/render_surface_filters.cc
diff --git a/cc/output/render_surface_filters.cc b/cc/output/render_surface_filters.cc
index 34e056dad521be2fa8a3260c904790aceee3fa3d..581a6717c6ec4a5824734cf6d6fe239cdb25a4e8 100644
--- a/cc/output/render_surface_filters.cc
+++ b/cc/output/render_surface_filters.cc
@@ -263,9 +263,22 @@ skia::RefPtr<SkImageFilter> RenderSurfaceFilters::BuildImageFilter(
break;
}
case FilterOperation::ALPHA_THRESHOLD: {
- skia::RefPtr<SkImageFilter> alpha_filter = skia::AdoptRef(
- SkAlphaThresholdFilter::Create(
- op.region(), op.amount(), op.outer_threshold()));
+ // 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.
+ SkPath path;
+ op.region().getBoundaryPath(&path);
+ SkMatrix scale;
+ scale.setScale(op.device_scale_factor(), op.device_scale_factor());
+ path.transform(scale);
+ SkRegion clip;
+ clip.setRect(0, 0, size.width(), size.height());
+ SkRegion scaled_shape;
+ scaled_shape.setPath(path, clip);
+
+ skia::RefPtr<SkImageFilter> alpha_filter =
+ skia::AdoptRef(SkAlphaThresholdFilter::Create(
danakj 2014/06/17 21:35:28 Can we just add the scale to this SkAlphaThreshold
garykac 2014/07/10 23:02:24 Done.
+ scaled_shape, op.amount(), op.outer_threshold()));
danakj 2014/06/17 21:42:01 If you put a transform on the ui::Layer with a sca
garykac 2014/07/10 23:02:24 I tested this and we need to pass the layer scale
if (image_filter.get()) {
image_filter = skia::AdoptRef(SkComposeImageFilter::Create(
alpha_filter.get(), image_filter.get()));

Powered by Google App Engine
This is Rietveld 408576698