2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#ifndef SkComposeShader_DEFINED
|
|
|
|
#define SkComposeShader_DEFINED
|
|
|
|
|
|
|
|
#include "SkShader.h"
|
|
|
|
|
|
|
|
class SkXfermode;
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/** \class SkComposeShader
|
2014-04-14 15:02:19 +00:00
|
|
|
This subclass of shader returns the composition of two other shaders, combined by
|
2008-12-17 15:59:43 +00:00
|
|
|
a xfermode.
|
|
|
|
*/
|
2011-05-20 22:16:08 +00:00
|
|
|
class SK_API SkComposeShader : public SkShader {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
|
|
|
/** Create a new compose shader, given shaders A, B, and a combining xfermode mode.
|
|
|
|
When the xfermode is called, it will be given the result from shader A as its
|
2014-04-14 15:02:19 +00:00
|
|
|
"dst", and the result from shader B as its "src".
|
2008-12-17 15:59:43 +00:00
|
|
|
mode->xfer32(sA_result, sB_result, ...)
|
|
|
|
@param shaderA The colors from this shader are seen as the "dst" by the xfermode
|
|
|
|
@param shaderB The colors from this shader are seen as the "src" by the xfermode
|
|
|
|
@param mode The xfermode that combines the colors from the two shaders. If mode
|
|
|
|
is null, then SRC_OVER is assumed.
|
|
|
|
*/
|
|
|
|
SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL);
|
|
|
|
virtual ~SkComposeShader();
|
2012-08-23 18:09:54 +00:00
|
|
|
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
virtual size_t contextSize() const SK_OVERRIDE;
|
|
|
|
|
|
|
|
class ComposeShaderContext : public SkShader::Context {
|
|
|
|
public:
|
|
|
|
// When this object gets destroyed, it will call contextA and contextB's destructor
|
|
|
|
// but it will NOT free the memory.
|
2014-05-01 19:31:31 +00:00
|
|
|
ComposeShaderContext(const SkComposeShader&, const ContextRec&,
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
SkShader::Context* contextA, SkShader::Context* contextB);
|
|
|
|
|
|
|
|
SkShader::Context* getShaderContextA() const { return fShaderContextA; }
|
|
|
|
SkShader::Context* getShaderContextB() const { return fShaderContextB; }
|
|
|
|
|
|
|
|
virtual ~ComposeShaderContext();
|
|
|
|
|
|
|
|
virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkShader::Context* fShaderContextA;
|
|
|
|
SkShader::Context* fShaderContextB;
|
|
|
|
|
|
|
|
typedef SkShader::Context INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef SK_DEBUG
|
|
|
|
SkShader* getShaderA() { return fShaderA; }
|
|
|
|
SkShader* getShaderB() { return fShaderB; }
|
|
|
|
#endif
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-03-13 18:02:17 +00:00
|
|
|
SK_TO_STRING_OVERRIDE()
|
2012-03-26 17:57:35 +00:00
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader)
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
protected:
|
2014-01-30 18:58:24 +00:00
|
|
|
SkComposeShader(SkReadBuffer& );
|
|
|
|
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
2014-05-05 18:39:18 +00:00
|
|
|
virtual Context* onCreateContext(const ContextRec&, void*) const SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SkShader* fShaderA;
|
|
|
|
SkShader* fShaderB;
|
|
|
|
SkXfermode* fMode;
|
|
|
|
|
|
|
|
typedef SkShader INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|