diff options
Diffstat (limited to 'src/opts')
-rw-r--r-- | src/opts/SkBitmapProcState_matrix_neon.h | 31 | ||||
-rw-r--r-- | src/opts/SkBitmapProcState_opts_SSE2.cpp | 36 | ||||
-rw-r--r-- | src/opts/SkBitmapProcState_opts_SSSE3.cpp | 12 | ||||
-rw-r--r-- | src/opts/SkBitmapProcState_opts_arm.cpp | 23 | ||||
-rw-r--r-- | src/opts/SkBitmapProcState_opts_mips_dsp.cpp | 20 |
5 files changed, 63 insertions, 59 deletions
diff --git a/src/opts/SkBitmapProcState_matrix_neon.h b/src/opts/SkBitmapProcState_matrix_neon.h index 72bf1bce33..fbb2a1e00b 100644 --- a/src/opts/SkBitmapProcState_matrix_neon.h +++ b/src/opts/SkBitmapProcState_matrix_neon.h @@ -1,7 +1,12 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ #include <arm_neon.h> - #define SCALE_NOFILTER_NAME MAKENAME(_nofilter_scale) #define SCALE_FILTER_NAME MAKENAME(_filter_scale) #define AFFINE_NOFILTER_NAME MAKENAME(_nofilter_affine) @@ -30,14 +35,14 @@ static void SCALE_NOFILTER_NAME(const SkBitmapProcState& s, PREAMBLE(s); // we store y, x, x, x, x, x - const unsigned maxX = s.fBitmap->width() - 1; + const unsigned maxX = s.fPixmap.width() - 1; SkFractionalInt fx; { SkPoint pt; s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf, &pt); fx = SkScalarToFractionalInt(pt.fY); - const unsigned maxY = s.fBitmap->height() - 1; + const unsigned maxY = s.fPixmap.height() - 1; *xy++ = TILEY_PROCF(SkFractionalIntToFixed(fx), maxY); fx = SkScalarToFractionalInt(pt.fX); } @@ -122,8 +127,8 @@ static void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s, SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY); SkFractionalInt dx = s.fInvSxFractionalInt; SkFractionalInt dy = s.fInvKyFractionalInt; - int maxX = s.fBitmap->width() - 1; - int maxY = s.fBitmap->height() - 1; + int maxX = s.fPixmap.width() - 1; + int maxY = s.fPixmap.height() - 1; if (count >= 8) { SkFractionalInt dx4 = dx * 4; @@ -187,8 +192,8 @@ static void PERSP_NOFILTER_NAME(const SkBitmapProcState& s, PREAMBLE(s); // max{X,Y} are int here, but later shown/assumed to fit in 16 bits - int maxX = s.fBitmap->width() - 1; - int maxY = s.fBitmap->height() - 1; + int maxX = s.fPixmap.width() - 1; + int maxY = s.fPixmap.height() - 1; SkPerspIter iter(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, @@ -293,7 +298,7 @@ static void SCALE_FILTER_NAME(const SkBitmapProcState& s, PREAMBLE(s); - const unsigned maxX = s.fBitmap->width() - 1; + const unsigned maxX = s.fPixmap.width() - 1; const SkFixed one = s.fFilterOneX; const SkFractionalInt dx = s.fInvSxFractionalInt; SkFractionalInt fx; @@ -303,7 +308,7 @@ static void SCALE_FILTER_NAME(const SkBitmapProcState& s, s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf, &pt); const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); - const unsigned maxY = s.fBitmap->height() - 1; + const unsigned maxY = s.fPixmap.height() - 1; // compute our two Y values up front *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y); // now initialize fx @@ -369,8 +374,8 @@ static void AFFINE_FILTER_NAME(const SkBitmapProcState& s, SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); SkFixed dx = s.fInvSx; SkFixed dy = s.fInvKy; - unsigned maxX = s.fBitmap->width() - 1; - unsigned maxY = s.fBitmap->height() - 1; + unsigned maxX = s.fPixmap.width() - 1; + unsigned maxY = s.fPixmap.height() - 1; if (count >= 4) { int32x4_t wide_fy, wide_fx; @@ -420,8 +425,8 @@ static void PERSP_FILTER_NAME(const SkBitmapProcState& s, SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); PREAMBLE(s); - unsigned maxX = s.fBitmap->width() - 1; - unsigned maxY = s.fBitmap->height() - 1; + unsigned maxX = s.fPixmap.width() - 1; + unsigned maxY = s.fPixmap.height() - 1; SkFixed oneX = s.fFilterOneX; SkFixed oneY = s.fFilterOneY; diff --git a/src/opts/SkBitmapProcState_opts_SSE2.cpp b/src/opts/SkBitmapProcState_opts_SSE2.cpp index 659caf25b8..f55a09938c 100644 --- a/src/opts/SkBitmapProcState_opts_SSE2.cpp +++ b/src/opts/SkBitmapProcState_opts_SSE2.cpp @@ -16,11 +16,11 @@ void S32_opaque_D32_filter_DX_SSE2(const SkBitmapProcState& s, int count, uint32_t* colors) { SkASSERT(count > 0 && colors != NULL); SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); - SkASSERT(kN32_SkColorType == s.fBitmap->colorType()); + SkASSERT(kN32_SkColorType == s.fPixmap.colorType()); SkASSERT(s.fAlphaScale == 256); - const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); - size_t rb = s.fBitmap->rowBytes(); + const char* srcAddr = static_cast<const char*>(s.fPixmap.addr()); + size_t rb = s.fPixmap.rowBytes(); uint32_t XY = *xy++; unsigned y0 = XY >> 14; const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb); @@ -122,11 +122,11 @@ void S32_alpha_D32_filter_DX_SSE2(const SkBitmapProcState& s, int count, uint32_t* colors) { SkASSERT(count > 0 && colors != NULL); SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); - SkASSERT(kN32_SkColorType == s.fBitmap->colorType()); + SkASSERT(kN32_SkColorType == s.fPixmap.colorType()); SkASSERT(s.fAlphaScale < 256); - const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); - size_t rb = s.fBitmap->rowBytes(); + const char* srcAddr = static_cast<const char*>(s.fPixmap.addr()); + size_t rb = s.fPixmap.rowBytes(); uint32_t XY = *xy++; unsigned y0 = XY >> 14; const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb); @@ -249,7 +249,7 @@ void ClampX_ClampY_filter_scale_SSE2(const SkBitmapProcState& s, uint32_t xy[], SkMatrix::kScale_Mask)) == 0); SkASSERT(s.fInvKy == 0); - const unsigned maxX = s.fBitmap->width() - 1; + const unsigned maxX = s.fPixmap.width() - 1; const SkFixed one = s.fFilterOneX; const SkFixed dx = s.fInvSx; SkFixed fx; @@ -258,7 +258,7 @@ void ClampX_ClampY_filter_scale_SSE2(const SkBitmapProcState& s, uint32_t xy[], s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf, &pt); const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); - const unsigned maxY = s.fBitmap->height() - 1; + const unsigned maxY = s.fPixmap.height() - 1; // compute our two Y values up front *xy++ = ClampX_ClampY_pack_filter(fy, maxY, s.fFilterOneY); // now initialize fx @@ -373,13 +373,13 @@ void ClampX_ClampY_nofilter_scale_SSE2(const SkBitmapProcState& s, SkMatrix::kScale_Mask)) == 0); // we store y, x, x, x, x, x - const unsigned maxX = s.fBitmap->width() - 1; + const unsigned maxX = s.fPixmap.width() - 1; SkFixed fx; SkPoint pt; s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf, &pt); fx = SkScalarToFixed(pt.fY); - const unsigned maxY = s.fBitmap->height() - 1; + const unsigned maxY = s.fPixmap.height() - 1; *xy++ = SkClampMax(fx >> 16, maxY); fx = SkScalarToFixed(pt.fX); @@ -500,8 +500,8 @@ void ClampX_ClampY_filter_affine_SSE2(const SkBitmapProcState& s, SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); SkFixed dx = s.fInvSx; SkFixed dy = s.fInvKy; - unsigned maxX = s.fBitmap->width() - 1; - unsigned maxY = s.fBitmap->height() - 1; + unsigned maxX = s.fPixmap.width() - 1; + unsigned maxY = s.fPixmap.height() - 1; if (count >= 2 && (maxX <= 0xFFFF)) { SkFixed dx2 = dx + dx; @@ -574,8 +574,8 @@ void ClampX_ClampY_nofilter_affine_SSE2(const SkBitmapProcState& s, SkFixed fy = SkScalarToFixed(srcPt.fY); SkFixed dx = s.fInvSx; SkFixed dy = s.fInvKy; - int maxX = s.fBitmap->width() - 1; - int maxY = s.fBitmap->height() - 1; + int maxX = s.fPixmap.width() - 1; + int maxY = s.fPixmap.height() - 1; if (count >= 4 && (maxX <= 0xFFFF)) { while (((size_t)xy & 0x0F) != 0) { @@ -642,12 +642,12 @@ void S32_D16_filter_DX_SSE2(const SkBitmapProcState& s, int count, uint16_t* colors) { SkASSERT(count > 0 && colors != NULL); SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); - SkASSERT(kN32_SkColorType == s.fBitmap->colorType()); - SkASSERT(s.fBitmap->isOpaque()); + SkASSERT(kN32_SkColorType == s.fPixmap.colorType()); + SkASSERT(s.fPixmap.isOpaque()); SkPMColor dstColor; - const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); - size_t rb = s.fBitmap->rowBytes(); + const char* srcAddr = static_cast<const char*>(s.fPixmap.addr()); + size_t rb = s.fPixmap.rowBytes(); uint32_t XY = *xy++; unsigned y0 = XY >> 14; const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb); diff --git a/src/opts/SkBitmapProcState_opts_SSSE3.cpp b/src/opts/SkBitmapProcState_opts_SSSE3.cpp index bfcd7caa72..15a9664c08 100644 --- a/src/opts/SkBitmapProcState_opts_SSSE3.cpp +++ b/src/opts/SkBitmapProcState_opts_SSSE3.cpp @@ -395,7 +395,7 @@ void S32_generic_D32_filter_DX_SSSE3(const SkBitmapProcState& s, int count, uint32_t* colors) { SkASSERT(count > 0 && colors != NULL); SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); - SkASSERT(kN32_SkColorType == s.fBitmap->colorType()); + SkASSERT(kN32_SkColorType == s.fPixmap.colorType()); if (has_alpha) { SkASSERT(s.fAlphaScale < 256); } else { @@ -403,8 +403,8 @@ void S32_generic_D32_filter_DX_SSSE3(const SkBitmapProcState& s, } const uint8_t* src_addr = - static_cast<const uint8_t*>(s.fBitmap->getPixels()); - const size_t rb = s.fBitmap->rowBytes(); + static_cast<const uint8_t*>(s.fPixmap.addr()); + const size_t rb = s.fPixmap.rowBytes(); const uint32_t XY = *xy++; const unsigned y0 = XY >> 14; const uint32_t* row0 = @@ -587,7 +587,7 @@ void S32_generic_D32_filter_DXDY_SSSE3(const SkBitmapProcState& s, int count, uint32_t* colors) { SkASSERT(count > 0 && colors != NULL); SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); - SkASSERT(kN32_SkColorType == s.fBitmap->colorType()); + SkASSERT(kN32_SkColorType == s.fPixmap.colorType()); if (has_alpha) { SkASSERT(s.fAlphaScale < 256); } else { @@ -595,8 +595,8 @@ void S32_generic_D32_filter_DXDY_SSSE3(const SkBitmapProcState& s, } const uint8_t* src_addr = - static_cast<const uint8_t*>(s.fBitmap->getPixels()); - const size_t rb = s.fBitmap->rowBytes(); + static_cast<const uint8_t*>(s.fPixmap.addr()); + const size_t rb = s.fPixmap.rowBytes(); // vector constants const __m128i mask_dist_select = _mm_set_epi8(12, 12, 12, 12, diff --git a/src/opts/SkBitmapProcState_opts_arm.cpp b/src/opts/SkBitmapProcState_opts_arm.cpp index e6799dea19..bd67ba4fd7 100644 --- a/src/opts/SkBitmapProcState_opts_arm.cpp +++ b/src/opts/SkBitmapProcState_opts_arm.cpp @@ -30,18 +30,17 @@ void SI8_D16_nofilter_DX_arm(const SkBitmapProcState& s, SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); - const uint16_t* SK_RESTRICT table = s.fBitmap->getColorTable()->read16BitCache(); - const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels(); + const uint16_t* SK_RESTRICT table = s.fPixmap.ctable()->read16BitCache(); + const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr(); // buffer is y32, x16, x16, x16, x16, x16 // bump srcAddr to the proper row, since we're told Y never changes - SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height()); - srcAddr = (const uint8_t*)((const char*)srcAddr + - xy[0] * s.fBitmap->rowBytes()); + SkASSERT((unsigned)xy[0] < (unsigned)s.fPixmap.height()); + srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes()); uint8_t src; - if (1 == s.fBitmap->width()) { + if (1 == s.fPixmap.width()) { src = srcAddr[0]; uint16_t dstValue = table[src]; sk_memset16(colors, dstValue, count); @@ -119,15 +118,15 @@ void SI8_opaque_D32_nofilter_DX_arm(const SkBitmapProcState& s, SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); - const SkPMColor* SK_RESTRICT table = s.fBitmap->getColorTable()->readColors(); - const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels(); + const SkPMColor* SK_RESTRICT table = s.fPixmap.ctable()->readColors(); + const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr(); // buffer is y32, x16, x16, x16, x16, x16 // bump srcAddr to the proper row, since we're told Y never changes - SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height()); - srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fBitmap->rowBytes()); + SkASSERT((unsigned)xy[0] < (unsigned)s.fPixmap.height()); + srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes()); - if (1 == s.fBitmap->width()) { + if (1 == s.fPixmap.width()) { uint8_t src = srcAddr[0]; SkPMColor dstValue = table[src]; sk_memset32(colors, dstValue, count); @@ -199,7 +198,7 @@ void SkBitmapProcState::platformProcs() { justDx = true; } - switch (fBitmap->colorType()) { + switch (fPixmap.colorType()) { case kIndex_8_SkColorType: if (justDx && kNone_SkFilterQuality == fFilterLevel) { #if 0 /* crashing on android device */ diff --git a/src/opts/SkBitmapProcState_opts_mips_dsp.cpp b/src/opts/SkBitmapProcState_opts_mips_dsp.cpp index 049519a613..6b8195c660 100644 --- a/src/opts/SkBitmapProcState_opts_mips_dsp.cpp +++ b/src/opts/SkBitmapProcState_opts_mips_dsp.cpp @@ -18,13 +18,13 @@ static void SI8_D16_nofilter_DX_mips_dsp(const SkBitmapProcState& s, SkASSERT(count > 0 && colors != NULL); SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); - const uint16_t* SK_RESTRICT table = s.fBitmap->getColorTable()->read16BitCache(); - const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels(); - SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height()); - srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fBitmap->rowBytes()); + const uint16_t* SK_RESTRICT table = s.fPixmap.ctable()->read16BitCache(); + const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr(); + SkASSERT((unsigned)xy[0] < (unsigned)s.fPixmap.height()); + srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes()); uint8_t src; - if (1 == s.fBitmap->width()) { + if (1 == s.fPixmap.width()) { src = srcAddr[0]; uint16_t dstValue = table[src]; sk_memset16(colors, dstValue, count); @@ -150,11 +150,11 @@ static void SI8_opaque_D32_nofilter_DX_mips_dsp(const SkBitmapProcState& s, SkASSERT(count > 0 && colors != NULL); SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); - const SkPMColor* SK_RESTRICT table = s.fBitmap->getColorTable()->readColors(); - const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels(); - srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fBitmap->rowBytes()); + const SkPMColor* SK_RESTRICT table = s.fPixmap.ctable()->readColors(); + const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr(); + srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes()); - if (1 == s.fBitmap->width()) { + if (1 == s.fPixmap.width()) { uint8_t src = srcAddr[0]; SkPMColor dstValue = table[src]; sk_memset32(colors, dstValue, count); @@ -376,7 +376,7 @@ void SkBitmapProcState::platformProcs() { justDx = true; } - switch (fBitmap->colorType()) { + switch (fPixmap.colorType()) { case kIndex_8_SkColorType: if (justDx && kNone_SkFilterQuality == fFilterLevel) { fSampleProc16 = SI8_D16_nofilter_DX_mips_dsp; |