aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-12 18:21:37 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-12 18:21:37 +0000
commit9a4c746a1f0f91a5be2708a4c2018dfe14f62e48 (patch)
tree0675db0fa2c47d73da08c3c2ca0786ed899b1b11 /src/core
parent6222be84d7b446f806d03127636a1b81c8f41b5d (diff)
reland 5926 w/ fix in middle loop (thank you asserts)
git-svn-id: http://skia.googlecode.com/svn/trunk@5928 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBitmapProcState.cpp74
-rw-r--r--src/core/SkBitmapProcState.h1
2 files changed, 75 insertions, 0 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 3eccf47e70..dfcd0021b9 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -227,11 +227,85 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shaderproc);
}
+ if (NULL == fShaderProc32) {
+ fShaderProc32 = this->chooseShaderProc32();
+ }
+
// see if our platform has any accelerated overrides
this->platformProcs();
return true;
}
+static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s,
+ int x, int y,
+ SkPMColor* SK_RESTRICT colors,
+ int count) {
+ SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0);
+ SkASSERT(s.fInvKy == 0);
+ SkASSERT(count > 0 && colors != NULL);
+ SkASSERT(!s.fDoFilter);
+
+ const int maxX = s.fBitmap->width() - 1;
+ SkPMColor* row;
+ int ix;
+
+ {
+ SkPoint pt;
+ s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
+ SkIntToScalar(y) + SK_ScalarHalf, &pt);
+ const unsigned maxY = s.fBitmap->height() - 1;
+ int y = SkClampMax(SkScalarFloorToInt(pt.fY), maxY);
+ row = s.fBitmap->getAddr32(0, y);
+ ix = SkScalarFloorToInt(pt.fX);
+ }
+
+ // clamp to the left
+ if (ix < 0) {
+ int n = SkMin32(-ix, count);
+ sk_memset32(colors, row[0], n);
+ count -= n;
+ if (0 == count) {
+ return;
+ }
+ colors += n;
+ SkASSERT(-ix == n);
+ ix = 0;
+ }
+ // copy the middle
+ if (ix <= maxX) {
+ int n = SkMin32(maxX - ix + 1, count);
+ memcpy(colors, row + ix, n * sizeof(SkPMColor));
+ count -= n;
+ if (0 == count) {
+ return;
+ }
+ colors += n;
+ }
+ SkASSERT(count > 0);
+ // clamp to the right
+ sk_memset32(colors, row[maxX], count);
+}
+
+SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() {
+ if (fAlphaScale < 256) {
+ return NULL;
+ }
+ if (fInvType > SkMatrix::kTranslate_Mask) {
+ return NULL;
+ }
+ if (fDoFilter) {
+ return NULL;
+ }
+ if (SkBitmap::kARGB_8888_Config != fBitmap->config()) {
+ return NULL;
+ }
+
+ if (SkShader::kClamp_TileMode == fTileModeX && SkShader::kClamp_TileMode == fTileModeY) {
+ return Clamp_S32_D32_nofilter_trans_shaderproc;
+ }
+ return NULL;
+}
+
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_DEBUG
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index 4e3a1a1b3e..d9ac5c717b 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -137,6 +137,7 @@ private:
MatrixProc chooseMatrixProc(bool trivial_matrix);
bool chooseProcs(const SkMatrix& inv, const SkPaint&);
+ ShaderProc32 chooseShaderProc32();
#ifdef SK_DEBUG
static void DebugMatrixProc(const SkBitmapProcState&,