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

Unified Diff: src/gpu/batches/GrAADistanceFieldPathRenderer.cpp

Issue 1535173002: Rejigger distance field path rect calcs to avoid underflow (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment Created 5 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
index a8cc2e2181daa921370f3a965e23494626b835cb..fbc578e9ad9fcf682505adc9365ca58283ad8dbc 100644
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
@@ -342,9 +342,15 @@ private:
SkIRect devPathBounds;
scaledBounds.roundOut(&devPathBounds);
// pad to allow room for antialiasing
- devPathBounds.outset(SkScalarCeilToInt(kAntiAliasPad), SkScalarCeilToInt(kAntiAliasPad));
- // move origin to upper left corner
- devPathBounds.offsetTo(0,0);
+ const int intPad = SkScalarCeilToInt(kAntiAliasPad);
+ // pre-move origin (after outset, will be 0,0)
+ int width = devPathBounds.width();
+ int height = devPathBounds.height();
+ devPathBounds.fLeft = intPad;
+ devPathBounds.fTop = intPad;
+ devPathBounds.fRight = intPad + width;
+ devPathBounds.fBottom = intPad + height;
+ devPathBounds.outset(intPad, intPad);
joshualitt 2015/12/18 17:36:45 I guess this could still overflow if width or heig
jvanverth1 2015/12/18 17:48:42 We've already caught that case in canDraw() -- we
// draw path to bitmap
SkMatrix drawMatrix;
@@ -381,8 +387,8 @@ private:
// generate signed distance field
devPathBounds.outset(SK_DistanceFieldPad, SK_DistanceFieldPad);
- int width = devPathBounds.width();
- int height = devPathBounds.height();
+ width = devPathBounds.width();
+ height = devPathBounds.height();
// TODO We should really generate this directly into the plot somehow
SkAutoSMalloc<1024> dfStorage(width * height * sizeof(unsigned char));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698