Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: include/utils/SkPictureUtils.h

Issue 134473002: Pull in Chromium's version of GatherPixelRefs (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: cleaned up Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/utils.gyp ('k') | src/utils/SkGatherPixelRefsAndRects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « gyp/utils.gyp ('k') | src/utils/SkGatherPixelRefsAndRects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698