| Index: include/utils/SkPictureUtils.h
|
| ===================================================================
|
| --- include/utils/SkPictureUtils.h (revision 13001)
|
| +++ include/utils/SkPictureUtils.h (working copy)
|
| @@ -9,6 +9,7 @@
|
| #define SkPictureUtils_DEFINED
|
|
|
| #include "SkPicture.h"
|
| +#include "SkTDArray.h"
|
|
|
| class SkData;
|
| struct SkRect;
|
| @@ -26,6 +27,57 @@
|
| * and remains unchanged.
|
| */
|
| static SkData* GatherPixelRefs(SkPicture* pict, const SkRect& area);
|
| +
|
| + /**
|
| + * SkPixelRefContainer provides a base class for more elaborate pixel ref
|
| + * query structures (e.g., rtrees, quad-trees, etc.)
|
| + */
|
| + class SkPixelRefContainer : public SkRefCnt {
|
| + public:
|
| + virtual void add(SkPixelRef* pr, const SkRect& rect) = 0;
|
| +
|
| + // The returned array may contain duplicates
|
| + virtual void query(const SkRect& queryRect, SkTDArray<SkPixelRef*> *result) = 0;
|
| +
|
| + private:
|
| + typedef SkRefCnt INHERITED;
|
| + };
|
| +
|
| + // Simple query structure that just stores a linked list of pixel refs
|
| + // and rects.
|
| + class SkPixelRefsAndRectsList : public SkPixelRefContainer {
|
| + public:
|
| + virtual void add(SkPixelRef* pr, const SkRect& rect) SK_OVERRIDE {
|
| + PixelRefAndRect *dst = fArray.append();
|
| +
|
| + dst->fPixelRef = pr;
|
| + dst->fRect = rect;
|
| + }
|
| +
|
| + virtual void query(const SkRect& queryRect, SkTDArray<SkPixelRef*> *result) SK_OVERRIDE {
|
| + for (int i = 0; i < fArray.count(); ++i) {
|
| + if (SkRect::Intersects(fArray[i].fRect, queryRect)) {
|
| + *result->append() = fArray[i].fPixelRef;
|
| + }
|
| + }
|
| + }
|
| +
|
| + private:
|
| + struct PixelRefAndRect {
|
| + SkPixelRef* fPixelRef;
|
| + SkRect fRect;
|
| + };
|
| +
|
| + SkTDArray<PixelRefAndRect> fArray;
|
| +
|
| + typedef SkPixelRefContainer INHERITED;
|
| + };
|
| +
|
| + /**
|
| + * Fill the provided pixel ref container with the picture's pixel ref
|
| + * and rect information.
|
| + */
|
| + static void GatherPixelRefsAndRects(SkPicture* pict, SkPixelRefContainer* prCont);
|
| };
|
|
|
| #endif
|
|
|