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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 int childCount = 0; | 410 int childCount = 0; |
411 for (int i = 0; i < root->fNumChildren; ++i) { | 411 for (int i = 0; i < root->fNumChildren; ++i) { |
412 SkASSERT(root->child(i)->fChild.subtree->fLevel == root->fLevel - 1)
; | 412 SkASSERT(root->child(i)->fChild.subtree->fLevel == root->fLevel - 1)
; |
413 childCount += this->validateSubtree(root->child(i)->fChild.subtree, | 413 childCount += this->validateSubtree(root->child(i)->fChild.subtree, |
414 root->child(i)->fBounds); | 414 root->child(i)->fBounds); |
415 } | 415 } |
416 return childCount; | 416 return childCount; |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
| 420 size_t SkRTree::bytesUsed() const { |
| 421 size_t byteCount = sizeof(SkRTree); |
| 422 |
| 423 byteCount += fNodes.totalCapacity(); |
| 424 |
| 425 return byteCount; |
| 426 } |
| 427 |
420 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 428 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
421 | 429 |
422 static inline uint32_t get_area(const SkIRect& rect) { | 430 static inline uint32_t get_area(const SkIRect& rect) { |
423 return rect.width() * rect.height(); | 431 return rect.width() * rect.height(); |
424 } | 432 } |
425 | 433 |
426 static inline uint32_t get_overlap(const SkIRect& rect1, const SkIRect& rect2) { | 434 static inline uint32_t get_overlap(const SkIRect& rect1, const SkIRect& rect2) { |
427 // I suspect there's a more efficient way of computing this... | 435 // I suspect there's a more efficient way of computing this... |
428 return SkMax32(0, SkMin32(rect1.fRight, rect2.fRight) - SkMax32(rect1.fLeft,
rect2.fLeft)) * | 436 return SkMax32(0, SkMin32(rect1.fRight, rect2.fRight) - SkMax32(rect1.fLeft,
rect2.fLeft)) * |
429 SkMax32(0, SkMin32(rect1.fBottom, rect2.fBottom) - SkMax32(rect1.fTop
, rect2.fTop)); | 437 SkMax32(0, SkMin32(rect1.fBottom, rect2.fBottom) - SkMax32(rect1.fTop
, rect2.fTop)); |
(...skipping 11 matching lines...) Expand all Loading... |
441 | 449 |
442 // Expand 'out' to include 'joinWith' | 450 // Expand 'out' to include 'joinWith' |
443 static inline void join_no_empty_check(const SkIRect& joinWith, SkIRect* out) { | 451 static inline void join_no_empty_check(const SkIRect& joinWith, SkIRect* out) { |
444 // since we check for empty bounds on insert, we know we'll never have empty
rects | 452 // since we check for empty bounds on insert, we know we'll never have empty
rects |
445 // and we can save the empty check that SkIRect::join requires | 453 // and we can save the empty check that SkIRect::join requires |
446 if (joinWith.fLeft < out->fLeft) { out->fLeft = joinWith.fLeft; } | 454 if (joinWith.fLeft < out->fLeft) { out->fLeft = joinWith.fLeft; } |
447 if (joinWith.fTop < out->fTop) { out->fTop = joinWith.fTop; } | 455 if (joinWith.fTop < out->fTop) { out->fTop = joinWith.fTop; } |
448 if (joinWith.fRight > out->fRight) { out->fRight = joinWith.fRight; } | 456 if (joinWith.fRight > out->fRight) { out->fRight = joinWith.fRight; } |
449 if (joinWith.fBottom > out->fBottom) { out->fBottom = joinWith.fBottom; } | 457 if (joinWith.fBottom > out->fBottom) { out->fBottom = joinWith.fBottom; } |
450 } | 458 } |
OLD | NEW |