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

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

Issue 23480002: R-Tree -- Don't sort draw commands unless specified. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/core/SkRTree.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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef SkRTree_DEFINED 9 #ifndef SkRTree_DEFINED
10 #define SkRTree_DEFINED 10 #define SkRTree_DEFINED
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 /** 47 /**
48 * Create a new R-Tree with specified min/max child counts. 48 * Create a new R-Tree with specified min/max child counts.
49 * The child counts are valid iff: 49 * The child counts are valid iff:
50 * - (max + 1) / 2 >= min (splitting an overfull node must be enough to popu late 2 nodes) 50 * - (max + 1) / 2 >= min (splitting an overfull node must be enough to popu late 2 nodes)
51 * - min < max 51 * - min < max
52 * - min > 0 52 * - min > 0
53 * - max < SK_MaxU16 53 * - max < SK_MaxU16
54 * If you have some prior information about the distribution of bounds you'r e expecting, you 54 * If you have some prior information about the distribution of bounds you'r e expecting, you
55 * can provide an optional aspect ratio parameter. This allows the bulk-load algorithm to create 55 * can provide an optional aspect ratio parameter. This allows the bulk-load algorithm to create
56 * better proportioned tiles of rectangles. 56 * better proportioned tiles of rectangles.
57 * You can make the build loading algorithm avoid the sorting step by settin g
58 * orderWhenBulkLoading to false. It will have a small impact on playback pe rformance for
59 * inputs where consecutive boxes are close to each other. It will do much w orse if the inputs
60 * are positioned randomly.
57 */ 61 */
58 static SkRTree* Create(int minChildren, int maxChildren, SkScalar aspectRati o = 1); 62 static SkRTree* Create(int minChildren, int maxChildren, SkScalar aspectRati o = 1,
63 bool orderWhenBulkLoading = true);
59 virtual ~SkRTree(); 64 virtual ~SkRTree();
60 65
61 /** 66 /**
62 * Insert a node, consisting of bounds and a data value into the tree, if we don't immediately 67 * Insert a node, consisting of bounds and a data value into the tree, if we don't immediately
63 * need to use the tree; we may allow the insert to be deferred (this can al low us to bulk-load 68 * need to use the tree; we may allow the insert to be deferred (this can al low us to bulk-load
64 * a large batch of nodes at once, which tends to be faster and produce a be tter tree). 69 * a large batch of nodes at once, which tends to be faster and produce a be tter tree).
65 * @param data The data value 70 * @param data The data value
66 * @param bounds The corresponding bounding box 71 * @param bounds The corresponding bounding box
67 * @param defer Can this insert be deferred? (this may be ignored) 72 * @param defer Can this insert be deferred? (this may be ignored)
68 */ 73 */
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 142 }
138 }; 143 };
139 144
140 struct RectLessY { 145 struct RectLessY {
141 bool operator()(const SkRTree::Branch lhs, const SkRTree::Branch rhs) { 146 bool operator()(const SkRTree::Branch lhs, const SkRTree::Branch rhs) {
142 return ((lhs.fBounds.fBottom - lhs.fBounds.fTop) >> 1) < 147 return ((lhs.fBounds.fBottom - lhs.fBounds.fTop) >> 1) <
143 ((rhs.fBounds.fBottom - lhs.fBounds.fTop) >> 1); 148 ((rhs.fBounds.fBottom - lhs.fBounds.fTop) >> 1);
144 } 149 }
145 }; 150 };
146 151
147 SkRTree(int minChildren, int maxChildren, SkScalar aspectRatio); 152 SkRTree(int minChildren, int maxChildren, SkScalar aspectRatio, bool orderWh enBulkLoading);
148 153
149 /** 154 /**
150 * Recursively descend the tree to find an insertion position for 'branch', updates 155 * Recursively descend the tree to find an insertion position for 'branch', updates
151 * bounding boxes on the way up. 156 * bounding boxes on the way up.
152 */ 157 */
153 Branch* insert(Node* root, Branch* branch, uint16_t level = 0); 158 Branch* insert(Node* root, Branch* branch, uint16_t level = 0);
154 159
155 int chooseSubtree(Node* root, Branch* branch); 160 int chooseSubtree(Node* root, Branch* branch);
156 SkIRect computeBounds(Node* n); 161 SkIRect computeBounds(Node* n);
157 int distributeChildren(Branch* children); 162 int distributeChildren(Branch* children);
(...skipping 19 matching lines...) Expand all
177 const int fMaxChildren; 182 const int fMaxChildren;
178 const size_t fNodeSize; 183 const size_t fNodeSize;
179 184
180 // This is the count of data elements (rather than total nodes in the tree) 185 // This is the count of data elements (rather than total nodes in the tree)
181 size_t fCount; 186 size_t fCount;
182 187
183 Branch fRoot; 188 Branch fRoot;
184 SkChunkAlloc fNodes; 189 SkChunkAlloc fNodes;
185 SkTDArray<Branch> fDeferredInserts; 190 SkTDArray<Branch> fDeferredInserts;
186 SkScalar fAspectRatio; 191 SkScalar fAspectRatio;
192 bool fSortWhenBulkLoading;
187 193
188 Node* allocateNode(uint16_t level); 194 Node* allocateNode(uint16_t level);
189 195
190 typedef SkBBoxHierarchy INHERITED; 196 typedef SkBBoxHierarchy INHERITED;
191 }; 197 };
192 198
193 #endif 199 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/core/SkRTree.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698