OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "SkRTree.h" | 8 #include "SkRTree.h" |
9 #include "SkTSort.h" | 9 #include "SkTSort.h" |
10 | 10 |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 branches->setCount(newBranches); | 399 branches->setCount(newBranches); |
400 return this->bulkLoad(branches, level + 1); | 400 return this->bulkLoad(branches, level + 1); |
401 } | 401 } |
402 } | 402 } |
403 | 403 |
404 void SkRTree::validate() { | 404 void SkRTree::validate() { |
405 #ifdef SK_DEBUG | 405 #ifdef SK_DEBUG |
406 if (this->isEmpty()) { | 406 if (this->isEmpty()) { |
407 return; | 407 return; |
408 } | 408 } |
409 SkASSERT(fCount == (size_t)this->validateSubtree(fRoot.fChild.subtree, fRoot
.fBounds, true)); | 409 SkASSERT(fCount == this->validateSubtree(fRoot.fChild.subtree, fRoot.fBounds
, true)); |
410 #endif | 410 #endif |
411 } | 411 } |
412 | 412 |
413 int SkRTree::validateSubtree(Node* root, SkIRect bounds, bool isRoot) { | 413 int SkRTree::validateSubtree(Node* root, SkIRect bounds, bool isRoot) { |
414 // make sure the pointer is pointing to a valid place | 414 // make sure the pointer is pointing to a valid place |
415 SkASSERT(fNodes.contains(static_cast<void*>(root))); | 415 SkASSERT(fNodes.contains(static_cast<void*>(root))); |
416 | 416 |
417 if (isRoot) { | 417 if (isRoot) { |
418 // If the root of this subtree is the overall root, we have looser stand
ards: | 418 // If the root of this subtree is the overall root, we have looser stand
ards: |
419 if (root->isLeaf()) { | 419 if (root->isLeaf()) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 475 |
476 // Expand 'out' to include 'joinWith' | 476 // Expand 'out' to include 'joinWith' |
477 static inline void join_no_empty_check(const SkIRect& joinWith, SkIRect* out) { | 477 static inline void join_no_empty_check(const SkIRect& joinWith, SkIRect* out) { |
478 // since we check for empty bounds on insert, we know we'll never have empty
rects | 478 // since we check for empty bounds on insert, we know we'll never have empty
rects |
479 // and we can save the empty check that SkIRect::join requires | 479 // and we can save the empty check that SkIRect::join requires |
480 if (joinWith.fLeft < out->fLeft) { out->fLeft = joinWith.fLeft; } | 480 if (joinWith.fLeft < out->fLeft) { out->fLeft = joinWith.fLeft; } |
481 if (joinWith.fTop < out->fTop) { out->fTop = joinWith.fTop; } | 481 if (joinWith.fTop < out->fTop) { out->fTop = joinWith.fTop; } |
482 if (joinWith.fRight > out->fRight) { out->fRight = joinWith.fRight; } | 482 if (joinWith.fRight > out->fRight) { out->fRight = joinWith.fRight; } |
483 if (joinWith.fBottom > out->fBottom) { out->fBottom = joinWith.fBottom; } | 483 if (joinWith.fBottom > out->fBottom) { out->fBottom = joinWith.fBottom; } |
484 } | 484 } |
OLD | NEW |