Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: src/core/SkCanvasDrawable.h

Issue 732653004: option to return drawable from recording (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « samplecode/SampleArc.cpp ('k') | src/core/SkCanvasDrawable.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkCanvasDrawable_DEFINED 8 #ifndef SkCanvasDrawable_DEFINED
9 #define SkCanvasDrawable_DEFINED 9 #define SkCanvasDrawable_DEFINED
10 10
11 #include "SkRefCnt.h" 11 #include "SkRefCnt.h"
12 12
13 class SkBBHFactory;
14 class SkCanvas; 13 class SkCanvas;
14 class SkPicture;
15 struct SkRect; 15 struct SkRect;
16 16
17 /** 17 /**
18 * Base-class for objects that draw into SkCanvas. 18 * Base-class for objects that draw into SkCanvas.
19 * 19 *
20 * The object has a generation ID, which is guaranteed to be unique across all drawables. To 20 * The object has a generation ID, which is guaranteed to be unique across all drawables. To
21 * allow for clients of the drawable that may want to cache the results, the dr awable must 21 * allow for clients of the drawable that may want to cache the results, the dr awable must
22 * change its generation ID whenever its internal state changes such that it wi ll draw differently. 22 * change its generation ID whenever its internal state changes such that it wi ll draw differently.
23 */ 23 */
24 class SkCanvasDrawable : public SkRefCnt { 24 class SkCanvasDrawable : public SkRefCnt {
25 public: 25 public:
26 SkCanvasDrawable(); 26 SkCanvasDrawable();
27 27
28 /** 28 /**
29 * Draws into the specified content. The drawing sequence will be balanced upon return 29 * Draws into the specified content. The drawing sequence will be balanced upon return
30 * (i.e. the saveLevel() on the canvas will match what it was when draw() w as called, 30 * (i.e. the saveLevel() on the canvas will match what it was when draw() w as called,
31 * and the current matrix and clip settings will not be changed. 31 * and the current matrix and clip settings will not be changed.
32 */ 32 */
33 void draw(SkCanvas*); 33 void draw(SkCanvas*);
34 34
35 SkPicture* newPictureSnapshot(SkBBHFactory* bbhFactory, uint32_t recordFlags ); 35 SkPicture* newPictureSnapshot();
36 SkPicture* newPictureSnapshot() {
37 return this->newPictureSnapshot(NULL, 0);
38 }
39 36
40 /** 37 /**
41 * Return a unique value for this instance. If two calls to this return the same value, 38 * Return a unique value for this instance. If two calls to this return the same value,
42 * it is presumed that calling the draw() method will render the same thing as well. 39 * it is presumed that calling the draw() method will render the same thing as well.
43 * 40 *
44 * Subclasses that change their state should call notifyDrawingChanged() to ensure that 41 * Subclasses that change their state should call notifyDrawingChanged() to ensure that
45 * a new value will be returned the next time it is called. 42 * a new value will be returned the next time it is called.
46 */ 43 */
47 uint32_t getGenerationID(); 44 uint32_t getGenerationID();
48 45
49 /** 46 /**
50 * Return the (conservative) bounds of what the drawable will draw. If the drawable can 47 * Return the (conservative) bounds of what the drawable will draw. If the drawable can
51 * change what it draws (e.g. animation or in response to some external cha nge), then this 48 * change what it draws (e.g. animation or in response to some external cha nge), then this
52 * must return a bounds that is always valid for all possible states. 49 * must return a bounds that is always valid for all possible states.
53 */ 50 */
54 SkRect getBounds(); 51 SkRect getBounds();
55 52
56 /** 53 /**
57 * Calling this invalidates the previous generation ID, and causes a new on e to be computed 54 * Calling this invalidates the previous generation ID, and causes a new on e to be computed
58 * the next time getGenerationID() is called. Typically this is called by t he object itself, 55 * the next time getGenerationID() is called. Typically this is called by t he object itself,
59 * in response to its internal state changing. 56 * in response to its internal state changing.
60 */ 57 */
61 void notifyDrawingChanged(); 58 void notifyDrawingChanged();
62 59
63 protected: 60 protected:
64 virtual SkRect onGetBounds() = 0; 61 virtual SkRect onGetBounds() = 0;
65 virtual void onDraw(SkCanvas*) = 0; 62 virtual void onDraw(SkCanvas*) = 0;
66 virtual SkPicture* onNewPictureSnapshot(SkBBHFactory*, uint32_t recordFlags) ; 63 virtual SkPicture* onNewPictureSnapshot();
67 64
68 private: 65 private:
69 int32_t fGenerationID; 66 int32_t fGenerationID;
70 }; 67 };
71 68
72 #endif 69 #endif
OLDNEW
« no previous file with comments | « samplecode/SampleArc.cpp ('k') | src/core/SkCanvasDrawable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698