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 |
11 #include "SkBBoxHierarchy.h" | 11 #include "SkBBoxHierarchy.h" |
12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
14 #include "SkRecord.h" | 14 #include "SkRecord.h" |
15 | 15 |
16 class SkCanvasDrawable; | 16 class SkDrawable; |
17 class SkLayerInfo; | 17 class SkLayerInfo; |
18 | 18 |
19 // Fill a BBH to be used by SkRecordDraw to accelerate playback. | 19 // Fill a BBH to be used by SkRecordDraw to accelerate playback. |
20 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord&, SkBBoxHierarchy
*); | 20 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord&, SkBBoxHierarchy
*); |
21 | 21 |
22 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, | 22 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, |
23 const SkPicture::SnapshotArray*, | 23 const SkPicture::SnapshotArray*, |
24 SkBBoxHierarchy* bbh, SkLayerInfo* data); | 24 SkBBoxHierarchy* bbh, SkLayerInfo* data); |
25 | 25 |
26 // Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::D
raw. | 26 // Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::D
raw. |
27 void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePic
ts[], | 27 void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePic
ts[], |
28 SkCanvasDrawable* const drawables[], int drawableCount, | 28 SkDrawable* const drawables[], int drawableCount, |
29 const SkBBoxHierarchy*, SkPicture::AbortCallback*); | 29 const SkBBoxHierarchy*, SkPicture::AbortCallback*); |
30 | 30 |
31 // Draw a portion of an SkRecord into an SkCanvas. | 31 // Draw a portion of an SkRecord into an SkCanvas. |
32 // When drawing a portion of an SkRecord the CTM on the passed in canvas must be | 32 // When drawing a portion of an SkRecord the CTM on the passed in canvas must be |
33 // the composition of the replay matrix with the record-time CTM (for the portio
n | 33 // the composition of the replay matrix with the record-time CTM (for the portio
n |
34 // of the record that is being replayed). For setMatrix calls to behave correctl
y | 34 // of the record that is being replayed). For setMatrix calls to behave correctl
y |
35 // the initialCTM parameter must set to just the replay matrix. | 35 // the initialCTM parameter must set to just the replay matrix. |
36 void SkRecordPartialDraw(const SkRecord&, SkCanvas*, | 36 void SkRecordPartialDraw(const SkRecord&, SkCanvas*, |
37 SkPicture const* const drawablePicts[], int drawableCou
nt, | 37 SkPicture const* const drawablePicts[], int drawableCou
nt, |
38 unsigned start, unsigned stop, const SkMatrix& initialC
TM); | 38 unsigned start, unsigned stop, const SkMatrix& initialC
TM); |
39 | 39 |
40 namespace SkRecords { | 40 namespace SkRecords { |
41 | 41 |
42 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. | 42 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. |
43 class Draw : SkNoncopyable { | 43 class Draw : SkNoncopyable { |
44 public: | 44 public: |
45 explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[], | 45 explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[], |
46 SkCanvasDrawable* const drawables[], int drawableCount, | 46 SkDrawable* const drawables[], int drawableCount, |
47 const SkMatrix* initialCTM = NULL) | 47 const SkMatrix* initialCTM = NULL) |
48 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) | 48 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) |
49 , fCanvas(canvas) | 49 , fCanvas(canvas) |
50 , fDrawablePicts(drawablePicts) | 50 , fDrawablePicts(drawablePicts) |
51 , fDrawables(drawables) | 51 , fDrawables(drawables) |
52 , fDrawableCount(drawableCount) | 52 , fDrawableCount(drawableCount) |
53 {} | 53 {} |
54 | 54 |
55 // This operator calls methods on the |canvas|. The various draw() wrapper | 55 // This operator calls methods on the |canvas|. The various draw() wrapper |
56 // methods around SkCanvas are defined by the DRAW() macro in | 56 // methods around SkCanvas are defined by the DRAW() macro in |
57 // SkRecordDraw.cpp. | 57 // SkRecordDraw.cpp. |
58 template <typename T> void operator()(const T& r) { | 58 template <typename T> void operator()(const T& r) { |
59 this->draw(r); | 59 this->draw(r); |
60 } | 60 } |
61 | 61 |
62 protected: | 62 protected: |
63 SkPicture const* const* drawablePicts() const { return fDrawablePicts; } | 63 SkPicture const* const* drawablePicts() const { return fDrawablePicts; } |
64 int drawableCount() const { return fDrawableCount; } | 64 int drawableCount() const { return fDrawableCount; } |
65 | 65 |
66 private: | 66 private: |
67 // No base case, so we'll be compile-time checked that we implement all poss
ibilities. | 67 // No base case, so we'll be compile-time checked that we implement all poss
ibilities. |
68 template <typename T> void draw(const T&); | 68 template <typename T> void draw(const T&); |
69 | 69 |
70 const SkMatrix fInitialCTM; | 70 const SkMatrix fInitialCTM; |
71 SkCanvas* fCanvas; | 71 SkCanvas* fCanvas; |
72 SkPicture const* const* fDrawablePicts; | 72 SkPicture const* const* fDrawablePicts; |
73 SkCanvasDrawable* const* fDrawables; | 73 SkDrawable* const* fDrawables; |
74 int fDrawableCount; | 74 int fDrawableCount; |
75 }; | 75 }; |
76 | 76 |
77 } // namespace SkRecords | 77 } // namespace SkRecords |
78 | 78 |
79 #endif//SkRecordDraw_DEFINED | 79 #endif//SkRecordDraw_DEFINED |
OLD | NEW |