diff options
author | reed <reed@google.com> | 2016-03-18 12:42:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-18 12:42:26 -0700 |
commit | 58fc94e55fb52704f86aa6fde97719131a3c9ed4 (patch) | |
tree | dc8074968cc98643982438862d46acb7032a738a /include | |
parent | d2497f35ce9e9e70ab6c7acd82b212c80cb86d3a (diff) |
allow more options for shader blitprocs
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1810383004
Review URL: https://codereview.chromium.org/1810383004
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkShader.h | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/include/core/SkShader.h b/include/core/SkShader.h index 39ffd86f3a..c9c760d06d 100644 --- a/include/core/SkShader.h +++ b/include/core/SkShader.h @@ -142,18 +142,35 @@ public: virtual void shadeSpan4f(int x, int y, SkPM4f[], int count); + struct BlitState; + typedef void (*BlitBW)(BlitState*, + int x, int y, const SkPixmap&, int count); + typedef void (*BlitAA)(BlitState*, + int x, int y, const SkPixmap&, int count, const SkAlpha[]); + struct BlitState { + // inputs Context* fCtx; SkXfermode* fXfer; + + // outputs enum { N = 2 }; void* fStorage[N]; + BlitBW fBlitBW; + BlitAA fBlitAA; }; - typedef void (*BlitProc)(BlitState*, - int x, int y, const SkPixmap&, int count, const SkAlpha[]); - BlitProc chooseBlitProc(const SkImageInfo& info, BlitState* state) { - return this->onChooseBlitProc(info, state); + + // Returns true if one or more of the blitprocs are set in the BlitState + bool chooseBlitProcs(const SkImageInfo& info, BlitState* state) { + state->fBlitBW = nullptr; + state->fBlitAA = nullptr; + if (this->onChooseBlitProcs(info, state)) { + SkASSERT(state->fBlitBW || state->fBlitAA); + return true; + } + return false; } - + /** * The const void* ctx is only const because all the implementations are const. * This can be changed to non-const if a new shade proc needs to change the ctx. @@ -188,9 +205,7 @@ public: MatrixClass getInverseClass() const { return (MatrixClass)fTotalInverseClass; } const SkMatrix& getCTM() const { return fCTM; } - virtual BlitProc onChooseBlitProc(const SkImageInfo&, BlitState*) { - return nullptr; - } + virtual bool onChooseBlitProcs(const SkImageInfo&, BlitState*) { return false; } private: SkMatrix fCTM; |