diff options
author | 2009-06-12 21:27:03 +0000 | |
---|---|---|
committer | 2009-06-12 21:27:03 +0000 | |
commit | 5119bdb952025a30f115b9c6a187173956e55097 (patch) | |
tree | 46636bc7cdf8f0142125f2b026c8fa3c5f68b22d /src/core/SkBitmapProcShader.cpp | |
parent | b2c5f2d2606930c4551d31a31921d87e0dd37cee (diff) |
add shader flag kConstInY_Flag
this signals blitters that the shader will return the same results for a given
x value, independent of y. Useful inside blitRect(), where it can cache the
first call to shadeSpan() and reuse it on all subsequent scans. Works with
(non-rotated) linear-gradients, and Nx1 bitmaps.
git-svn-id: http://skia.googlecode.com/svn/trunk@214 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkBitmapProcShader.cpp')
-rw-r--r-- | src/core/SkBitmapProcShader.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index 8ba57c4ae3..2302e0f048 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -67,6 +67,11 @@ void SkBitmapProcShader::flatten(SkFlattenableWriteBuffer& buffer) { buffer.write8(fState.fTileModeY); } +static bool only_scale_and_translate(const SkMatrix& matrix) { + unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask; + return (matrix.getType() & ~mask) == 0; +} + bool SkBitmapProcShader::setContext(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix) { @@ -117,6 +122,12 @@ bool SkBitmapProcShader::setContext(const SkBitmap& device, default: break; } + + // if we're only 1-pixel heigh, and we don't rotate, then we can claim this + if (1 == fState.fBitmap->height() && + only_scale_and_translate(this->getTotalInverse())) { + fFlags |= kConstInY_Flag; + } return true; } |