| 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" |
| 11 #include "SkPictureData.h" | 11 #include "SkPictureData.h" |
| 12 #include "SkPicturePlayback.h" | 12 #include "SkPicturePlayback.h" |
| 13 #include "SkPictureRecord.h" | 13 #include "SkPictureRecord.h" |
| 14 #include "SkPictureRecorder.h" | 14 #include "SkPictureRecorder.h" |
| 15 #include "SkPictureStateTree.h" | |
| 16 | 15 |
| 17 #include "SkBitmapDevice.h" | 16 #include "SkBitmapDevice.h" |
| 18 #include "SkCanvas.h" | 17 #include "SkCanvas.h" |
| 19 #include "SkChunkAlloc.h" | 18 #include "SkChunkAlloc.h" |
| 20 #include "SkDrawPictureCallback.h" | 19 #include "SkDrawPictureCallback.h" |
| 21 #include "SkPaintPriv.h" | 20 #include "SkPaintPriv.h" |
| 22 #include "SkPathEffect.h" | 21 #include "SkPathEffect.h" |
| 23 #include "SkPicture.h" | 22 #include "SkPicture.h" |
| 24 #include "SkRegion.h" | 23 #include "SkRegion.h" |
| 25 #include "SkShader.h" | 24 #include "SkShader.h" |
| 26 #include "SkStream.h" | 25 #include "SkStream.h" |
| 27 #include "SkTDArray.h" | 26 #include "SkTDArray.h" |
| 28 #include "SkTLogic.h" | 27 #include "SkTLogic.h" |
| 29 #include "SkTSearch.h" | 28 #include "SkTSearch.h" |
| 30 #include "SkTime.h" | 29 #include "SkTime.h" |
| 31 | 30 |
| 32 #include "SkReader32.h" | 31 #include "SkReader32.h" |
| 33 #include "SkWriter32.h" | 32 #include "SkWriter32.h" |
| 34 #include "SkRTree.h" | 33 #include "SkRTree.h" |
| 35 #include "SkBBoxHierarchyRecord.h" | |
| 36 | 34 |
| 37 #if SK_SUPPORT_GPU | 35 #if SK_SUPPORT_GPU |
| 38 #include "GrContext.h" | 36 #include "GrContext.h" |
| 39 #endif | 37 #endif |
| 40 | 38 |
| 41 #include "SkRecord.h" | 39 #include "SkRecord.h" |
| 42 #include "SkRecordDraw.h" | 40 #include "SkRecordDraw.h" |
| 43 #include "SkRecordOpts.h" | 41 #include "SkRecordOpts.h" |
| 44 #include "SkRecorder.h" | 42 #include "SkRecorder.h" |
| 45 | 43 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 int32_t id = sk_atomic_inc(&gNextID); | 298 int32_t id = sk_atomic_inc(&gNextID); |
| 301 if (id >= 1 << (8 * sizeof(Domain))) { | 299 if (id >= 1 << (8 * sizeof(Domain))) { |
| 302 SK_CRASH(); | 300 SK_CRASH(); |
| 303 } | 301 } |
| 304 | 302 |
| 305 return static_cast<Domain>(id); | 303 return static_cast<Domain>(id); |
| 306 } | 304 } |
| 307 | 305 |
| 308 /////////////////////////////////////////////////////////////////////////////// | 306 /////////////////////////////////////////////////////////////////////////////// |
| 309 | 307 |
| 310 uint32_t SkPicture::OperationList::offset(int index) const { | |
| 311 SkASSERT(index < fOps.count()); | |
| 312 return ((SkPictureStateTree::Draw*)fOps[index])->fOffset; | |
| 313 } | |
| 314 | |
| 315 const SkMatrix& SkPicture::OperationList::matrix(int index) const { | |
| 316 SkASSERT(index < fOps.count()); | |
| 317 return *((SkPictureStateTree::Draw*)fOps[index])->fMatrix; | |
| 318 } | |
| 319 | |
| 320 // fRecord OK | 308 // fRecord OK |
| 321 void SkPicture::playback(SkCanvas* canvas, SkDrawPictureCallback* callback) cons
t { | 309 void SkPicture::playback(SkCanvas* canvas, SkDrawPictureCallback* callback) cons
t { |
| 322 SkASSERT(canvas); | 310 SkASSERT(canvas); |
| 323 SkASSERT(fData.get() || fRecord.get()); | 311 SkASSERT(fData.get() || fRecord.get()); |
| 324 | 312 |
| 325 // If the query contains the whole picture, don't bother with the BBH. | |
| 326 SkRect clipBounds = { 0, 0, 0, 0 }; | |
| 327 (void)canvas->getClipBounds(&clipBounds); | |
| 328 const bool useBBH = !clipBounds.contains(this->cullRect()); | |
| 329 | |
| 330 if (fData.get()) { | 313 if (fData.get()) { |
| 331 SkPicturePlayback playback(this); | 314 SkPicturePlayback playback(this); |
| 332 playback.setUseBBH(useBBH); | |
| 333 playback.draw(canvas, callback); | 315 playback.draw(canvas, callback); |
| 334 } | 316 } |
| 335 if (fRecord.get()) { | 317 if (fRecord.get()) { |
| 318 // If the query contains the whole picture, don't bother with the BBH. |
| 319 SkRect clipBounds = { 0, 0, 0, 0 }; |
| 320 (void)canvas->getClipBounds(&clipBounds); |
| 321 const bool useBBH = !clipBounds.contains(this->cullRect()); |
| 322 |
| 336 SkRecordDraw(*fRecord, canvas, useBBH ? fBBH.get() : NULL, callback); | 323 SkRecordDraw(*fRecord, canvas, useBBH ? fBBH.get() : NULL, callback); |
| 337 } | 324 } |
| 338 } | 325 } |
| 339 | 326 |
| 340 /////////////////////////////////////////////////////////////////////////////// | 327 /////////////////////////////////////////////////////////////////////////////// |
| 341 | 328 |
| 342 #include "SkStream.h" | 329 #include "SkStream.h" |
| 343 | 330 |
| 344 static const char kMagic[] = { 's', 'k', 'i', 'a', 'p', 'i', 'c', 't' }; | 331 static const char kMagic[] = { 's', 'k', 'i', 'a', 'p', 'i', 'c', 't' }; |
| 345 | 332 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 int SkPicture::approximateOpCount() const { | 658 int SkPicture::approximateOpCount() const { |
| 672 SkASSERT(fRecord.get() || fData.get()); | 659 SkASSERT(fRecord.get() || fData.get()); |
| 673 if (fRecord.get()) { | 660 if (fRecord.get()) { |
| 674 return fRecord->count(); | 661 return fRecord->count(); |
| 675 } | 662 } |
| 676 if (fData.get()) { | 663 if (fData.get()) { |
| 677 return fData->opCount(); | 664 return fData->opCount(); |
| 678 } | 665 } |
| 679 return 0; | 666 return 0; |
| 680 } | 667 } |
| OLD | NEW |