michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #ifndef SkComposeShader_DEFINED michael@0: #define SkComposeShader_DEFINED michael@0: michael@0: #include "SkShader.h" michael@0: michael@0: class SkXfermode; michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: /** \class SkComposeShader michael@0: This subclass of shader returns the coposition of two other shaders, combined by michael@0: a xfermode. michael@0: */ michael@0: class SK_API SkComposeShader : public SkShader { michael@0: public: michael@0: /** Create a new compose shader, given shaders A, B, and a combining xfermode mode. michael@0: When the xfermode is called, it will be given the result from shader A as its michael@0: "dst", and the result of from shader B as its "src". michael@0: mode->xfer32(sA_result, sB_result, ...) michael@0: @param shaderA The colors from this shader are seen as the "dst" by the xfermode michael@0: @param shaderB The colors from this shader are seen as the "src" by the xfermode michael@0: @param mode The xfermode that combines the colors from the two shaders. If mode michael@0: is null, then SRC_OVER is assumed. michael@0: */ michael@0: SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL); michael@0: virtual ~SkComposeShader(); michael@0: michael@0: virtual bool setContext(const SkBitmap&, const SkPaint&, michael@0: const SkMatrix&) SK_OVERRIDE; michael@0: virtual void endContext() SK_OVERRIDE; michael@0: virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE; michael@0: michael@0: SK_TO_STRING_OVERRIDE() michael@0: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader) michael@0: michael@0: protected: michael@0: SkComposeShader(SkReadBuffer& ); michael@0: virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; michael@0: michael@0: private: michael@0: michael@0: SkShader* fShaderA; michael@0: SkShader* fShaderB; michael@0: SkXfermode* fMode; michael@0: michael@0: typedef SkShader INHERITED; michael@0: }; michael@0: michael@0: #endif