From 9e1ec1a52985cce9db3a0d0e8d448b82a32e70cb Mon Sep 17 00:00:00 2001 From: "skia.committer@gmail.com" Date: Wed, 10 Jul 2013 07:00:58 +0000 Subject: [PATCH] Sanitizing source files in Housekeeper-Nightly git-svn-id: http://skia.googlecode.com/svn/trunk@9948 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/BitmapScaleBench.cpp | 20 ++++---- gm/arcofzorro.cpp | 2 +- gm/gradientDirtyLaundry.cpp | 2 +- gm/scalebitmap.cpp | 23 ++++----- include/core/SkBitmap.h | 14 +++--- samplecode/SamplePathUtils.cpp | 14 +++--- src/core/SkBitmapFilter.cpp | 62 +++++++++++------------ src/core/SkBitmapFilter.h | 32 ++++++------ src/core/SkBitmapProcState.h | 6 +-- src/core/SkGeometry.cpp | 2 +- src/opts/SkBitmapFilter_opts_SSE2.cpp | 72 +++++++++++++-------------- src/opts/SkBitmapFilter_opts_SSE2.h | 2 +- 12 files changed, 125 insertions(+), 126 deletions(-) diff --git a/bench/BitmapScaleBench.cpp b/bench/BitmapScaleBench.cpp index 45ea1b46ef..14d9fc0f34 100644 --- a/bench/BitmapScaleBench.cpp +++ b/bench/BitmapScaleBench.cpp @@ -28,10 +28,10 @@ public: } protected: - + SkBitmap fInputBitmap, fOutputBitmap; SkMatrix fMatrix; - + virtual const char* onGetName() { return fName.c_str(); } @@ -39,15 +39,15 @@ protected: int inputSize() const { return fInputSize; } - + int outputSize() const { return fOutputSize; } - + float scale() const { return float(outputSize())/inputSize(); } - + SkIPoint onGetSize() SK_OVERRIDE { return SkIPoint::Make( fOutputSize, fOutputSize ); } @@ -55,17 +55,17 @@ protected: void setName(const char * name) { fName.printf( "bitmap_scale_%s_%d_%d", name, fInputSize, fOutputSize ); } - + virtual void onPreDraw() { fInputBitmap.setConfig(SkBitmap::kARGB_8888_Config, fInputSize, fInputSize); fInputBitmap.allocPixels(); fInputBitmap.eraseColor(SK_ColorWHITE); fInputBitmap.setIsOpaque(true); - + fOutputBitmap.setConfig(SkBitmap::kARGB_8888_Config, fOutputSize, fOutputSize); fOutputBitmap.allocPixels(); fOutputBitmap.setIsOpaque(true); - + fMatrix.setScale( scale(), scale() ); } @@ -95,9 +95,9 @@ protected: virtual void doScaleImage() SK_OVERRIDE { SkCanvas canvas( fOutputBitmap ); SkPaint paint; - + paint.setFlags( SkPaint::kHighQualityFilterBitmap_Flag | SkPaint::kFilterBitmap_Flag ); - + canvas.drawBitmapMatrix( fInputBitmap, fMatrix, &paint ); } private: diff --git a/gm/arcofzorro.cpp b/gm/arcofzorro.cpp index 1e38130595..f1f1195bad 100644 --- a/gm/arcofzorro.cpp +++ b/gm/arcofzorro.cpp @@ -10,7 +10,7 @@ namespace skiagm { -// This GM draws a lot of arcs in a 'Z' shape. It particularly exercises +// This GM draws a lot of arcs in a 'Z' shape. It particularly exercises // the 'drawArc' code near a singularly of its processing (i.e., near the // edge of one of its underlying quads). class ArcOfZorroGM : public GM { diff --git a/gm/gradientDirtyLaundry.cpp b/gm/gradientDirtyLaundry.cpp index adf59b6e9c..ff6864ad7a 100644 --- a/gm/gradientDirtyLaundry.cpp +++ b/gm/gradientDirtyLaundry.cpp @@ -63,7 +63,7 @@ static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm, SkUnitMapper* mapper); static const GradMaker gGradMakers[] = { - MakeLinear, MakeRadial, MakeSweep, + MakeLinear, MakeRadial, MakeSweep, }; /////////////////////////////////////////////////////////////////////////////// diff --git a/gm/scalebitmap.cpp b/gm/scalebitmap.cpp index 5d08ba85de..c0150627ca 100644 --- a/gm/scalebitmap.cpp +++ b/gm/scalebitmap.cpp @@ -11,15 +11,15 @@ #include "SkStream.h" class ScaleBitmapGM : public skiagm::GM { - + public: - + ScaleBitmapGM(const char filename[], float scale) : fFilename(filename), fScale(scale) { this->setBGColor(0xFFDDDDDD); fName.printf("scalebitmap_%s_%f", filename, scale); - + SkString path(skiagm::GM::gResourcePath); path.append("/"); path.append(fFilename); @@ -43,15 +43,15 @@ public: } protected: - - + + SkBitmap fBM; SkString fName; SkString fFilename; int fSize; float fScale; - - + + virtual SkString onShortName() SK_OVERRIDE { return fName; } @@ -65,7 +65,7 @@ protected: dst.setConfig(SkBitmap::kARGB_8888_Config, fBM.width() * fScale, fBM.height() * fScale); dst.allocPixels(); fBM.scale(&dst); - + canvas->drawBitmap(dst, 0, 0); } @@ -75,7 +75,7 @@ private: class ScaleBitmapMipmapGM: public ScaleBitmapGM { SkMatrix fMatrix; - + public: ScaleBitmapMipmapGM(const char filename[], float scale) : INHERITED(filename, scale) @@ -87,12 +87,12 @@ public: protected: virtual void onDraw(SkCanvas *canvas) SK_OVERRIDE { SkPaint paint; - + paint.setFilterBitmap(true); canvas->drawBitmapMatrix(fBM, fMatrix, &paint); } private: - typedef ScaleBitmapGM INHERITED; + typedef ScaleBitmapGM INHERITED; }; ////////////////////////////////////////////////////////////////////////////// @@ -111,4 +111,3 @@ DEF_GM( return new ScaleBitmapMipmapGM("nature.jpg", 0.5f); ) DEF_GM( return new ScaleBitmapMipmapGM("nature.jpg", 0.25f); ) DEF_GM( return new ScaleBitmapMipmapGM("nature.jpg", 0.125f); ) DEF_GM( return new ScaleBitmapMipmapGM("nature.jpg", 0.0625f); ) - diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index d7f43274c6..d5277c6c80 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -538,7 +538,7 @@ public: by calling copyTo(). */ bool canCopyTo(Config newConfig) const; - + /** * DEPRECATED -- will be replaced with API on SkPaint */ @@ -702,17 +702,17 @@ private: int extractMipLevel(SkBitmap* dst, SkFixed sx, SkFixed sy); bool hasMipMap() const; void freeMipMap(); - + /** Make a scaled copy of this bitmap into the provided destination. * The caller is responsible for having set the width and height of the - * provided destination bitmap, and also having allocated its pixel + * provided destination bitmap, and also having allocated its pixel * memory. - * - * This function is temporary and for testing purposes only; it will - * likely move once it has been properly plumbed into the bitmap + * + * This function is temporary and for testing purposes only; it will + * likely move once it has been properly plumbed into the bitmap * shader infrastructure. */ - + void scale(SkBitmap *dst) const; friend struct SkBitmapProcState; diff --git a/samplecode/SamplePathUtils.cpp b/samplecode/SamplePathUtils.cpp index d1943630ea..09ab7738e9 100644 --- a/samplecode/SamplePathUtils.cpp +++ b/samplecode/SamplePathUtils.cpp @@ -25,10 +25,10 @@ static const BitsToPath gBitsToPath_fns[] = { static const uint8_t gBits[][16] = { { 0x18, 0x00, 0x3c, 0x00, 0x7e, 0x00, 0xdb, 0x00, 0xff, 0x00, 0x24, 0x00, 0x5a, 0x00, 0xa5, 0x00 }, - + { 0x20, 0x80, 0x91, 0x20, 0xbf, 0xa0, 0xee, 0xe0, 0xff, 0xe0, 0x7f, 0xc0, 0x20, 0x80, 0x40, 0x40 }, - + { 0x0f, 0x00, 0x7f, 0xe0, 0xff, 0xf0, 0xe6, 0x70, 0xff, 0xf0, 0x19, 0x80, 0x36, 0xc0, 0xc0, 0x30 } }; @@ -38,8 +38,8 @@ class SamplePathUtils : public SampleView { public: static const int fNumBits = 3; static const int fH = 8, fW = 12; - static const size_t fRowBytes = 2; - static const int fNumChars = fH * fRowBytes; + static const size_t fRowBytes = 2; + static const int fNumChars = fH * fRowBytes; SkPaint fBmpPaint; SkScalar fPhase; @@ -47,7 +47,7 @@ public: SamplePathUtils() { fBmpPaint.setAntiAlias(true); // Black paint for bitmap fBmpPaint.setStyle(SkPaint::kFill_Style); - + fPhase = 0.0f; // to animate the dashed path } @@ -77,13 +77,13 @@ protected: canvas->scale(10.0f, 10.0f); // scales up for (int i = 0; i < fNumBits; ++i) { - canvas->save(); + canvas->save(); for (size_t j = 0; j < SK_ARRAY_COUNT(gBitsToPath_fns); ++j) { SkPath path; gBitsToPath_fns[j](&path, (char*) &gBits[i], fW, fH, fRowBytes); //draw skPath and outline - canvas->drawPath(path, fBmpPaint); + canvas->drawPath(path, fBmpPaint); canvas->translate(1.5f * fW, 0); // translates past previous bitmap canvas->drawPath(path, outlinePaint); canvas->translate(1.5f * fW, 0); // translates past previous bitmap diff --git a/src/core/SkBitmapFilter.cpp b/src/core/SkBitmapFilter.cpp index 79c0a98781..441ad05df0 100644 --- a/src/core/SkBitmapFilter.cpp +++ b/src/core/SkBitmapFilter.cpp @@ -29,23 +29,23 @@ void highQualityFilter(const SkBitmapProcState& s, int x, int y, int sx = SkScalarFloorToInt(srcPt.fX); int sy = SkScalarFloorToInt(srcPt.fY); - + SkFixed weight = 0; SkFixed fr = 0, fg = 0, fb = 0, fa = 0; - + int y0 = SkClampMax(int(ceil(sy-s.getBitmapFilter()->width() + 0.5f)), maxY); int y1 = SkClampMax(int(floor(sy+s.getBitmapFilter()->width() + 0.5f)), maxY); int x0 = SkClampMax(int(ceil(sx-s.getBitmapFilter()->width() + 0.5f)), maxX); int x1 = SkClampMax(int(floor(sx+s.getBitmapFilter()->width() + 0.5f)), maxX); - + for (int src_y = y0; src_y <= y1; src_y++) { SkFixed yweight = s.getBitmapFilter()->lookup((srcPt.fY - src_y)); - + for (int src_x = x0; src_x <= x1 ; src_x++) { SkFixed xweight = s.getBitmapFilter()->lookup((srcPt.fX - src_x)); - + SkFixed combined_weight = SkFixedMul(xweight, yweight); - + SkPMColor c = *s.fBitmap->getAddr32(src_x, src_y); fr += combined_weight * SkGetPackedR32(c); fg += combined_weight * SkGetPackedG32(c); @@ -75,9 +75,9 @@ void highQualityFilter_ScaleOnly(const SkBitmapProcState &s, int x, int y, SkPMColor *SK_RESTRICT colors, int count) { const int maxX = s.fBitmap->width() - 1; const int maxY = s.fBitmap->height() - 1; - + SkPoint srcPt; - + s.fInvProc(*s.fInvMatrix, SkIntToScalar(x), SkIntToScalar(y), &srcPt); srcPt.fY -= SK_ScalarHalf; @@ -129,7 +129,7 @@ void highQualityFilter_ScaleOnly(const SkBitmapProcState &s, int x, int y, *colors++ = SkPackARGB32(a, r, g, b); x++; - } + } } SK_CONF_DECLARE(const char *, c_bitmapFilter, "bitmap.filter", "mitchell", "Which bitmap filter to use [mitchell, sinc, gaussian, triangle, box]"); @@ -148,7 +148,7 @@ static SkBitmapFilter *allocateBitmapFilter() { } else { SkASSERT(!!!"Unknown filter type"); } - + return NULL; } @@ -176,11 +176,11 @@ SkBitmapProcState::chooseBitmapFilterProc(const SkPaint& paint) { if (0xFF != paint.getAlpha()) { return NULL; } - + if (fInvType & (SkMatrix::kAffine_Mask | SkMatrix::kScale_Mask)) { fBitmapFilter = allocateBitmapFilter(); } - + if (fInvType & SkMatrix::kAffine_Mask) { return highQualityFilter; } else if (fInvType & SkMatrix::kScale_Mask) { @@ -213,10 +213,10 @@ static void upScaleHoriz(const SkBitmap *src, SkBitmap *dst, float scale, SkBitm float sx = x / scale - 0.5f; int x0 = SkClampMax(int(ceil(sx-filter->width() + 0.5f)), src->width()-1); int x1 = SkClampMax(int(floor(sx+filter->width() + 0.5f)), src->width()-1); - + SkFixed total_weight = 0; SkFixed fr = 0, fg = 0, fb = 0, fa = 0; - + for (int src_x = x0 ; src_x <= x1 ; src_x++) { SkFixed weight = filter->lookup(sx - src_x); SkPMColor c = *src->getAddr32(src_x,y); @@ -244,22 +244,22 @@ static void upScaleHoriz(const SkBitmap *src, SkBitmap *dst, float scale, SkBitm static void downScaleHoriz(const SkBitmap *src, SkBitmap *dst, float scale, SkBitmapFilter *filter) { SkFixed *sums = SkNEW_ARRAY(SkFixed, dst->width() * dst->height() * 4); SkFixed *weights = SkNEW_ARRAY(SkFixed, dst->width() * dst->height()); - + SkAutoTDeleteArray ada1(sums); SkAutoTDeleteArray ada2(weights); memset(sums, 0, dst->width() * dst->height() * sizeof(SkFixed) * 4); memset(weights, 0, dst->width() * dst->height() * sizeof(SkFixed)); - + for (int y = 0 ; y < src->height() ; y++) { for (int x = 0 ; x < src->width() ; x++) { // splat each source pixel into the destination image float dx = (x + 0.5f) * scale; int x0 = SkClampMax(int(ceil(dx-filter->width() + 0.5f)), dst->width()-1); int x1 = SkClampMax(int(floor(dx+filter->width() + 0.5f)), dst->width()-1); - + SkPMColor c = *src->getAddr32(x,y); - + for (int dst_x = x0 ; dst_x <= x1 ; dst_x++) { SkFixed weight = filter->lookup(dx - dst_x); sums[4*(y*dst->width() + dst_x) + 0] += weight*SkGetPackedR32(c); @@ -270,7 +270,7 @@ static void downScaleHoriz(const SkBitmap *src, SkBitmap *dst, float scale, SkBi } } } - + divideByWeights(sums, weights, dst); } @@ -280,10 +280,10 @@ static void upScaleVert(const SkBitmap *src, SkBitmap *dst, float scale, SkBitma float sy = y / scale - 0.5f; int y0 = SkClampMax(int(ceil(sy-filter->width() + 0.5f)), src->height()-1); int y1 = SkClampMax(int(floor(sy+filter->width() + 0.5f)), src->height()-1); - + SkFixed total_weight = 0; SkFixed fr = 0, fg = 0, fb = 0, fa = 0; - + for (int src_y = y0 ; src_y <= y1 ; src_y++) { SkFixed weight = filter->lookup(sy - src_y); SkPMColor c = *src->getAddr32(x,src_y); @@ -311,7 +311,7 @@ static void upScaleVert(const SkBitmap *src, SkBitmap *dst, float scale, SkBitma static void downScaleVert(const SkBitmap *src, SkBitmap *dst, float scale, SkBitmapFilter *filter) { SkFixed *sums = SkNEW_ARRAY(SkFixed, dst->width() * dst->height() * 4); SkFixed *weights = SkNEW_ARRAY(SkFixed, dst->width() * dst->height()); - + SkAutoTDeleteArray ada1(sums); SkAutoTDeleteArray ada2(weights); @@ -337,21 +337,21 @@ static void downScaleVert(const SkBitmap *src, SkBitmap *dst, float scale, SkBit } } } - + divideByWeights(sums, weights, dst); } void SkBitmap::scale(SkBitmap *dst) const { - + SkBitmap horiz_temp; - + horiz_temp.setConfig(SkBitmap::kARGB_8888_Config, dst->width(), height()); horiz_temp.allocPixels(); - + SkBitmapFilter *filter = allocateBitmapFilter(); - + float horiz_scale = float(dst->width()) / width(); - + if (horiz_scale == 1) { this->copyPixelsTo(horiz_temp.getPixels(), getSize()); } else if (horiz_scale > 1) { @@ -359,9 +359,9 @@ void SkBitmap::scale(SkBitmap *dst) const { } else if (horiz_scale < 1) { downScaleHoriz(this, &horiz_temp, horiz_scale, filter); } - + float vert_scale = float(dst->height()) / height(); - + if (vert_scale == 1) { horiz_temp.copyPixelsTo(dst->getPixels(), dst->getSize()); } else if (vert_scale > 1) { @@ -369,6 +369,6 @@ void SkBitmap::scale(SkBitmap *dst) const { } else if (vert_scale < 1) { downScaleVert(&horiz_temp, dst, vert_scale, filter); } - + SkDELETE(filter); } diff --git a/src/core/SkBitmapFilter.h b/src/core/SkBitmapFilter.h index bb14290452..c6fee2c008 100644 --- a/src/core/SkBitmapFilter.h +++ b/src/core/SkBitmapFilter.h @@ -24,23 +24,23 @@ class SkBitmapFilter { : fWidth(width), fInvWidth(1.f/width) { precomputed = false; } - + SkFixed lookup( float x ) const { if (!precomputed) { precomputeTable(); } int filter_idx = int(fabsf(x * invWidth() * SKBITMAP_FILTER_TABLE_SIZE)); return fFilterTable[ SkTMin(filter_idx, SKBITMAP_FILTER_TABLE_SIZE-1) ]; - } - + } + float lookupFloat( float x ) const { if (!precomputed) { precomputeTable(); } int filter_idx = int(fabsf(x * invWidth() * SKBITMAP_FILTER_TABLE_SIZE)); return fFilterTableFloat[ SkTMin(filter_idx, SKBITMAP_FILTER_TABLE_SIZE-1) ]; - } - + } + float width() const { return fWidth; } float invWidth() const { return fInvWidth; } virtual float evaluate(float x) const = 0; @@ -48,7 +48,7 @@ class SkBitmapFilter { protected: float fWidth; float fInvWidth; - + mutable bool precomputed; mutable SkFixed fFilterTable[SKBITMAP_FILTER_TABLE_SIZE]; mutable float fFilterTableFloat[SKBITMAP_FILTER_TABLE_SIZE]; @@ -69,9 +69,9 @@ class SkBitmapFilter { class SkMitchellFilter: public SkBitmapFilter { public: SkMitchellFilter(float b, float c, float width=2.0f) - : SkBitmapFilter(width), B(b), C(c) { + : SkBitmapFilter(width), B(b), C(c) { } - + virtual float evaluate(float x) const SK_OVERRIDE { x = fabsf(x); if (x > 2.f) { @@ -92,9 +92,9 @@ class SkMitchellFilter: public SkBitmapFilter { class SkGaussianFilter: public SkBitmapFilter { public: SkGaussianFilter(float a, float width=2.0f) - : SkBitmapFilter(width), alpha(a), expWidth(expf(-alpha * width * width)) { + : SkBitmapFilter(width), alpha(a), expWidth(expf(-alpha * width * width)) { } - + virtual float evaluate(float x) const SK_OVERRIDE { return SkTMax(0.f, float(expf(-alpha*x*x) - expWidth)); } @@ -105,9 +105,9 @@ class SkGaussianFilter: public SkBitmapFilter { class SkTriangleFilter: public SkBitmapFilter { public: SkTriangleFilter(float width=1) - : SkBitmapFilter(width) { + : SkBitmapFilter(width) { } - + virtual float evaluate(float x) const SK_OVERRIDE { return SkTMax(0.f, fWidth - fabsf(x)); } @@ -117,9 +117,9 @@ class SkTriangleFilter: public SkBitmapFilter { class SkBoxFilter: public SkBitmapFilter { public: SkBoxFilter(float width=0.5f) - : SkBitmapFilter(width) { + : SkBitmapFilter(width) { } - + virtual float evaluate(float x) const SK_OVERRIDE { return 1; } @@ -130,9 +130,9 @@ class SkBoxFilter: public SkBitmapFilter { class SkSincFilter: public SkBitmapFilter { public: SkSincFilter(float t, float width=3.f) - : SkBitmapFilter(width), tau(t) { + : SkBitmapFilter(width), tau(t) { } - + virtual float evaluate(float x) const SK_OVERRIDE { x = sk_float_abs(x * fInvWidth); if (x < 1e-5f) return 1.f; diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h index 69de2ca86a..1f75533410 100644 --- a/src/core/SkBitmapProcState.h +++ b/src/core/SkBitmapProcState.h @@ -114,7 +114,7 @@ struct SkBitmapProcState { // are ignored ShaderProc32 getShaderProc32() const { return fShaderProc32; } ShaderProc16 getShaderProc16() const { return fShaderProc16; } - + SkBitmapFilter* getBitmapFilter() const { return fBitmapFilter; } #ifdef SK_DEBUG @@ -142,7 +142,7 @@ private: MatrixProc chooseMatrixProc(bool trivial_matrix); bool chooseProcs(const SkMatrix& inv, const SkPaint&); ShaderProc32 chooseShaderProc32(); - + void buildFilterCoefficients(SkFixed dst[4], float t) const; SkBitmapFilter *fBitmapFilter; @@ -206,6 +206,6 @@ void highQualityFilter_ScaleOnly(const SkBitmapProcState &s, int x, int y, SkPMColor *SK_RESTRICT colors, int count); void highQualityFilter(const SkBitmapProcState &s, int x, int y, SkPMColor *SK_RESTRICT colors, int count); - + #endif diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp index a12f961948..cd6aa2e7fc 100644 --- a/src/core/SkGeometry.cpp +++ b/src/core/SkGeometry.cpp @@ -1208,7 +1208,7 @@ static SkScalar quad_solve(SkScalar a, SkScalar b, SkScalar c, SkScalar d) /* given a quad-curve and a point (x,y), chop the quad at that point and place the new off-curve point and endpoint into 'dest'. The new end point is used (rather than (x,y)) to compensate for numerical inaccuracies. - Should only return false if the computed pos is the start of the curve + Should only return false if the computed pos is the start of the curve (i.e. root == 0) */ static bool truncate_last_curve(const SkPoint quad[3], SkScalar x, SkScalar y, SkPoint* dest) diff --git a/src/opts/SkBitmapFilter_opts_SSE2.cpp b/src/opts/SkBitmapFilter_opts_SSE2.cpp index fe0a242f23..685ec77f49 100644 --- a/src/opts/SkBitmapFilter_opts_SSE2.cpp +++ b/src/opts/SkBitmapFilter_opts_SSE2.cpp @@ -29,7 +29,7 @@ static inline void print128i_16(__m128i value) { static inline void print128i_8(__m128i value) { unsigned char *v = (unsigned char*) &value; - printf("%.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u\n", + printf("%.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u %.3u\n", v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12], v[13], v[14], v[15] ); @@ -49,10 +49,10 @@ int debug_y = 255; void highQualityFilter_SSE2(const SkBitmapProcState& s, int x, int y, SkPMColor* SK_RESTRICT colors, int count) { - + const int maxX = s.fBitmap->width() - 1; const int maxY = s.fBitmap->height() - 1; - + while (count-- > 0) { SkPoint srcPt; s.fInvProc(*s.fInvMatrix, SkIntToScalar(x), @@ -62,33 +62,33 @@ void highQualityFilter_SSE2(const SkBitmapProcState& s, int x, int y, int sx = SkScalarFloorToInt(srcPt.fX); int sy = SkScalarFloorToInt(srcPt.fY); - + __m128 weight = _mm_setzero_ps(); __m128 accum = _mm_setzero_ps(); - + int y0 = SkTMax(0, int(ceil(sy-s.getBitmapFilter()->width() + 0.5f))); int y1 = SkTMin(maxY, int(floor(sy+s.getBitmapFilter()->width() + 0.5f))); int x0 = SkTMax(0, int(ceil(sx-s.getBitmapFilter()->width() + 0.5f))); int x1 = SkTMin(maxX, int(floor(sx+s.getBitmapFilter()->width() + 0.5f))); - + for (int src_y = y0; src_y <= y1; src_y++) { float yweight = s.getBitmapFilter()->lookupFloat( (srcPt.fY - src_y) ); - + for (int src_x = x0; src_x <= x1 ; src_x++) { float xweight = s.getBitmapFilter()->lookupFloat( (srcPt.fX - src_x) ); - + float combined_weight = xweight * yweight; SkPMColor color = *s.fBitmap->getAddr32(src_x, src_y); - + __m128i c = _mm_cvtsi32_si128( color ); c = _mm_unpacklo_epi8(c, _mm_setzero_si128()); c = _mm_unpacklo_epi16(c, _mm_setzero_si128()); - + __m128 cfloat = _mm_cvtepi32_ps( c ); - + __m128 weightVector = _mm_set1_ps(combined_weight); - + accum = _mm_add_ps(accum, _mm_mul_ps(cfloat, weightVector)); weight = _mm_add_ps( weight, weightVector ); } @@ -96,16 +96,16 @@ void highQualityFilter_SSE2(const SkBitmapProcState& s, int x, int y, accum = _mm_div_ps(accum, weight); accum = _mm_add_ps(accum, _mm_set1_ps(0.5f)); - + __m128i accumInt = _mm_cvtps_epi32( accum ); - + int localResult[4]; _mm_storeu_si128((__m128i *) (localResult), accumInt); int a = SkClampMax(localResult[0], 255); int r = SkClampMax(localResult[1], a); int g = SkClampMax(localResult[2], a); int b = SkClampMax(localResult[3], a); - + *colors++ = SkPackARGB32(a, r, g, b); x++; @@ -116,67 +116,67 @@ void highQualityFilter_ScaleOnly_SSE2(const SkBitmapProcState &s, int x, int y, SkPMColor *SK_RESTRICT colors, int count) { const int maxX = s.fBitmap->width() - 1; const int maxY = s.fBitmap->height() - 1; - + SkPoint srcPt; s.fInvProc(*s.fInvMatrix, SkIntToScalar(x), SkIntToScalar(y), &srcPt); srcPt.fY -= SK_ScalarHalf; int sy = SkScalarFloorToInt(srcPt.fY); - + int y0 = SkTMax(0, int(ceil(sy-s.getBitmapFilter()->width() + 0.5f))); int y1 = SkTMin(maxY, int(floor(sy+s.getBitmapFilter()->width() + 0.5f))); - + while (count-- > 0) { srcPt.fX -= SK_ScalarHalf; srcPt.fY -= SK_ScalarHalf; - + int sx = SkScalarFloorToInt(srcPt.fX); - + float weight = 0; __m128 accum = _mm_setzero_ps(); - + int x0 = SkTMax(0, int(ceil(sx-s.getBitmapFilter()->width() + 0.5f))); int x1 = SkTMin(maxX, int(floor(sx+s.getBitmapFilter()->width() + 0.5f))); - + for (int src_y = y0; src_y <= y1; src_y++) { float yweight = s.getBitmapFilter()->lookupFloat( (srcPt.fY - src_y) ); - + for (int src_x = x0; src_x <= x1 ; src_x++) { float xweight = s.getBitmapFilter()->lookupFloat( (srcPt.fX - src_x) ); - + float combined_weight = xweight * yweight; - + SkPMColor color = *s.fBitmap->getAddr32(src_x, src_y); - - __m128 c = _mm_set_ps((float)SkGetPackedB32(color), + + __m128 c = _mm_set_ps((float)SkGetPackedB32(color), (float)SkGetPackedG32(color), (float)SkGetPackedR32(color), (float)SkGetPackedA32(color)); - + __m128 weightVector = _mm_set1_ps(combined_weight); - + accum = _mm_add_ps(accum, _mm_mul_ps(c, weightVector)); weight += combined_weight; } } - + __m128 totalWeightVector = _mm_set1_ps(weight); accum = _mm_div_ps(accum, totalWeightVector); accum = _mm_add_ps(accum, _mm_set1_ps(0.5f)); - + float localResult[4]; _mm_storeu_ps(localResult, accum); int a = SkClampMax(int(localResult[0]), 255); int r = SkClampMax(int(localResult[1]), a); int g = SkClampMax(int(localResult[2]), a); int b = SkClampMax(int(localResult[3]), a); - + *colors++ = SkPackARGB32(a, r, g, b); - + x++; - + s.fInvProc(*s.fInvMatrix, SkIntToScalar(x), SkIntToScalar(y), &srcPt); - - } + + } } diff --git a/src/opts/SkBitmapFilter_opts_SSE2.h b/src/opts/SkBitmapFilter_opts_SSE2.h index 974b00896c..c511acc83a 100644 --- a/src/opts/SkBitmapFilter_opts_SSE2.h +++ b/src/opts/SkBitmapFilter_opts_SSE2.h @@ -16,5 +16,5 @@ void highQualityFilter_ScaleOnly_SSE2(const SkBitmapProcState &s, int x, int y, SkPMColor *SK_RESTRICT colors, int count); void highQualityFilter_SSE2(const SkBitmapProcState &s, int x, int y, SkPMColor *SK_RESTRICT colors, int count); - + #endif -- 2.34.1