diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-07-16 01:13:14 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-07-16 01:13:14 +0000 |
commit | 7a99eb1c63d4327d352af09ea59f039f014e4028 (patch) | |
tree | da87a81eb9d9b528603a20b24f4836305e751f76 /src | |
parent | b4f404ac4195e5b1f49e49c591bd69f98b246f9b (diff) |
add shaderprocs for all-in-one special blits (matrix+sampler)
git-svn-id: http://skia.googlecode.com/svn/trunk@267 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBitmapProcShader.cpp | 16 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 5 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.h | 13 |
3 files changed, 29 insertions, 5 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index 2302e0f048..b396c68d5c 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -134,9 +134,13 @@ bool SkBitmapProcShader::setContext(const SkBitmap& device, #define BUF_MAX 128 void SkBitmapProcShader::shadeSpan(int x, int y, SkPMColor dstC[], int count) { - uint32_t buffer[BUF_MAX]; + const SkBitmapProcState& state = fState; + if (state.fShaderProc32) { + state.fShaderProc32(state, x, y, dstC, count); + return; + } - const SkBitmapProcState& state = fState; + uint32_t buffer[BUF_MAX]; SkBitmapProcState::MatrixProc mproc = state.fMatrixProc; SkBitmapProcState::SampleProc32 sproc = state.fSampleProc32; int max = fState.fDoFilter ? (BUF_MAX >> 1) : BUF_MAX; @@ -162,9 +166,13 @@ void SkBitmapProcShader::shadeSpan(int x, int y, SkPMColor dstC[], int count) { } void SkBitmapProcShader::shadeSpan16(int x, int y, uint16_t dstC[], int count) { - uint32_t buffer[BUF_MAX]; + const SkBitmapProcState& state = fState; + if (state.fShaderProc16) { + state.fShaderProc16(state, x, y, dstC, count); + return; + } - const SkBitmapProcState& state = fState; + uint32_t buffer[BUF_MAX]; SkBitmapProcState::MatrixProc mproc = state.fMatrixProc; SkBitmapProcState::SampleProc16 sproc = state.fSampleProc16; int max = fState.fDoFilter ? (BUF_MAX >> 1) : BUF_MAX; diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 35585736dd..7dc9324770 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -345,6 +345,11 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { (inv.getType() > SkMatrix::kTranslate_Mask && valid_for_filtering(fBitmap->width() | fBitmap->height())); + fShaderProc32 = NULL; + fShaderProc16 = NULL; + fSampleProc32 = NULL; + fSampleProc16 = NULL; + fMatrixProc = this->chooseMatrixProc(); if (NULL == fMatrixProc) { return false; diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h index 561bdb7d90..553b952c46 100644 --- a/src/core/SkBitmapProcState.h +++ b/src/core/SkBitmapProcState.h @@ -24,6 +24,12 @@ class SkPaint; struct SkBitmapProcState { + typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y, + SkPMColor[], int count); + + typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y, + uint16_t[], int count); + typedef void (*MatrixProc)(const SkBitmapProcState&, uint32_t bitmapXY[], int count, @@ -40,7 +46,12 @@ struct SkBitmapProcState { uint16_t colors[]); typedef U16CPU (*FixedTileProc)(SkFixed); // returns 0..0xFFFF - + + // If a shader proc is present, then the corresponding matrix/sample procs + // are ignored + ShaderProc32 fShaderProc32; // chooseProcs + ShaderProc16 fShaderProc16; // chooseProcs + // These are used if the shaderproc is NULL MatrixProc fMatrixProc; // chooseProcs SampleProc32 fSampleProc32; // chooseProcs SampleProc16 fSampleProc16; // chooseProcs |