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

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

Issue 1090943004: O(1) SkPictureUtils::ApproxBytesUsed() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: const Created 5 years, 8 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
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2007 The Android Open Source Project 2 * Copyright 2007 The Android Open Source Project
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 8
9 #include "SkPictureFlat.h" 9 #include "SkPictureFlat.h"
10 #include "SkPictureData.h" 10 #include "SkPictureData.h"
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 bool SkPicture::suitableForGpuRasterization(GrContext*, const char **reason) con st { 473 bool SkPicture::suitableForGpuRasterization(GrContext*, const char **reason) con st {
474 return fAnalysis.suitableForGpuRasterization(reason, 0); 474 return fAnalysis.suitableForGpuRasterization(reason, 0);
475 } 475 }
476 #endif 476 #endif
477 477
478 bool SkPicture::hasText() const { return fAnalysis.fHasText; } 478 bool SkPicture::hasText() const { return fAnalysis.fHasText; }
479 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm aps; } 479 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm aps; }
480 int SkPicture::approximateOpCount() const { return fRecord->count(); } 480 int SkPicture::approximateOpCount() const { return fRecord->count(); }
481 481
482 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr awablePicts, 482 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr awablePicts,
483 SkBBoxHierarchy* bbh) 483 SkBBoxHierarchy* bbh, size_t approxBytesUsedBySubPictures)
484 : fUniqueID(0) 484 : fUniqueID(0)
485 , fCullRect(cullRect) 485 , fCullRect(cullRect)
486 , fRecord(SkRef(record)) 486 , fRecord(SkRef(record))
487 , fBBH(SkSafeRef(bbh)) 487 , fBBH(SkSafeRef(bbh))
488 , fDrawablePicts(drawablePicts) // take ownership 488 , fDrawablePicts(drawablePicts) // take ownership
489 , fApproxBytesUsedBySubPictures(approxBytesUsedBySubPictures)
489 , fAnalysis(*fRecord) 490 , fAnalysis(*fRecord)
490 {} 491 {}
491 492
492 493
493 static uint32_t gNextID = 1; 494 static uint32_t gNextID = 1;
494 uint32_t SkPicture::uniqueID() const { 495 uint32_t SkPicture::uniqueID() const {
495 uint32_t id = sk_atomic_load(&fUniqueID, sk_memory_order_relaxed); 496 uint32_t id = sk_atomic_load(&fUniqueID, sk_memory_order_relaxed);
496 while (id == 0) { 497 while (id == 0) {
497 uint32_t next = sk_atomic_fetch_add(&gNextID, 1u); 498 uint32_t next = sk_atomic_fetch_add(&gNextID, 1u);
498 if (sk_atomic_compare_exchange(&fUniqueID, &id, next, 499 if (sk_atomic_compare_exchange(&fUniqueID, &id, next,
499 sk_memory_order_relaxed, 500 sk_memory_order_relaxed,
500 sk_memory_order_relaxed)) { 501 sk_memory_order_relaxed)) {
501 id = next; 502 id = next;
502 } else { 503 } else {
503 // sk_atomic_compare_exchange replaced id with the current value of fUniqueID. 504 // sk_atomic_compare_exchange replaced id with the current value of fUniqueID.
504 } 505 }
505 } 506 }
506 return id; 507 return id;
507 } 508 }
OLDNEW
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698