| 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 SkMultiPictureDraw_DEFINED | 8 #ifndef SkMultiPictureDraw_DEFINED |
| 9 #define SkMultiPictureDraw_DEFINED | 9 #define SkMultiPictureDraw_DEFINED |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 * @param paint if non-NULL, draw picture to a temporary buffer | 38 * @param paint if non-NULL, draw picture to a temporary buffer |
| 39 * and then apply the paint when the result is drawn | 39 * and then apply the paint when the result is drawn |
| 40 */ | 40 */ |
| 41 void add(SkCanvas* canvas, | 41 void add(SkCanvas* canvas, |
| 42 const SkPicture* picture, | 42 const SkPicture* picture, |
| 43 const SkMatrix* matrix = NULL, | 43 const SkMatrix* matrix = NULL, |
| 44 const SkPaint* paint = NULL); | 44 const SkPaint* paint = NULL); |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * Perform all the previously added draws. This will reset the state | 47 * Perform all the previously added draws. This will reset the state |
| 48 * of this object. | 48 * of this object. If flush is true, all canvases are flushed after |
| 49 * draw. |
| 49 */ | 50 */ |
| 50 void draw(); | 51 void draw(bool flush = false); |
| 51 | 52 |
| 52 /** | 53 /** |
| 53 * Abandon all buffered draws and reset to the initial state. | 54 * Abandon all buffered draws and reset to the initial state. |
| 54 */ | 55 */ |
| 55 void reset(); | 56 void reset(); |
| 56 | 57 |
| 57 private: | 58 private: |
| 58 struct DrawData { | 59 struct DrawData { |
| 59 SkCanvas* fCanvas; // reffed | 60 SkCanvas* fCanvas; // reffed |
| 60 const SkPicture* fPicture; // reffed | 61 const SkPicture* fPicture; // reffed |
| 61 SkMatrix fMatrix; | 62 SkMatrix fMatrix; |
| 62 SkPaint* fPaint; // owned | 63 SkPaint* fPaint; // owned |
| 63 | 64 |
| 64 void init(SkCanvas*, const SkPicture*, const SkMatrix*, const SkPaint*); | 65 void init(SkCanvas*, const SkPicture*, const SkMatrix*, const SkPaint*); |
| 65 void draw(); | 66 void draw(); |
| 66 | 67 |
| 67 static void Reset(SkTDArray<DrawData>&); | 68 static void Reset(SkTDArray<DrawData>&); |
| 68 | 69 |
| 69 static void Draw(DrawData* d) { d->draw(); } | 70 static void Draw(DrawData* d) { d->draw(); } |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 SkTDArray<DrawData> fThreadSafeDrawData; | 73 SkTDArray<DrawData> fThreadSafeDrawData; |
| 73 SkTDArray<DrawData> fGPUDrawData; | 74 SkTDArray<DrawData> fGPUDrawData; |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 #endif | 77 #endif |
| OLD | NEW |