| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkPictureFlat.h" | 10 #include "SkPictureFlat.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 *reason = "Too many anti-aliased concave paths."; | 263 *reason = "Too many anti-aliased concave paths."; |
| 264 else | 264 else |
| 265 *reason = "Unknown reason for GPU unsuitability."; | 265 *reason = "Unknown reason for GPU unsuitability."; |
| 266 } | 266 } |
| 267 return ret; | 267 return ret; |
| 268 } | 268 } |
| 269 | 269 |
| 270 /////////////////////////////////////////////////////////////////////////////// | 270 /////////////////////////////////////////////////////////////////////////////// |
| 271 | 271 |
| 272 int SkPicture::drawableCount() const { | 272 int SkPicture::drawableCount() const { |
| 273 if (fDrawablePicts.get()) { | 273 return fDrawablePicts.get() ? fDrawablePicts->count() : 0; |
| 274 return SkToInt(fDrawablePicts->size() / sizeof(SkPicture*)); | |
| 275 } else { | |
| 276 return 0; | |
| 277 } | |
| 278 } | 274 } |
| 279 | 275 |
| 280 SkPicture const* const* SkPicture::drawablePicts() const { | 276 SkPicture const* const* SkPicture::drawablePicts() const { |
| 281 if (fDrawablePicts) { | 277 return fDrawablePicts.get() ? fDrawablePicts->begin() : NULL; |
| 282 return reinterpret_cast<SkPicture* const*>(fDrawablePicts->data()); | |
| 283 } | |
| 284 return NULL; | |
| 285 } | 278 } |
| 286 | 279 |
| 287 SkPicture::~SkPicture() { | 280 SkPicture::~SkPicture() { |
| 288 this->callDeletionListeners(); | 281 this->callDeletionListeners(); |
| 289 } | 282 } |
| 290 | 283 |
| 291 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons
t { | 284 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons
t { |
| 292 fAccelData.reset(SkRef(data)); | 285 fAccelData.reset(SkRef(data)); |
| 293 } | 286 } |
| 294 | 287 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 #if SK_SUPPORT_GPU | 510 #if SK_SUPPORT_GPU |
| 518 bool SkPicture::suitableForGpuRasterization(GrContext*, const char **reason) con
st { | 511 bool SkPicture::suitableForGpuRasterization(GrContext*, const char **reason) con
st { |
| 519 return fAnalysis.suitableForGpuRasterization(reason, 0); | 512 return fAnalysis.suitableForGpuRasterization(reason, 0); |
| 520 } | 513 } |
| 521 #endif | 514 #endif |
| 522 | 515 |
| 523 bool SkPicture::hasText() const { return fAnalysis.fHasText; } | 516 bool SkPicture::hasText() const { return fAnalysis.fHasText; } |
| 524 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm
aps; } | 517 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm
aps; } |
| 525 int SkPicture::approximateOpCount() const { return fRecord->count(); } | 518 int SkPicture::approximateOpCount() const { return fRecord->count(); } |
| 526 | 519 |
| 527 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SkData* drawableP
icts, | 520 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr
awablePicts, |
| 528 SkBBoxHierarchy* bbh) | 521 SkBBoxHierarchy* bbh) |
| 529 : fUniqueID(next_picture_generation_id()) | 522 : fUniqueID(next_picture_generation_id()) |
| 530 , fCullRect(cullRect) | 523 , fCullRect(cullRect) |
| 531 , fRecord(record) | 524 , fRecord(record) |
| 532 , fBBH(SkSafeRef(bbh)) | 525 , fBBH(SkSafeRef(bbh)) |
| 533 , fDrawablePicts(SkSafeRef(drawablePicts)) | 526 , fDrawablePicts(SkSafeRef(drawablePicts)) |
| 534 , fAnalysis(*fRecord) | 527 , fAnalysis(*fRecord) |
| 535 {} | 528 {} |
| 536 | 529 |
| 537 // Note that we are assuming that this entry point will only be called from | 530 // Note that we are assuming that this entry point will only be called from |
| 538 // one thread. Currently the only client of this method is | 531 // one thread. Currently the only client of this method is |
| 539 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single | 532 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single |
| 540 // thread. | 533 // thread. |
| 541 void SkPicture::addDeletionListener(DeletionListener* listener) const { | 534 void SkPicture::addDeletionListener(DeletionListener* listener) const { |
| 542 SkASSERT(listener); | 535 SkASSERT(listener); |
| 543 | 536 |
| 544 *fDeletionListeners.append() = SkRef(listener); | 537 *fDeletionListeners.append() = SkRef(listener); |
| 545 } | 538 } |
| 546 | 539 |
| 547 void SkPicture::callDeletionListeners() { | 540 void SkPicture::callDeletionListeners() { |
| 548 for (int i = 0; i < fDeletionListeners.count(); ++i) { | 541 for (int i = 0; i < fDeletionListeners.count(); ++i) { |
| 549 fDeletionListeners[i]->onDeletion(this->uniqueID()); | 542 fDeletionListeners[i]->onDeletion(this->uniqueID()); |
| 550 } | 543 } |
| 551 | 544 |
| 552 fDeletionListeners.unrefAll(); | 545 fDeletionListeners.unrefAll(); |
| 553 } | 546 } |
| OLD | NEW |