OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkCanvasDrawable_DEFINED |
| 9 #define SkCanvasDrawable_DEFINED |
| 10 |
| 11 #include "SkRefCnt.h" |
| 12 |
| 13 class SkCanvas; |
| 14 struct SkRect; |
| 15 |
| 16 /** |
| 17 * Base-class to capture a set of drawing commands (sent to SkCanvas). Instance
s of this class |
| 18 * need not be thread-safe, but they must be able to be used in a thread differ
ent from where |
| 19 * they were created. |
| 20 */ |
| 21 class SkCanvasDrawable : public SkRefCnt { |
| 22 public: |
| 23 SkCanvasDrawable(); |
| 24 |
| 25 /** |
| 26 * Draws into the specified content. The drawing sequence will be balanced
upon return |
| 27 * (i.e. the saveLevel() on the canvas will match what it was when draw() w
as called, |
| 28 * and the current matrix and clip settings will not be changed. |
| 29 */ |
| 30 void draw(SkCanvas*); |
| 31 |
| 32 /** |
| 33 * Return a unique value for this instance. If two calls to this return the
same value, |
| 34 * it is presumed that calling the draw() method will render the same thing
as well. |
| 35 * |
| 36 * Subclasses that change their state should call notifyDrawingChanged() to
ensure that |
| 37 * a new value will be returned the next time it is called. |
| 38 */ |
| 39 uint32_t getGenerationID(); |
| 40 |
| 41 /** |
| 42 * If the drawable knows a bounds that will contains all of its drawing, re
turn true and |
| 43 * set the parameter to that rectangle. If one is not known, ignore the par
ameter and |
| 44 * return false. |
| 45 */ |
| 46 bool getBounds(SkRect*); |
| 47 |
| 48 void notifyDrawingChanged(); |
| 49 |
| 50 protected: |
| 51 virtual void onDraw(SkCanvas*) = 0; |
| 52 |
| 53 virtual bool onGetBounds(SkRect*) { return false; } |
| 54 |
| 55 private: |
| 56 int32_t fGenerationID; |
| 57 }; |
| 58 |
| 59 #endif |
OLD | NEW |