| 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 |
| 11 static inline uint32_t get_area(const SkIRect& rect); | 11 static inline uint32_t get_area(const SkIRect& rect); |
| 12 static inline uint32_t get_overlap(const SkIRect& rect1, const SkIRect& rect2); | 12 static inline uint32_t get_overlap(const SkIRect& rect1, const SkIRect& rect2); |
| 13 static inline uint32_t get_margin(const SkIRect& rect); | 13 static inline uint32_t get_margin(const SkIRect& rect); |
| 14 static inline uint32_t get_area_increase(const SkIRect& rect1, SkIRect rect2); | 14 static inline uint32_t get_area_increase(const SkIRect& rect1, SkIRect rect2); |
| 15 static inline void join_no_empty_check(const SkIRect& joinWith, SkIRect* out); | 15 static inline void join_no_empty_check(const SkIRect& joinWith, SkIRect* out); |
| 16 | 16 |
| 17 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 17 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 18 | 18 |
| 19 SK_DEFINE_INST_COUNT(SkRTree) | |
| 20 | |
| 21 SkRTree* SkRTree::Create(int minChildren, int maxChildren, SkScalar aspectRatio, | 19 SkRTree* SkRTree::Create(int minChildren, int maxChildren, SkScalar aspectRatio, |
| 22 bool sortWhenBulkLoading) { | 20 bool sortWhenBulkLoading) { |
| 23 if (minChildren < maxChildren && (maxChildren + 1) / 2 >= minChildren && | 21 if (minChildren < maxChildren && (maxChildren + 1) / 2 >= minChildren && |
| 24 minChildren > 0 && maxChildren < static_cast<int>(SK_MaxU16)) { | 22 minChildren > 0 && maxChildren < static_cast<int>(SK_MaxU16)) { |
| 25 return new SkRTree(minChildren, maxChildren, aspectRatio, sortWhenBulkLo
ading); | 23 return new SkRTree(minChildren, maxChildren, aspectRatio, sortWhenBulkLo
ading); |
| 26 } | 24 } |
| 27 return NULL; | 25 return NULL; |
| 28 } | 26 } |
| 29 | 27 |
| 30 SkRTree::SkRTree(int minChildren, int maxChildren, SkScalar aspectRatio, | 28 SkRTree::SkRTree(int minChildren, int maxChildren, SkScalar aspectRatio, |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 473 |
| 476 // Expand 'out' to include 'joinWith' | 474 // Expand 'out' to include 'joinWith' |
| 477 static inline void join_no_empty_check(const SkIRect& joinWith, SkIRect* out) { | 475 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 | 476 // 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 | 477 // and we can save the empty check that SkIRect::join requires |
| 480 if (joinWith.fLeft < out->fLeft) { out->fLeft = joinWith.fLeft; } | 478 if (joinWith.fLeft < out->fLeft) { out->fLeft = joinWith.fLeft; } |
| 481 if (joinWith.fTop < out->fTop) { out->fTop = joinWith.fTop; } | 479 if (joinWith.fTop < out->fTop) { out->fTop = joinWith.fTop; } |
| 482 if (joinWith.fRight > out->fRight) { out->fRight = joinWith.fRight; } | 480 if (joinWith.fRight > out->fRight) { out->fRight = joinWith.fRight; } |
| 483 if (joinWith.fBottom > out->fBottom) { out->fBottom = joinWith.fBottom; } | 481 if (joinWith.fBottom > out->fBottom) { out->fBottom = joinWith.fBottom; } |
| 484 } | 482 } |
| OLD | NEW |