diff options
author | 2008-12-17 15:59:43 +0000 | |
---|---|---|
committer | 2008-12-17 15:59:43 +0000 | |
commit | 8a1c16ff38322f0210116fa7293eb8817c7e477e (patch) | |
tree | fe40e07f6c8983318a2f79032b9a706ede1090c1 /include/effects/SkLayerDrawLooper.h | |
parent | 2559c629078f738ac37095d896d580b681ac6a30 (diff) |
grab from latest android
git-svn-id: http://skia.googlecode.com/svn/trunk@27 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/effects/SkLayerDrawLooper.h')
-rw-r--r-- | include/effects/SkLayerDrawLooper.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h new file mode 100644 index 0000000000..670ac23d87 --- /dev/null +++ b/include/effects/SkLayerDrawLooper.h @@ -0,0 +1,70 @@ +#ifndef SkLayerDrawLooper_DEFINED +#define SkLayerDrawLooper_DEFINED + +#include "SkDrawLooper.h" + +struct SkPoint; + +class SkLayerDrawLooper : public SkDrawLooper { +public: + SkLayerDrawLooper(); + virtual ~SkLayerDrawLooper(); + + /** Call for each layer you want to add (from top to bottom). + This returns a paint you can modify, but that ptr is only valid until + the next call made to this object. + */ + SkPaint* addLayer(SkScalar dx, SkScalar dy); + + /** Helper for addLayer() which passes (0, 0) for the offset parameters + */ + SkPaint* addLayer() { + return this->addLayer(0, 0); + } + + // overrides from SkDrawLooper + virtual void init(SkCanvas*, SkPaint*); + virtual bool next(); + virtual void restore(); + + // must be public for Registrar :( + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { + return SkNEW_ARGS(SkLayerDrawLooper, (buffer)); + } + +protected: + SkLayerDrawLooper(SkFlattenableReadBuffer&); + + // overrides from SkFlattenable + virtual void flatten(SkFlattenableWriteBuffer& ); + virtual Factory getFactory() { return CreateProc; } + +private: + struct Rec { + Rec* fNext; + SkPaint fPaint; + SkPoint fOffset; + + static Rec* Reverse(Rec*); + }; + Rec* fRecs; + int fCount; + + struct Iter { + SkPaint fSavedPaint; + SkPaint* fPaint; + SkCanvas* fCanvas; + Rec* fRec; + }; + Iter fIter; + + class MyRegistrar : public SkFlattenable::Registrar { + public: + MyRegistrar(); + }; + + typedef SkDrawLooper INHERITED; +}; + + +#endif |