Chromium Code Reviews| Index: src/core/SkCanvasDrawable.h |
| diff --git a/src/core/SkCanvasDrawable.h b/src/core/SkCanvasDrawable.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..931a5a354aa7c63845107745a0a4e859b6779364 |
| --- /dev/null |
| +++ b/src/core/SkCanvasDrawable.h |
| @@ -0,0 +1,58 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef SkCanvasDrawable_DEFINED |
| +#define SkCanvasDrawable_DEFINED |
| + |
| +#include "SkRefCnt.h" |
| + |
| +class SkCanvas; |
| +struct SkRect; |
| + |
| +/** |
| + * Base-class to capture a set of drawing commands (sent to SkCanvas). Instances of this class |
| + * need not be thread-safe, but they must be able to be used in a thread different from where |
| + * they were created. |
| + */ |
| +class SkCanvasDrawable : public SkRefCnt { |
|
djsollen
2014/11/10 19:23:38
seems that the only real use case for this is anim
reed1
2014/11/11 12:46:30
I see it as more general. For instance, it could a
|
| +public: |
| + SkCanvasDrawable(); |
| + |
| + /** |
| + * Draws into the specified content. The drawing sequence will be balanced upon return |
| + * (i.e. the saveLevel() on the canvas will match what it was when draw() was called, |
| + * and the current matrix and clip settings will not be changed. |
| + */ |
| + void draw(SkCanvas*); |
| + |
| + /** |
| + * Return a unique value for this instance. If two calls to this return the same value, |
| + * it is presumed that calling the draw() method will render the same thing as well. |
| + * |
| + * Subclasses that change their state should call notifyDrawingChanged() to ensure that |
| + * a new value will be returned the next time it is called. |
| + */ |
| + uint32_t getGenerationID(); |
| + |
| + /** |
| + * If the drawable knows a bounds that will contains all of its drawing, return true and |
| + * set the parameter to that rectangle. If one is not known, ignore the parameter and |
| + * return false. |
| + */ |
| + bool getBounds(SkRect*); |
| + |
| + void notifyDrawingChanged(); |
|
djsollen
2014/11/10 19:23:39
can you add some comments on this?
reed1
2014/11/11 12:46:30
Done.
djsollen
2014/11/11 12:53:12
Did you forget to upload the comments? I don't see
|
| + |
| +protected: |
| + virtual void onDraw(SkCanvas*) = 0; |
|
robertphillips
2014/11/10 19:16:35
What do you think about having a default implement
reed1
2014/11/10 19:20:03
Done.
|
| + virtual bool onGetBounds(SkRect*) = 0; |
| + |
| +private: |
| + int32_t fGenerationID; |
| +}; |
| + |
| +#endif |