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

Unified Diff: cc/output/filter_operation.cc

Issue 1980613003: cc: correctly fix edge-AA for filtered render surfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 years, 7 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 | « cc/output/filter_operation.h ('k') | cc/output/filter_operations.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/filter_operation.cc
diff --git a/cc/output/filter_operation.cc b/cc/output/filter_operation.cc
index 46e662986de30c3ec96d0bbfa245db6fed1083c4..a9c52a2e80144d50916f3f3bf851968f40bbe36f 100644
--- a/cc/output/filter_operation.cc
+++ b/cc/output/filter_operation.cc
@@ -315,26 +315,25 @@ void FilterOperation::AsValueInto(base::trace_event::TracedValue* value) const {
}
}
-static int SpreadForStdDeviation(float std_deviation) {
- // https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#feGaussianBlurElement
- // provides this approximation for evaluating a gaussian blur by a triple box
- // filter.
- float d = floorf(std_deviation * 3.f * sqrt(8.f * atan(1.f)) / 4.f + 0.5f);
- return static_cast<int>(ceilf(d * 3.f / 2.f));
+static SkVector MapStdDeviation(float std_deviation, const SkMatrix& matrix) {
enne (OOO) 2016/05/13 21:31:13 Can you explain this change to me?
Stephen White 2016/05/13 21:51:07 Basically, this syncs this function up with the Sk
+ SkVector sigma = SkVector::Make(std_deviation, std_deviation);
+ matrix.mapVectors(&sigma, 1);
+ return sigma * SkIntToScalar(3);
}
-gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect) const {
+gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect,
+ const SkMatrix& matrix) const {
switch (type_) {
case FilterOperation::BLUR: {
- int spread = SpreadForStdDeviation(amount());
+ SkVector spread = MapStdDeviation(amount(), matrix);
gfx::Rect result = rect;
- result.Inset(-spread, -spread, -spread, -spread);
+ result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y());
return result;
}
case FilterOperation::DROP_SHADOW: {
- int spread = SpreadForStdDeviation(amount());
+ SkVector spread = MapStdDeviation(amount(), matrix);
gfx::Rect result = rect;
- result.Inset(-spread, -spread, -spread, -spread);
+ result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y());
result += drop_shadow_offset().OffsetFromOrigin();
result.Union(rect);
return result;
@@ -344,7 +343,7 @@ gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect) const {
return rect;
SkIRect in_rect = gfx::RectToSkIRect(rect);
SkIRect out_rect = image_filter()->filterBounds(
- in_rect, SkMatrix::I(), SkImageFilter::kForward_MapDirection);
+ in_rect, matrix, SkImageFilter::kForward_MapDirection);
return gfx::SkIRectToRect(out_rect);
}
default:
« no previous file with comments | « cc/output/filter_operation.h ('k') | cc/output/filter_operations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698