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

Side by Side Diff: src/core/SkRecordDraw.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 | « src/core/SkRecord.h ('k') | src/core/SkRecordDraw.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 SkRecordDraw_DEFINED 8 #ifndef SkRecordDraw_DEFINED
9 #define SkRecordDraw_DEFINED 9 #define SkRecordDraw_DEFINED
10 10
11 #include "SkBBoxHierarchy.h" 11 #include "SkBBoxHierarchy.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkDrawPictureCallback.h" 13 #include "SkDrawPictureCallback.h"
14 #include "SkMatrix.h" 14 #include "SkMatrix.h"
15 #include "SkRecord.h" 15 #include "SkRecord.h"
16 16
17 class SkCanvasDrawable;
17 class SkLayerInfo; 18 class SkLayerInfo;
18 19
19 // Fill a BBH to be used by SkRecordDraw to accelerate playback. 20 // Fill a BBH to be used by SkRecordDraw to accelerate playback.
20 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord&, SkBBoxHierarchy *); 21 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord&, SkBBoxHierarchy *);
21 22
22 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, 23 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record,
24 const SkPicture::SnapshotArray*,
23 SkBBoxHierarchy* bbh, SkLayerInfo* data); 25 SkBBoxHierarchy* bbh, SkLayerInfo* data);
24 26
25 // Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::D raw. 27 // Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::D raw.
26 void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePic ts[], int drawableCount, 28 void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePic ts[],
29 SkCanvasDrawable* const drawables[], int drawableCount,
27 const SkBBoxHierarchy*, SkDrawPictureCallback*); 30 const SkBBoxHierarchy*, SkDrawPictureCallback*);
28 31
29 // Draw a portion of an SkRecord into an SkCanvas while replacing clears with dr awRects. 32 // Draw a portion of an SkRecord into an SkCanvas while replacing clears with dr awRects.
30 // When drawing a portion of an SkRecord the CTM on the passed in canvas must be 33 // When drawing a portion of an SkRecord the CTM on the passed in canvas must be
31 // the composition of the replay matrix with the record-time CTM (for the portio n 34 // the composition of the replay matrix with the record-time CTM (for the portio n
32 // of the record that is being replayed). For setMatrix calls to behave correctl y 35 // of the record that is being replayed). For setMatrix calls to behave correctl y
33 // the initialCTM parameter must set to just the replay matrix. 36 // the initialCTM parameter must set to just the replay matrix.
34 void SkRecordPartialDraw(const SkRecord&, SkCanvas*, 37 void SkRecordPartialDraw(const SkRecord&, SkCanvas*,
35 SkPicture const* const drawablePicts[], int drawableCou nt, 38 SkPicture const* const drawablePicts[], int drawableCou nt,
36 const SkRect&, unsigned start, unsigned stop, 39 const SkRect&, unsigned start, unsigned stop,
37 const SkMatrix& initialCTM); 40 const SkMatrix& initialCTM);
38 41
39 namespace SkRecords { 42 namespace SkRecords {
40 43
41 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. 44 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas.
42 class Draw : SkNoncopyable { 45 class Draw : SkNoncopyable {
43 public: 46 public:
44 explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[], int drawableCount, 47 explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[],
48 SkCanvasDrawable* const drawables[], int drawableCount,
45 const SkMatrix* initialCTM = NULL) 49 const SkMatrix* initialCTM = NULL)
46 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) 50 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix())
47 , fCanvas(canvas) 51 , fCanvas(canvas)
48 , fDrawablePicts(drawablePicts) 52 , fDrawablePicts(drawablePicts)
53 , fDrawables(drawables)
49 , fDrawableCount(drawableCount) 54 , fDrawableCount(drawableCount)
50 {} 55 {}
51 56
52 // This operator calls methods on the |canvas|. The various draw() wrapper 57 // This operator calls methods on the |canvas|. The various draw() wrapper
53 // methods around SkCanvas are defined by the DRAW() macro in 58 // methods around SkCanvas are defined by the DRAW() macro in
54 // SkRecordDraw.cpp. 59 // SkRecordDraw.cpp.
55 template <typename T> void operator()(const T& r) { 60 template <typename T> void operator()(const T& r) {
56 this->draw(r); 61 this->draw(r);
57 } 62 }
58 63
59 protected: 64 protected:
60 SkPicture const* const* drawablePicts() const { return fDrawablePicts; } 65 SkPicture const* const* drawablePicts() const { return fDrawablePicts; }
61 int drawableCount() const { return fDrawableCount; } 66 int drawableCount() const { return fDrawableCount; }
62 67
63 private: 68 private:
64 // No base case, so we'll be compile-time checked that we implement all poss ibilities. 69 // No base case, so we'll be compile-time checked that we implement all poss ibilities.
65 template <typename T> void draw(const T&); 70 template <typename T> void draw(const T&);
66 71
67 const SkMatrix fInitialCTM; 72 const SkMatrix fInitialCTM;
68 SkCanvas* fCanvas; 73 SkCanvas* fCanvas;
69 SkPicture const* const* fDrawablePicts; 74 SkPicture const* const* fDrawablePicts;
75 SkCanvasDrawable* const* fDrawables;
70 int fDrawableCount; 76 int fDrawableCount;
71 }; 77 };
72 78
73 // Used by SkRecordPartialDraw. 79 // Used by SkRecordPartialDraw.
74 class PartialDraw : public Draw { 80 class PartialDraw : public Draw {
75 public: 81 public:
76 PartialDraw(SkCanvas* canvas, SkPicture const* const drawablePicts[], int dr awableCount, 82 PartialDraw(SkCanvas* canvas, SkPicture const* const drawablePicts[], int dr awableCount,
77 const SkRect& clearRect, const SkMatrix& initialCTM) 83 const SkRect& clearRect, const SkMatrix& initialCTM)
78 : INHERITED(canvas, drawablePicts, drawableCount, &initialCTM), fClearRe ct(clearRect) {} 84 : INHERITED(canvas, drawablePicts, NULL, drawableCount, &initialCTM), fC learRect(clearRect)
85 {}
79 86
80 // Same as Draw for all ops except Clear. 87 // Same as Draw for all ops except Clear.
81 template <typename T> void operator()(const T& r) { 88 template <typename T> void operator()(const T& r) {
82 this->INHERITED::operator()(r); 89 this->INHERITED::operator()(r);
83 } 90 }
84 void operator()(const Clear& c) { 91 void operator()(const Clear& c) {
85 SkPaint p; 92 SkPaint p;
86 p.setColor(c.color); 93 p.setColor(c.color);
87 DrawRect drawRect(p, fClearRect); 94 DrawRect drawRect(p, fClearRect);
88 this->INHERITED::operator()(drawRect); 95 this->INHERITED::operator()(drawRect);
89 } 96 }
90 97
91 private: 98 private:
92 const SkRect fClearRect; 99 const SkRect fClearRect;
93 typedef Draw INHERITED; 100 typedef Draw INHERITED;
94 }; 101 };
95 102
96 } // namespace SkRecords 103 } // namespace SkRecords
97 104
98 #endif//SkRecordDraw_DEFINED 105 #endif//SkRecordDraw_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkRecord.h ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698