| 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. | 32 // Draw a portion of an SkRecord into an SkCanvas while replacing clears with dr
awRects. |
| 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 unsigned start, unsigned stop, const SkMatrix& initialC
TM); | 39 const SkRect&, unsigned start, unsigned stop, |
| 40 const SkMatrix& initialCTM); |
| 40 | 41 |
| 41 namespace SkRecords { | 42 namespace SkRecords { |
| 42 | 43 |
| 43 // 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. |
| 44 class Draw : SkNoncopyable { | 45 class Draw : SkNoncopyable { |
| 45 public: | 46 public: |
| 46 explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[], | 47 explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[], |
| 47 SkCanvasDrawable* const drawables[], int drawableCount, | 48 SkCanvasDrawable* const drawables[], int drawableCount, |
| 48 const SkMatrix* initialCTM = NULL) | 49 const SkMatrix* initialCTM = NULL) |
| 49 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) | 50 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 68 // 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. |
| 69 template <typename T> void draw(const T&); | 70 template <typename T> void draw(const T&); |
| 70 | 71 |
| 71 const SkMatrix fInitialCTM; | 72 const SkMatrix fInitialCTM; |
| 72 SkCanvas* fCanvas; | 73 SkCanvas* fCanvas; |
| 73 SkPicture const* const* fDrawablePicts; | 74 SkPicture const* const* fDrawablePicts; |
| 74 SkCanvasDrawable* const* fDrawables; | 75 SkCanvasDrawable* const* fDrawables; |
| 75 int fDrawableCount; | 76 int fDrawableCount; |
| 76 }; | 77 }; |
| 77 | 78 |
| 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 |
| 78 } // namespace SkRecords | 103 } // namespace SkRecords |
| 79 | 104 |
| 80 #endif//SkRecordDraw_DEFINED | 105 #endif//SkRecordDraw_DEFINED |
| OLD | NEW |