diff options
author | initial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-27 00:09:42 +0000 |
---|---|---|
committer | initial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-27 00:09:42 +0000 |
commit | ae2c20f398933a9e86c387dcc465ec0f71065ffc (patch) | |
tree | de668b1411e2ee0b4e49b6d8f8b68183134ac990 /skia/include/SkXfermode.h | |
parent | 09911bf300f1a419907a9412154760efd0b7abc3 (diff) | |
download | chromium_src-ae2c20f398933a9e86c387dcc465ec0f71065ffc.zip chromium_src-ae2c20f398933a9e86c387dcc465ec0f71065ffc.tar.gz chromium_src-ae2c20f398933a9e86c387dcc465ec0f71065ffc.tar.bz2 |
Add skia to the repository.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/include/SkXfermode.h')
-rw-r--r-- | skia/include/SkXfermode.h | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/skia/include/SkXfermode.h b/skia/include/SkXfermode.h new file mode 100644 index 0000000..8de5e65d --- /dev/null +++ b/skia/include/SkXfermode.h @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2006 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SkXfermode_DEFINED +#define SkXfermode_DEFINED + +#include "SkFlattenable.h" +#include "SkColor.h" + +/** \class SkXfermode + + SkXfermode is the base class for objects that are called to implement custom + "transfer-modes" in the drawing pipeline. The static function Create(Modes) + can be called to return an instance of any of the predefined subclasses as + specified in the Modes enum. When an SkXfermode is assigned to an SkPaint, + then objects drawn with that paint have the xfermode applied. +*/ +class SkXfermode : public SkFlattenable { +public: + SkXfermode() {} + + virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, + const SkAlpha aa[]); + virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, + const SkAlpha aa[]); + virtual void xfer4444(uint16_t dst[], const SkPMColor src[], int count, + const SkAlpha aa[]); + virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, + const SkAlpha aa[]); + + enum Coeff { + kZero_Coeff, + kOne_Coeff, + kSC_Coeff, + kISC_Coeff, + kDC_Coeff, + kIDC_Coeff, + kSA_Coeff, + kISA_Coeff, + kDA_Coeff, + kIDA_Coeff, + + kCoeffCount + }; + virtual bool asCoeff(Coeff* src, Coeff* dst); + +protected: + SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {} + + /** The default implementation of xfer32/xfer16/xferA8 in turn call this + method, 1 color at a time (upscaled to a SkPMColor). The default + implmentation of this method just returns dst. If performance is + important, your subclass should override xfer32/xfer16/xferA8 directly. + + This method will not be called directly by the client, so it need not + be implemented if your subclass has overridden xfer32/xfer16/xferA8 + */ + virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst); + +private: + typedef SkFlattenable INHERITED; +}; + +/////////////////////////////////////////////////////////////////////////////// + +/** \class SkProcXfermode + + SkProcXfermode is a xfermode that applies the specified proc to its colors. + This class is not exported to java. +*/ +class SkProcXfermode : public SkXfermode { +public: + SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {} + + // overrides from SkXfermode + virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, + const SkAlpha aa[]); + virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, + const SkAlpha aa[]); + virtual void xfer4444(uint16_t dst[], const SkPMColor src[], int count, + const SkAlpha aa[]); + virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, + const SkAlpha aa[]); + + // overrides from SkFlattenable + virtual Factory getFactory() { return CreateProc; } + virtual void flatten(SkFlattenableWriteBuffer&); + +protected: + SkProcXfermode(SkFlattenableReadBuffer&); + +private: + SkXfermodeProc fProc; + + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { + return SkNEW_ARGS(SkProcXfermode, (buffer)); } + + typedef SkXfermode INHERITED; +}; + +#endif + |