Home | History | Annotate | Download | only in effects
      1 #ifndef SkLayerDrawLooper_DEFINED
      2 #define SkLayerDrawLooper_DEFINED
      3 
      4 #include "SkDrawLooper.h"
      5 
      6 struct SkPoint;
      7 
      8 class SkLayerDrawLooper : public SkDrawLooper {
      9 public:
     10             SkLayerDrawLooper();
     11     virtual ~SkLayerDrawLooper();
     12 
     13     /** Call for each layer you want to add (from top to bottom).
     14         This returns a paint you can modify, but that ptr is only valid until
     15         the next call made to this object.
     16      */
     17     SkPaint* addLayer(SkScalar dx, SkScalar dy);
     18 
     19     /** Helper for addLayer() which passes (0, 0) for the offset parameters
     20      */
     21     SkPaint* addLayer() {
     22         return this->addLayer(0, 0);
     23     }
     24 
     25     // overrides from SkDrawLooper
     26     virtual void init(SkCanvas*, SkPaint*);
     27     virtual bool next();
     28     virtual void restore();
     29 
     30     // must be public for Registrar :(
     31     static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
     32         return SkNEW_ARGS(SkLayerDrawLooper, (buffer));
     33     }
     34 
     35 protected:
     36     SkLayerDrawLooper(SkFlattenableReadBuffer&);
     37 
     38     // overrides from SkFlattenable
     39     virtual void flatten(SkFlattenableWriteBuffer& );
     40     virtual Factory getFactory() { return CreateProc; }
     41 
     42 private:
     43     struct Rec {
     44         Rec*    fNext;
     45         SkPaint fPaint;
     46         SkPoint fOffset;
     47 
     48         static Rec* Reverse(Rec*);
     49     };
     50     Rec*    fRecs;
     51     int     fCount;
     52 
     53     struct Iter {
     54         SkPaint     fSavedPaint;
     55         SkPaint*    fPaint;
     56         SkCanvas*   fCanvas;
     57         Rec*        fRec;
     58     };
     59     Iter    fIter;
     60 
     61     class MyRegistrar : public SkFlattenable::Registrar {
     62     public:
     63         MyRegistrar();
     64     };
     65 
     66     typedef SkDrawLooper INHERITED;
     67 };
     68 
     69 
     70 #endif
     71