gfx/skia/trunk/src/core/SkPathHeap.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 /*
michael@0 3 * Copyright 2011 Google Inc.
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8 #ifndef SkPathHeap_DEFINED
michael@0 9 #define SkPathHeap_DEFINED
michael@0 10
michael@0 11 #include "SkRefCnt.h"
michael@0 12 #include "SkChunkAlloc.h"
michael@0 13 #include "SkTDArray.h"
michael@0 14
michael@0 15 class SkPath;
michael@0 16 class SkReadBuffer;
michael@0 17 class SkWriteBuffer;
michael@0 18
michael@0 19 class SkPathHeap : public SkRefCnt {
michael@0 20 public:
michael@0 21 SK_DECLARE_INST_COUNT(SkPathHeap)
michael@0 22
michael@0 23 SkPathHeap();
michael@0 24 SkPathHeap(SkReadBuffer&);
michael@0 25 virtual ~SkPathHeap();
michael@0 26
michael@0 27 /** Copy the path into the heap, and return the new total number of paths.
michael@0 28 Thus, the returned value will be index+1, where index is the index of
michael@0 29 this newly added (copied) path.
michael@0 30 */
michael@0 31 int append(const SkPath&);
michael@0 32
michael@0 33 /** Add the specified path to the heap using its gen ID to de-duplicate.
michael@0 34 Returns the path's index in the heap + 1.
michael@0 35 */
michael@0 36 int insert(const SkPath&);
michael@0 37
michael@0 38 // called during picture-playback
michael@0 39 int count() const { return fPaths.count(); }
michael@0 40 const SkPath& operator[](int index) const {
michael@0 41 return *fPaths[index];
michael@0 42 }
michael@0 43
michael@0 44 void flatten(SkWriteBuffer&) const;
michael@0 45
michael@0 46 private:
michael@0 47 // we store the paths in the heap (placement new)
michael@0 48 SkChunkAlloc fHeap;
michael@0 49 // we just store ptrs into fHeap here
michael@0 50 SkTDArray<SkPath*> fPaths;
michael@0 51
michael@0 52 class LookupEntry {
michael@0 53 public:
michael@0 54 LookupEntry(const SkPath& path);
michael@0 55
michael@0 56 int storageSlot() const { return fStorageSlot; }
michael@0 57 void setStorageSlot(int storageSlot) { fStorageSlot = storageSlot; }
michael@0 58
michael@0 59 static bool Less(const LookupEntry& a, const LookupEntry& b) {
michael@0 60 return a.fGenerationID < b.fGenerationID;
michael@0 61 }
michael@0 62
michael@0 63 private:
michael@0 64 uint32_t fGenerationID; // the SkPath's generation ID
michael@0 65 // the path's index in the heap + 1. It is 0 if the path is not yet in the heap.
michael@0 66 int fStorageSlot;
michael@0 67 };
michael@0 68
michael@0 69 SkTDArray<LookupEntry> fLookupTable;
michael@0 70
michael@0 71 SkPathHeap::LookupEntry* addIfNotPresent(const SkPath& path);
michael@0 72
michael@0 73 typedef SkRefCnt INHERITED;
michael@0 74 };
michael@0 75
michael@0 76 #endif

mercurial