OLD | NEW |
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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, | 23 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, |
24 const SkPicture::SnapshotArray*, | 24 const SkPicture::SnapshotArray*, |
25 SkBBoxHierarchy* bbh, SkLayerInfo* data); | 25 SkBBoxHierarchy* bbh, SkLayerInfo* data); |
26 | 26 |
27 // 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. |
28 void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePic
ts[], | 28 void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePic
ts[], |
29 SkCanvasDrawable* const drawables[], int drawableCount, | 29 SkCanvasDrawable* const drawables[], int drawableCount, |
30 const SkBBoxHierarchy*, SkDrawPictureCallback*); | 30 const SkBBoxHierarchy*, SkDrawPictureCallback*); |
31 | 31 |
32 // 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. |
33 // 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 |
34 // 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 |
35 // 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 |
36 // the initialCTM parameter must set to just the replay matrix. | 36 // the initialCTM parameter must set to just the replay matrix. |
37 void SkRecordPartialDraw(const SkRecord&, SkCanvas*, | 37 void SkRecordPartialDraw(const SkRecord&, SkCanvas*, |
38 SkPicture const* const drawablePicts[], int drawableCou
nt, | 38 SkPicture const* const drawablePicts[], int drawableCou
nt, |
39 const SkRect&, unsigned start, unsigned stop, | 39 unsigned start, unsigned stop, const SkMatrix& initialC
TM); |
40 const SkMatrix& initialCTM); | |
41 | 40 |
42 namespace SkRecords { | 41 namespace SkRecords { |
43 | 42 |
44 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. | 43 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. |
45 class Draw : SkNoncopyable { | 44 class Draw : SkNoncopyable { |
46 public: | 45 public: |
47 explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[], | 46 explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[], |
48 SkCanvasDrawable* const drawables[], int drawableCount, | 47 SkCanvasDrawable* const drawables[], int drawableCount, |
49 const SkMatrix* initialCTM = NULL) | 48 const SkMatrix* initialCTM = NULL) |
50 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) | 49 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) |
(...skipping 18 matching lines...) Expand all Loading... |
69 // No base case, so we'll be compile-time checked that we implement all poss
ibilities. | 68 // No base case, so we'll be compile-time checked that we implement all poss
ibilities. |
70 template <typename T> void draw(const T&); | 69 template <typename T> void draw(const T&); |
71 | 70 |
72 const SkMatrix fInitialCTM; | 71 const SkMatrix fInitialCTM; |
73 SkCanvas* fCanvas; | 72 SkCanvas* fCanvas; |
74 SkPicture const* const* fDrawablePicts; | 73 SkPicture const* const* fDrawablePicts; |
75 SkCanvasDrawable* const* fDrawables; | 74 SkCanvasDrawable* const* fDrawables; |
76 int fDrawableCount; | 75 int fDrawableCount; |
77 }; | 76 }; |
78 | 77 |
79 // Used by SkRecordPartialDraw. | |
80 class PartialDraw : public Draw { | |
81 public: | |
82 PartialDraw(SkCanvas* canvas, SkPicture const* const drawablePicts[], int dr
awableCount, | |
83 const SkRect& clearRect, const SkMatrix& initialCTM) | |
84 : INHERITED(canvas, drawablePicts, NULL, drawableCount, &initialCTM), fC
learRect(clearRect) | |
85 {} | |
86 | |
87 // Same as Draw for all ops except Clear. | |
88 template <typename T> void operator()(const T& r) { | |
89 this->INHERITED::operator()(r); | |
90 } | |
91 void operator()(const Clear& c) { | |
92 SkPaint p; | |
93 p.setColor(c.color); | |
94 DrawRect drawRect(p, fClearRect); | |
95 this->INHERITED::operator()(drawRect); | |
96 } | |
97 | |
98 private: | |
99 const SkRect fClearRect; | |
100 typedef Draw INHERITED; | |
101 }; | |
102 | |
103 } // namespace SkRecords | 78 } // namespace SkRecords |
104 | 79 |
105 #endif//SkRecordDraw_DEFINED | 80 #endif//SkRecordDraw_DEFINED |
OLD | NEW |