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

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: Move to SkPictureUtils, start unit test Created 6 years, 4 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
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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 440 }
441 441
442 void SkRTree::rewindInserts() { 442 void SkRTree::rewindInserts() {
443 SkASSERT(this->isEmpty()); // Currently only supports deferred inserts 443 SkASSERT(this->isEmpty()); // Currently only supports deferred inserts
444 while (!fDeferredInserts.isEmpty() && 444 while (!fDeferredInserts.isEmpty() &&
445 fClient->shouldRewind(fDeferredInserts.top().fChild.data)) { 445 fClient->shouldRewind(fDeferredInserts.top().fChild.data)) {
446 fDeferredInserts.pop(); 446 fDeferredInserts.pop();
447 } 447 }
448 } 448 }
449 449
450 size_t SkRTree::bytesUsed() const {
451 size_t byteCount = sizeof(SkRTree);
452
453 byteCount += fNodes.totalCapacity();
454 byteCount += fDeferredInserts.reserved() * sizeof(Branch);
mtklein 2014/11/17 20:19:32 There probably isn't an fDeferredInserts any more.
455
456 return byteCount;
457 }
458
450 //////////////////////////////////////////////////////////////////////////////// /////////////////// 459 //////////////////////////////////////////////////////////////////////////////// ///////////////////
451 460
452 static inline uint32_t get_area(const SkIRect& rect) { 461 static inline uint32_t get_area(const SkIRect& rect) {
453 return rect.width() * rect.height(); 462 return rect.width() * rect.height();
454 } 463 }
455 464
456 static inline uint32_t get_overlap(const SkIRect& rect1, const SkIRect& rect2) { 465 static inline uint32_t get_overlap(const SkIRect& rect1, const SkIRect& rect2) {
457 // I suspect there's a more efficient way of computing this... 466 // I suspect there's a more efficient way of computing this...
458 return SkMax32(0, SkMin32(rect1.fRight, rect2.fRight) - SkMax32(rect1.fLeft, rect2.fLeft)) * 467 return SkMax32(0, SkMin32(rect1.fRight, rect2.fRight) - SkMax32(rect1.fLeft, rect2.fLeft)) *
459 SkMax32(0, SkMin32(rect1.fBottom, rect2.fBottom) - SkMax32(rect1.fTop , rect2.fTop)); 468 SkMax32(0, SkMin32(rect1.fBottom, rect2.fBottom) - SkMax32(rect1.fTop , rect2.fTop));
(...skipping 11 matching lines...) Expand all
471 480
472 // Expand 'out' to include 'joinWith' 481 // Expand 'out' to include 'joinWith'
473 static inline void join_no_empty_check(const SkIRect& joinWith, SkIRect* out) { 482 static inline void join_no_empty_check(const SkIRect& joinWith, SkIRect* out) {
474 // since we check for empty bounds on insert, we know we'll never have empty rects 483 // since we check for empty bounds on insert, we know we'll never have empty rects
475 // and we can save the empty check that SkIRect::join requires 484 // and we can save the empty check that SkIRect::join requires
476 if (joinWith.fLeft < out->fLeft) { out->fLeft = joinWith.fLeft; } 485 if (joinWith.fLeft < out->fLeft) { out->fLeft = joinWith.fLeft; }
477 if (joinWith.fTop < out->fTop) { out->fTop = joinWith.fTop; } 486 if (joinWith.fTop < out->fTop) { out->fTop = joinWith.fTop; }
478 if (joinWith.fRight > out->fRight) { out->fRight = joinWith.fRight; } 487 if (joinWith.fRight > out->fRight) { out->fRight = joinWith.fRight; }
479 if (joinWith.fBottom > out->fBottom) { out->fBottom = joinWith.fBottom; } 488 if (joinWith.fBottom > out->fBottom) { out->fBottom = joinWith.fBottom; }
480 } 489 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698