gfx/skia/trunk/include/utils/SkPictureUtils.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2012 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef SkPictureUtils_DEFINED
michael@0 9 #define SkPictureUtils_DEFINED
michael@0 10
michael@0 11 #include "SkPicture.h"
michael@0 12 #include "SkTDArray.h"
michael@0 13
michael@0 14 class SkData;
michael@0 15 struct SkRect;
michael@0 16
michael@0 17 class SK_API SkPictureUtils {
michael@0 18 public:
michael@0 19 /**
michael@0 20 * Given a rectangular visible "window" into the picture, return an array
michael@0 21 * of SkPixelRefs that might intersect that area. To keep the call fast,
michael@0 22 * the returned list is not guaranteed to be exact, so it may miss some,
michael@0 23 * and it may return false positives.
michael@0 24 *
michael@0 25 * The pixelrefs returned in the SkData are already owned by the picture,
michael@0 26 * so the returned pointers are only valid while the picture is in scope
michael@0 27 * and remains unchanged.
michael@0 28 */
michael@0 29 static SkData* GatherPixelRefs(SkPicture* pict, const SkRect& area);
michael@0 30
michael@0 31 /**
michael@0 32 * SkPixelRefContainer provides a base class for more elaborate pixel ref
michael@0 33 * query structures (e.g., rtrees, quad-trees, etc.)
michael@0 34 */
michael@0 35 class SkPixelRefContainer : public SkRefCnt {
michael@0 36 public:
michael@0 37 virtual void add(SkPixelRef* pr, const SkRect& rect) = 0;
michael@0 38
michael@0 39 // The returned array may contain duplicates
michael@0 40 virtual void query(const SkRect& queryRect, SkTDArray<SkPixelRef*> *result) = 0;
michael@0 41
michael@0 42 private:
michael@0 43 typedef SkRefCnt INHERITED;
michael@0 44 };
michael@0 45
michael@0 46 // Simple query structure that just stores a linked list of pixel refs
michael@0 47 // and rects.
michael@0 48 class SkPixelRefsAndRectsList : public SkPixelRefContainer {
michael@0 49 public:
michael@0 50 virtual void add(SkPixelRef* pr, const SkRect& rect) SK_OVERRIDE {
michael@0 51 PixelRefAndRect *dst = fArray.append();
michael@0 52
michael@0 53 dst->fPixelRef = pr;
michael@0 54 dst->fRect = rect;
michael@0 55 }
michael@0 56
michael@0 57 virtual void query(const SkRect& queryRect, SkTDArray<SkPixelRef*> *result) SK_OVERRIDE {
michael@0 58 for (int i = 0; i < fArray.count(); ++i) {
michael@0 59 if (SkRect::Intersects(fArray[i].fRect, queryRect)) {
michael@0 60 *result->append() = fArray[i].fPixelRef;
michael@0 61 }
michael@0 62 }
michael@0 63 }
michael@0 64
michael@0 65 private:
michael@0 66 struct PixelRefAndRect {
michael@0 67 SkPixelRef* fPixelRef;
michael@0 68 SkRect fRect;
michael@0 69 };
michael@0 70
michael@0 71 SkTDArray<PixelRefAndRect> fArray;
michael@0 72
michael@0 73 typedef SkPixelRefContainer INHERITED;
michael@0 74 };
michael@0 75
michael@0 76 /**
michael@0 77 * Fill the provided pixel ref container with the picture's pixel ref
michael@0 78 * and rect information.
michael@0 79 */
michael@0 80 static void GatherPixelRefsAndRects(SkPicture* pict, SkPixelRefContainer* prCont);
michael@0 81 };
michael@0 82
michael@0 83 #endif

mercurial