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

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

Issue 490253003: Implement SkPicture::bytesUsed() for SkRecord backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Unit test prevents bloat Created 6 years, 1 month 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
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698