1 :
2 : /*
3 : * Copyright 2011 The Android Open Source Project
4 : *
5 : * Use of this source code is governed by a BSD-style license that can be
6 : * found in the LICENSE file.
7 : */
8 :
9 :
10 : #ifndef SkDrawLooper_DEFINED
11 : #define SkDrawLooper_DEFINED
12 :
13 : #include "SkFlattenable.h"
14 :
15 : class SkCanvas;
16 : class SkPaint;
17 :
18 : /** \class SkDrawLooper
19 : Subclasses of SkDrawLooper can be attached to a SkPaint. Where they are,
20 : and something is drawn to a canvas with that paint, the looper subclass will
21 : be called, allowing it to modify the canvas and/or paint for that draw call.
22 : More than that, via the next() method, the looper can modify the draw to be
23 : invoked multiple times (hence the name loop-er), allow it to perform effects
24 : like shadows or frame/fills, that require more than one pass.
25 : */
26 0 : class SK_API SkDrawLooper : public SkFlattenable {
27 : public:
28 : /**
29 : * Called right before something is being drawn. This will be followed by
30 : * calls to next() until next() returns false.
31 : */
32 : virtual void init(SkCanvas*) = 0;
33 :
34 : /**
35 : * Called in a loop (after init()). Each time true is returned, the object
36 : * is drawn (possibly with a modified canvas and/or paint). When false is
37 : * finally returned, drawing for the object stops.
38 : *
39 : * On each call, the paint will be in its original state, but the canvas
40 : * will be as it was following the previous call to next() or init().
41 : *
42 : * The implementation must ensure that, when next() finally returns false,
43 : * that the canvas has been restored to the state it was initially, before
44 : * init() was first called.
45 : */
46 : virtual bool next(SkCanvas*, SkPaint* paint) = 0;
47 :
48 : protected:
49 0 : SkDrawLooper() {}
50 0 : SkDrawLooper(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {}
51 :
52 : private:
53 : typedef SkFlattenable INHERITED;
54 : };
55 :
56 : #endif
|