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

Unified Diff: src/effects/SkMorphologyImageFilter.cpp

Issue 52603004: Implement SSE2-based implementations of the morphology filters (dilate & (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix typo in dilateY() Created 7 years, 2 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: src/effects/SkMorphologyImageFilter.cpp
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index df015cac7356fb2cf4d9b1c67612cf9c155fb7aa..1ab35483dd4e5d18fa137a88a50e44923f4d92c5 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -10,6 +10,7 @@
#include "SkColorPriv.h"
#include "SkFlattenableBuffers.h"
#include "SkRect.h"
+#include "SkMorphology_opts.h"
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrTexture.h"
@@ -74,16 +75,33 @@ static void erode(const SkPMColor* src, SkPMColor* dst,
static void erodeX(const SkBitmap& src, SkBitmap* dst, int radiusX, const SkIRect& bounds)
{
- erode(src.getAddr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0),
- radiusX, bounds.width(), bounds.height(),
- 1, src.rowBytesAsPixels(), 1, dst->rowBytesAsPixels());
+ if (SkMorphologyProc erodeXProc = SkErodeXGetPlatformProc()) {
reed1 2013/10/30 15:15:04 can we change either the platformproc or your erod
Stephen White 2013/10/30 19:47:17 Done.
+ (*erodeXProc)(src.getAddr32(bounds.left(), bounds.top()),
+ dst->getAddr32(0, 0), radiusX,
+ bounds.width(), bounds.height(),
+ src.rowBytesAsPixels(),
+ dst->rowBytesAsPixels());
+ } else {
+ erode(src.getAddr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0),
+ radiusX, bounds.width(), bounds.height(),
+ 1, src.rowBytesAsPixels(), 1, dst->rowBytesAsPixels());
+ }
}
static void erodeY(const SkBitmap& src, SkBitmap* dst, int radiusY, const SkIRect& bounds)
{
- erode(src.getAddr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0),
- radiusY, bounds.height(), bounds.width(),
- src.rowBytesAsPixels(), 1, dst->rowBytesAsPixels(), 1);
+ if (SkMorphologyProc erodeYProc = SkErodeYGetPlatformProc()) {
+ (*erodeYProc)(src.getAddr32(bounds.left(), bounds.top()),
+ dst->getAddr32(0, 0),
+ radiusY,
+ bounds.width(), bounds.height(),
+ src.rowBytesAsPixels(),
+ dst->rowBytesAsPixels());
+ } else {
+ erode(src.getAddr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0),
+ radiusY, bounds.height(), bounds.width(),
+ src.rowBytesAsPixels(), 1, dst->rowBytesAsPixels(), 1);
+ }
}
static void dilate(const SkPMColor* src, SkPMColor* dst,
@@ -122,16 +140,33 @@ static void dilate(const SkPMColor* src, SkPMColor* dst,
static void dilateX(const SkBitmap& src, SkBitmap* dst, int radiusX, const SkIRect& bounds)
{
- dilate(src.getAddr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0),
- radiusX, bounds.width(), bounds.height(),
- 1, src.rowBytesAsPixels(), 1, dst->rowBytesAsPixels());
+ if (SkMorphologyProc erodeYProc = SkDilateXGetPlatformProc()) {
+ (*erodeYProc)(src.getAddr32(bounds.left(), bounds.top()),
+ dst->getAddr32(0, 0), radiusX,
+ bounds.width(), bounds.height(),
+ src.rowBytesAsPixels(),
+ dst->rowBytesAsPixels());
+ } else {
+ dilate(src.getAddr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0),
+ radiusX, bounds.width(), bounds.height(),
+ 1, src.rowBytesAsPixels(), 1, dst->rowBytesAsPixels());
+ }
}
static void dilateY(const SkBitmap& src, SkBitmap* dst, int radiusY, const SkIRect& bounds)
{
- dilate(src.getAddr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0),
- radiusY, bounds.height(), bounds.width(),
- src.rowBytesAsPixels(), 1, dst->rowBytesAsPixels(), 1);
+ if (SkMorphologyProc dilateYProc = SkDilateYGetPlatformProc()) {
+ (*dilateYProc)(src.getAddr32(bounds.left(), bounds.top()),
+ dst->getAddr32(0, 0),
+ radiusY,
+ bounds.width(), bounds.height(),
+ src.rowBytesAsPixels(),
+ dst->rowBytesAsPixels());
+ } else {
+ dilate(src.getAddr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0),
+ radiusY, bounds.height(), bounds.width(),
+ src.rowBytesAsPixels(), 1, dst->rowBytesAsPixels(), 1);
+ }
}
bool SkErodeImageFilter::onFilterImage(Proxy* proxy,
« no previous file with comments | « gyp/opts.gyp ('k') | src/opts/SkMorphology_opts.h » ('j') | src/opts/SkMorphology_opts.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698