Index: include/core/SkDrawLooper.h |
diff --git a/include/core/SkDrawLooper.h b/include/core/SkDrawLooper.h |
index 4609c1dcf90ddb67a4708909ea209b5063fcfe18..60448f2bb0e3a34a99b19f3622d78f5c8ae63061 100644 |
--- a/include/core/SkDrawLooper.h |
+++ b/include/core/SkDrawLooper.h |
@@ -30,24 +30,49 @@ public: |
SK_DECLARE_INST_COUNT(SkDrawLooper) |
/** |
- * Called right before something is being drawn. This will be followed by |
- * calls to next() until next() returns false. |
+ * Holds state during a draw. Users call next() until it returns false. |
+ * When the context is no longer needed, call cleanup() to ensure memory |
scroggo
2014/03/11 14:08:05
No need for comment about cleanup()
Dominik Grewe
2014/03/11 18:28:17
Done.
|
+ * is released correctly. |
+ * |
+ * Subclasses of SkDrawLooper should create a subclass of this object to |
+ * hold state specific to their subclass. |
*/ |
- virtual void init(SkCanvas*) = 0; |
+ class SK_API Context : public SkNoncopyable { |
+ public: |
+ Context() {} |
+ virtual ~Context() {} |
+ |
+ /** |
+ * Called in a loop (after init()). Each time true is returned, the |
+ * object is drawn (possibly with a modified canvas and/or paint). When |
+ * false is finally returned, drawing for the object stops. |
+ * |
+ * On each call, the paint will be in its original state, but the |
+ * canvas will be as it was following the previous call to next() or |
+ * init(). |
+ * |
+ * The implementation must ensure that, when next() finally returns |
+ * false, that the canvas has been restored to the state it was |
+ * initially, before init() was first called. |
+ */ |
+ virtual bool next(SkCanvas* canvas, SkPaint* paint) = 0; |
+ }; |
/** |
- * Called in a loop (after init()). Each time true is returned, the object |
- * is drawn (possibly with a modified canvas and/or paint). When false is |
- * finally returned, drawing for the object stops. |
- * |
- * On each call, the paint will be in its original state, but the canvas |
- * will be as it was following the previous call to next() or init(). |
- * |
- * The implementation must ensure that, when next() finally returns false, |
- * that the canvas has been restored to the state it was initially, before |
- * init() was first called. |
+ * Called right before something is being drawn. Returns a Context |
+ * whose next() method should be called until it returns false. |
+ * The caller has to ensure that the storage pointer provides enough |
+ * memory for the Context. The required size can be queried by calling |
+ * contextSize(). It is also the caller's responsibility to destroy the |
+ * object after use. |
*/ |
- virtual bool next(SkCanvas*, SkPaint* paint) = 0; |
+ virtual Context* init(SkCanvas*, void* storage) const = 0; |
reed1
2014/03/11 14:23:31
Rename to something that reflects its "factory" na
scroggo
2014/03/11 15:51:02
Personally I like not having the size there. Passi
Dominik Grewe
2014/03/11 18:28:17
Done.
|
+ |
+ /** |
+ * Returns the number of bytes needed to store a Context object. |
scroggo
2014/03/11 14:08:05
I think it might be clearer to state that this is
Dominik Grewe
2014/03/11 18:28:17
Done.
|
+ */ |
+ virtual size_t contextSize() const = 0; |
+ |
/** |
* The fast bounds functions are used to enable the paint to be culled early |