diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-08-24 19:11:00 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-08-24 19:11:00 +0000 |
commit | 1cdcb5138f9b70aff547ea1c3af96f0c90b12f8f (patch) | |
tree | 8f8ac608b4fb0581f0cdd78ba6451d0dd10d0d27 | |
parent | 69255fb50381dd902c23d7d1baf3fe8b724c6ab1 (diff) |
fix warning in sampler
lock pixels when we extract alpha
disabling hinting when linear-text is set
git-svn-id: http://skia.googlecode.com/svn/trunk@333 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/core/SkBitmap.cpp | 13 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 12 | ||||
-rw-r--r-- | src/images/SkScaledBitmapSampler.cpp | 2 |
3 files changed, 24 insertions, 3 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index 9478faef52..0276897a20 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -1044,7 +1044,7 @@ SkFixed SkBitmap::ComputeMipLevel(SkFixed sx, SkFixed sy) { /////////////////////////////////////////////////////////////////////////////// -static void GetBitmapAlpha(const SkBitmap& src, uint8_t SK_RESTRICT alpha[], +static bool GetBitmapAlpha(const SkBitmap& src, uint8_t SK_RESTRICT alpha[], int alphaRowBytes) { SkASSERT(alpha != NULL); SkASSERT(alphaRowBytes >= src.width()); @@ -1054,6 +1054,16 @@ static void GetBitmapAlpha(const SkBitmap& src, uint8_t SK_RESTRICT alpha[], int h = src.height(); int rb = src.rowBytes(); + SkAutoLockPixels alp(src); + if (!src.readyToDraw()) { + // zero out the alpha buffer and return + while (--h >= 0) { + memset(alpha, 0, w); + alpha += alphaRowBytes; + } + return false; + } + if (SkBitmap::kA8_Config == config && !src.isOpaque()) { const uint8_t* s = src.getAddr8(0, 0); while (--h >= 0) { @@ -1096,6 +1106,7 @@ static void GetBitmapAlpha(const SkBitmap& src, uint8_t SK_RESTRICT alpha[], } else { // src is opaque, so just fill alpha[] with 0xFF memset(alpha, 0xFF, h * alphaRowBytes); } + return true; } #include "SkPaint.h" diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 76a2066c8c..2432ee3059 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -1142,6 +1142,16 @@ static SkMask::Format computeMaskFormat(const SkPaint& paint) return SkMask::kBW_Format; } +// if linear-text is on, then we force hinting to be off (since that's sort of +// the point of linear-text. +static SkPaint::Hinting computeHinting(const SkPaint& paint) { + SkPaint::Hinting h = paint.getHinting(); + if (paint.isLinearText()) { + h = SkPaint::kNo_Hinting; + } + return h; +} + void SkScalerContext::MakeRec(const SkPaint& paint, const SkMatrix* deviceMatrix, Rec* rec) { @@ -1207,7 +1217,7 @@ void SkScalerContext::MakeRec(const SkPaint& paint, rec->fSubpixelPositioning = paint.isSubpixelText(); rec->fMaskFormat = SkToU8(computeMaskFormat(paint)); rec->fFlags = SkToU8(flags); - rec->setHinting(paint.getHinting()); + rec->setHinting(computeHinting(paint)); /* Allow the fonthost to modify our rec before we use it as a key into the cache. This way if we're asking for something that they will ignore, diff --git a/src/images/SkScaledBitmapSampler.cpp b/src/images/SkScaledBitmapSampler.cpp index b51b4e7529..3ba38f7b16 100644 --- a/src/images/SkScaledBitmapSampler.cpp +++ b/src/images/SkScaledBitmapSampler.cpp @@ -192,7 +192,7 @@ static bool Sample_RGBA_D4444_D(void* SK_RESTRICT dstRow, // Index -#define A32_MASK_IN_PLACE (SK_A32_MASK << SK_A32_SHIFT) +#define A32_MASK_IN_PLACE (SkPMColor)(SK_A32_MASK << SK_A32_SHIFT) static bool Sample_Index_D8888(void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, |