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

Side by Side Diff: src/core/SkQuadTree.h

Issue 196383026: Slightly faster quadtree searching (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use U8CPU for intersection bitmask Created 6 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkQuadTree.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkQuadTree_DEFINED 8 #ifndef SkQuadTree_DEFINED
9 #define SkQuadTree_DEFINED 9 #define SkQuadTree_DEFINED
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 virtual void clear() SK_OVERRIDE; 59 virtual void clear() SK_OVERRIDE;
60 60
61 /** 61 /**
62 * Gets the depth of the tree structure 62 * Gets the depth of the tree structure
63 */ 63 */
64 virtual int getDepth() const SK_OVERRIDE; 64 virtual int getDepth() const SK_OVERRIDE;
65 65
66 /** 66 /**
67 * This gets the insertion count (rather than the node count) 67 * This gets the insertion count (rather than the node count)
68 */ 68 */
69 virtual int getCount() const SK_OVERRIDE { return fEntryCount; } 69 virtual int getCount() const SK_OVERRIDE {
70 return fEntryPool.allocated() - fEntryPool.available();
71 }
70 72
71 virtual void rewindInserts() SK_OVERRIDE; 73 virtual void rewindInserts() SK_OVERRIDE;
72 74
73 private: 75 private:
74 struct Entry { 76 struct Entry {
75 Entry() : fData(NULL) {} 77 Entry() : fData(NULL) {}
76 SkIRect fBounds; 78 SkIRect fBounds;
77 void* fData; 79 void* fData;
78 SK_DECLARE_INTERNAL_SLIST_INTERFACE(Entry); 80 SK_DECLARE_INTERNAL_SLIST_INTERFACE(Entry);
79 }; 81 };
80 82
81 static const int kChildCount = 4; 83 static const int kChildCount = 4;
82 84
83 struct Node { 85 struct Node {
84 Node() { 86 Node() {
85 for (int index=0; index<kChildCount; ++index) { 87 for (int index=0; index<kChildCount; ++index) {
86 fChildren[index] = NULL; 88 fChildren[index] = NULL;
87 } 89 }
88 } 90 }
89 SkTInternalSList<Entry> fEntries; 91 SkTInternalSList<Entry> fEntries;
90 SkIRect fBounds; 92 SkIRect fBounds;
91 SkIPoint fSplitPoint; // Only valid if the node has children. 93 SkIPoint fSplitPoint; // Only valid if the node has children.
92 Node* fChildren[kChildCount]; 94 Node* fChildren[kChildCount];
93 SK_DECLARE_INTERNAL_SLIST_ADAPTER(Node, fChildren[0]); 95 SK_DECLARE_INTERNAL_SLIST_ADAPTER(Node, fChildren[0]);
94 }; 96 };
95 97
96 SkTObjectPool<Entry> fEntryPool; 98 SkTObjectPool<Entry> fEntryPool;
97 SkTObjectPool<Node> fNodePool; 99 SkTObjectPool<Node> fNodePool;
98 int fEntryCount;
99 Node* fRoot; 100 Node* fRoot;
101 SkIRect fRootBounds;
100 SkTInternalSList<Entry> fDeferred; 102 SkTInternalSList<Entry> fDeferred;
101 103
102 Node* pickChild(Node* node, const SkIRect& bounds) const;
103 void insert(Node* node, Entry* entry); 104 void insert(Node* node, Entry* entry);
105 void split(Node* node);
104 void search(Node* node, const SkIRect& query, SkTDArray<void*>* results) con st; 106 void search(Node* node, const SkIRect& query, SkTDArray<void*>* results) con st;
105 void clear(Node* node); 107 void clear(Node* node);
106 int getDepth(Node* node) const; 108 int getDepth(Node* node) const;
107 109
108 typedef SkBBoxHierarchy INHERITED; 110 typedef SkBBoxHierarchy INHERITED;
109 }; 111 };
110 112
111 #endif 113 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkQuadTree.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698