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

Unified Diff: third_party/WebKit/Source/platform/graphics/skia/SkiaUtils.cpp

Issue 1536803003: Drop SkPathContainsPoint in favor of SkPath::contains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Less ugly. 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 | « third_party/WebKit/Source/platform/graphics/skia/SkiaUtils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/skia/SkiaUtils.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/skia/SkiaUtils.cpp b/third_party/WebKit/Source/platform/graphics/skia/SkiaUtils.cpp
index bc498815db8d3c4bdda30ce4d52ad6d086df586c..4a597d1809d13f3878d038856c55316e33949627 100644
--- a/third_party/WebKit/Source/platform/graphics/skia/SkiaUtils.cpp
+++ b/third_party/WebKit/Source/platform/graphics/skia/SkiaUtils.cpp
@@ -32,7 +32,6 @@
#include "platform/graphics/skia/SkiaUtils.h"
#include "platform/graphics/GraphicsContext.h"
-#include "third_party/skia/include/core/SkRegion.h"
#include "third_party/skia/include/effects/SkCornerPathEffect.h"
namespace blink {
@@ -169,53 +168,6 @@ WebBlendMode blendModeFromSkia(SkXfermode::Mode xferMode)
return WebBlendModeNormal;
}
-bool SkPathContainsPoint(const SkPath& originalPath, const FloatPoint& point, SkPath::FillType ft)
-{
- SkRect bounds = originalPath.getBounds();
-
- // We can immediately return false if the point is outside the bounding
- // rect. We don't use bounds.contains() here, since it would exclude
- // points on the right and bottom edges of the bounding rect, and we want
- // to include them.
- SkScalar fX = SkFloatToScalar(point.x());
- SkScalar fY = SkFloatToScalar(point.y());
- if (fX < bounds.fLeft || fX > bounds.fRight || fY < bounds.fTop || fY > bounds.fBottom)
- return false;
-
- // Scale the path to a large size before hit testing for two reasons:
- // 1) Skia has trouble with coordinates close to the max signed 16-bit values, so we scale larger paths down.
- // TODO: when Skia is patched to work properly with large values, this will not be necessary.
- // 2) Skia does not support analytic hit testing, so we scale paths up to do raster hit testing with subpixel accuracy.
- // 3) Scale the x/y axis separately so an extreme large/small scale factor on one axis won't
- // ruin the resolution of the other axis.
- SkScalar biggestCoordX = std::max(bounds.fRight, -bounds.fLeft);
- SkScalar biggestCoordY = std::max(bounds.fBottom, -bounds.fTop);
- if (SkScalarNearlyZero(biggestCoordX) || SkScalarNearlyZero(biggestCoordY))
- return false;
-
- biggestCoordX = std::max(biggestCoordX, std::fabs(fX) + 1);
- biggestCoordY = std::max(biggestCoordY, std::fabs(fY) + 1);
-
- const SkScalar kMaxCoordinate = SkIntToScalar(1 << 15);
- SkScalar scaleX = kMaxCoordinate / biggestCoordX;
- SkScalar scaleY = kMaxCoordinate / biggestCoordY;
-
- SkRegion rgn;
- SkRegion clip;
- SkMatrix m;
- SkPath scaledPath(originalPath);
-
- scaledPath.setFillType(ft);
- m.setScale(scaleX, scaleY);
- scaledPath.transform(m, 0);
-
- int x = static_cast<int>(floorf(0.5f + point.x() * scaleX));
- int y = static_cast<int>(floorf(0.5f + point.y() * scaleY));
- clip.setRect(x - 1, y - 1, x + 1, y + 1);
-
- return rgn.setPath(scaledPath, clip);
-}
-
SkMatrix affineTransformToSkMatrix(const AffineTransform& source)
{
SkMatrix result;
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/skia/SkiaUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698