Chromium Code Reviews| Index: include/core/SkMultiPictureDraw.h |
| diff --git a/include/core/SkMultiPictureDraw.h b/include/core/SkMultiPictureDraw.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f191311ebc38762e898bb76f486977e69441382a |
| --- /dev/null |
| +++ b/include/core/SkMultiPictureDraw.h |
| @@ -0,0 +1,61 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef SkMultiPictureDraw_DEFINED |
| +#define SkMultiPictureDraw_DEFINED |
| + |
| +#include "SkMatrix.h" |
| +#include "SkTDArray.h" |
| + |
| +class SkCanvas; |
| +class SkPaint; |
| +class SkPicture; |
| + |
| +/** \class SkMultiPictureDraw |
| + |
| + The MultiPictureDraw object accepts several picture/canvas pairs and |
| + then attempts to optimally draw the pictures into the canvases, sharing |
| + as many resources as possible. |
| +*/ |
| +class SkMultiPictureDraw { |
| +public: |
| + SkMultiPictureDraw(int sizeHint = 0); |
|
reed1
2014/08/21 17:58:01
document or remove
bsalomon
2014/08/21 17:58:40
wonder if we should call this reserve to be consis
bsalomon
2014/08/21 17:58:40
wonder if we should call this reserve to be consis
robertphillips
2014/08/21 18:21:35
Done.
robertphillips
2014/08/21 18:21:35
Done.
|
| + ~SkMultiPictureDraw() { this->unrefAll(); } |
| + |
| + /** |
| + * Add a canvas/picture pair for later rendering. |
| + * @param canvas the canvas in which to draw picture |
| + * @param picture the picture to draw into canvas |
| + * @param matrix if non-NULL, applied to the CTM when drawing |
| + * @param paint if non-NULL, draw picture to a temporary buffer |
| + * and then apply the paint when the result is drawn |
| + */ |
| + void add(SkCanvas* canvas, |
| + const SkPicture* picture, |
| + const SkMatrix* matrix = NULL, |
| + const SkPaint* paint = NULL); |
| + |
| + /** |
| + * Perform all the previously added draws. This will reset the state |
| + * of this object. |
| + */ |
| + void draw(); |
| + |
| +private: |
| + struct DrawData { |
| + SkCanvas* canvas; // reffed |
| + const SkPicture* picture; // reffed |
| + SkMatrix matrix; |
| + SkPaint* paint; // owned |
| + }; |
| + |
| + SkTDArray<DrawData> fDrawData; |
| + |
| + void unrefAll(); |
| +}; |
| + |
| +#endif |