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

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

Issue 1112833003: Straighten out SkPicture::AccelData APIs. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 SkPicture::~SkPicture() { 234 SkPicture::~SkPicture() {
235 // If the ID is still zero, no one has read it, so no need to send this mess age. 235 // If the ID is still zero, no one has read it, so no need to send this mess age.
236 uint32_t id = sk_atomic_load(&fUniqueID, sk_memory_order_relaxed); 236 uint32_t id = sk_atomic_load(&fUniqueID, sk_memory_order_relaxed);
237 if (id != 0) { 237 if (id != 0) {
238 SkPicture::DeletionMessage msg; 238 SkPicture::DeletionMessage msg;
239 msg.fUniqueID = id; 239 msg.fUniqueID = id;
240 SkMessageBus<SkPicture::DeletionMessage>::Post(msg); 240 SkMessageBus<SkPicture::DeletionMessage>::Post(msg);
241 } 241 }
242 } 242 }
243 243
244 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons t {
245 fAccelData.reset(SkRef(data));
246 }
247
248 const SkPicture::AccelData* SkPicture::EXPERIMENTAL_getAccelData( 244 const SkPicture::AccelData* SkPicture::EXPERIMENTAL_getAccelData(
249 SkPicture::AccelData::Key key) const { 245 SkPicture::AccelData::Key key) const {
250 if (fAccelData.get() && fAccelData->getKey() == key) { 246 if (fAccelData.get() && fAccelData->getKey() == key) {
251 return fAccelData.get(); 247 return fAccelData.get();
252 } 248 }
253 return NULL; 249 return NULL;
254 } 250 }
255 251
256 SkPicture::AccelData::Domain SkPicture::AccelData::GenerateDomain() { 252 SkPicture::AccelData::Domain SkPicture::AccelData::GenerateDomain() {
257 static int32_t gNextID = 0; 253 static int32_t gNextID = 0;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 #if SK_SUPPORT_GPU 441 #if SK_SUPPORT_GPU
446 bool SkPicture::suitableForGpuRasterization(GrContext*, const char **reason) con st { 442 bool SkPicture::suitableForGpuRasterization(GrContext*, const char **reason) con st {
447 return fAnalysis.suitableForGpuRasterization(reason, 0); 443 return fAnalysis.suitableForGpuRasterization(reason, 0);
448 } 444 }
449 #endif 445 #endif
450 446
451 bool SkPicture::hasText() const { return fAnalysis.fHasText; } 447 bool SkPicture::hasText() const { return fAnalysis.fHasText; }
452 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm aps; } 448 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm aps; }
453 int SkPicture::approximateOpCount() const { return fRecord->count(); } 449 int SkPicture::approximateOpCount() const { return fRecord->count(); }
454 450
455 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr awablePicts, 451 SkPicture::SkPicture(const SkRect& cullRect,
456 SkBBoxHierarchy* bbh, size_t approxBytesUsedBySubPictures) 452 SkRecord* record,
453 SnapshotArray* drawablePicts,
454 SkBBoxHierarchy* bbh,
455 AccelData* accelData,
456 size_t approxBytesUsedBySubPictures)
457 : fUniqueID(0) 457 : fUniqueID(0)
458 , fCullRect(cullRect) 458 , fCullRect(cullRect)
459 , fRecord(record) // For performance, we take ownership of the caller's re f. 459 , fRecord(record) // Take ownership of caller's ref.
460 , fBBH(bbh) // Ditto. 460 , fDrawablePicts(drawablePicts) // Take ownership.
461 , fDrawablePicts(drawablePicts) // take ownership 461 , fBBH(bbh) // Take ownership of caller's ref.
462 , fAccelData(accelData) // Take ownership of caller's ref.
462 , fApproxBytesUsedBySubPictures(approxBytesUsedBySubPictures) 463 , fApproxBytesUsedBySubPictures(approxBytesUsedBySubPictures)
463 , fAnalysis(*fRecord) 464 , fAnalysis(*fRecord)
464 {} 465 {}
465 466
466 467
467 static uint32_t gNextID = 1; 468 static uint32_t gNextID = 1;
468 uint32_t SkPicture::uniqueID() const { 469 uint32_t SkPicture::uniqueID() const {
469 uint32_t id = sk_atomic_load(&fUniqueID, sk_memory_order_relaxed); 470 uint32_t id = sk_atomic_load(&fUniqueID, sk_memory_order_relaxed);
470 while (id == 0) { 471 while (id == 0) {
471 uint32_t next = sk_atomic_fetch_add(&gNextID, 1u); 472 uint32_t next = sk_atomic_fetch_add(&gNextID, 1u);
472 if (sk_atomic_compare_exchange(&fUniqueID, &id, next, 473 if (sk_atomic_compare_exchange(&fUniqueID, &id, next,
473 sk_memory_order_relaxed, 474 sk_memory_order_relaxed,
474 sk_memory_order_relaxed)) { 475 sk_memory_order_relaxed)) {
475 id = next; 476 id = next;
476 } else { 477 } else {
477 // sk_atomic_compare_exchange replaced id with the current value of fUniqueID. 478 // sk_atomic_compare_exchange replaced id with the current value of fUniqueID.
478 } 479 }
479 } 480 }
480 return id; 481 return id;
481 } 482 }
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