| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 namespace SkRecords { | 31 namespace SkRecords { |
| 32 | 32 |
| 33 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. | 33 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. |
| 34 class Draw : SkNoncopyable { | 34 class Draw : SkNoncopyable { |
| 35 public: | 35 public: |
| 36 explicit Draw(SkCanvas* canvas, const SkMatrix* initialCTM = NULL) | 36 explicit Draw(SkCanvas* canvas, const SkMatrix* initialCTM = NULL) |
| 37 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) | 37 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) |
| 38 , fCanvas(canvas) {} | 38 , fCanvas(canvas) {} |
| 39 | 39 |
| 40 // This operator calls methods on the |canvas|. The various draw() wrapper |
| 41 // methods around SkCanvas are defined by the DRAW() macro in |
| 42 // SkRecordDraw.cpp. |
| 40 template <typename T> void operator()(const T& r) { | 43 template <typename T> void operator()(const T& r) { |
| 41 this->draw(r); | 44 this->draw(r); |
| 42 } | 45 } |
| 43 | 46 |
| 44 private: | 47 private: |
| 45 // No base case, so we'll be compile-time checked that we implement all poss
ibilities. | 48 // No base case, so we'll be compile-time checked that we implement all poss
ibilities. |
| 46 template <typename T> void draw(const T&); | 49 template <typename T> void draw(const T&); |
| 47 | 50 |
| 48 const SkMatrix fInitialCTM; | 51 const SkMatrix fInitialCTM; |
| 49 SkCanvas* fCanvas; | 52 SkCanvas* fCanvas; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 67 } | 70 } |
| 68 | 71 |
| 69 private: | 72 private: |
| 70 const SkRect fClearRect; | 73 const SkRect fClearRect; |
| 71 typedef Draw INHERITED; | 74 typedef Draw INHERITED; |
| 72 }; | 75 }; |
| 73 | 76 |
| 74 } // namespace SkRecords | 77 } // namespace SkRecords |
| 75 | 78 |
| 76 #endif//SkRecordDraw_DEFINED | 79 #endif//SkRecordDraw_DEFINED |
| OLD | NEW |