OLD | NEW |
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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 #endif | 449 #endif |
450 | 450 |
451 bool SkPicture::hasText() const { return fAnalysis.fHasText; } | 451 bool SkPicture::hasText() const { return fAnalysis.fHasText; } |
452 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm
aps; } | 452 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm
aps; } |
453 int SkPicture::approximateOpCount() const { return fRecord->count(); } | 453 int SkPicture::approximateOpCount() const { return fRecord->count(); } |
454 | 454 |
455 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr
awablePicts, | 455 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr
awablePicts, |
456 SkBBoxHierarchy* bbh, size_t approxBytesUsedBySubPictures) | 456 SkBBoxHierarchy* bbh, size_t approxBytesUsedBySubPictures) |
457 : fUniqueID(0) | 457 : fUniqueID(0) |
458 , fCullRect(cullRect) | 458 , fCullRect(cullRect) |
459 , fRecord(SkRef(record)) | 459 , fRecord(record) // For performance, we take ownership of the caller's re
f. |
460 , fBBH(SkSafeRef(bbh)) | 460 , fBBH(bbh) // Ditto. |
461 , fDrawablePicts(drawablePicts) // take ownership | 461 , fDrawablePicts(drawablePicts) // take ownership |
462 , fApproxBytesUsedBySubPictures(approxBytesUsedBySubPictures) | 462 , fApproxBytesUsedBySubPictures(approxBytesUsedBySubPictures) |
463 , fAnalysis(*fRecord) | 463 , fAnalysis(*fRecord) |
464 {} | 464 {} |
465 | 465 |
466 | 466 |
467 static uint32_t gNextID = 1; | 467 static uint32_t gNextID = 1; |
468 uint32_t SkPicture::uniqueID() const { | 468 uint32_t SkPicture::uniqueID() const { |
469 uint32_t id = sk_atomic_load(&fUniqueID, sk_memory_order_relaxed); | 469 uint32_t id = sk_atomic_load(&fUniqueID, sk_memory_order_relaxed); |
470 while (id == 0) { | 470 while (id == 0) { |
471 uint32_t next = sk_atomic_fetch_add(&gNextID, 1u); | 471 uint32_t next = sk_atomic_fetch_add(&gNextID, 1u); |
472 if (sk_atomic_compare_exchange(&fUniqueID, &id, next, | 472 if (sk_atomic_compare_exchange(&fUniqueID, &id, next, |
473 sk_memory_order_relaxed, | 473 sk_memory_order_relaxed, |
474 sk_memory_order_relaxed)) { | 474 sk_memory_order_relaxed)) { |
475 id = next; | 475 id = next; |
476 } else { | 476 } else { |
477 // sk_atomic_compare_exchange replaced id with the current value of
fUniqueID. | 477 // sk_atomic_compare_exchange replaced id with the current value of
fUniqueID. |
478 } | 478 } |
479 } | 479 } |
480 return id; | 480 return id; |
481 } | 481 } |
OLD | NEW |