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 22 matching lines...) Expand all Loading... |
33 #include "SkWriter32.h" | 33 #include "SkWriter32.h" |
34 #include "SkRTree.h" | 34 #include "SkRTree.h" |
35 #include "SkBBoxHierarchyRecord.h" | 35 #include "SkBBoxHierarchyRecord.h" |
36 | 36 |
37 #if SK_SUPPORT_GPU | 37 #if SK_SUPPORT_GPU |
38 #include "GrContext.h" | 38 #include "GrContext.h" |
39 #endif | 39 #endif |
40 | 40 |
41 #include "SkRecord.h" | 41 #include "SkRecord.h" |
42 #include "SkRecordDraw.h" | 42 #include "SkRecordDraw.h" |
| 43 #include "SkRecordOpts.h" |
43 #include "SkRecorder.h" | 44 #include "SkRecorder.h" |
44 | 45 |
45 template <typename T> int SafeCount(const T* obj) { | 46 template <typename T> int SafeCount(const T* obj) { |
46 return obj ? obj->count() : 0; | 47 return obj ? obj->count() : 0; |
47 } | 48 } |
48 | 49 |
49 /////////////////////////////////////////////////////////////////////////////// | 50 /////////////////////////////////////////////////////////////////////////////// |
50 | 51 |
51 namespace { | 52 namespace { |
52 | 53 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 SkPictInfo info; | 265 SkPictInfo info; |
265 this->createHeader(&info); | 266 this->createHeader(&info); |
266 fData.reset(SkNEW_ARGS(SkPictureData, (record, info, deepCopyOps))); | 267 fData.reset(SkNEW_ARGS(SkPictureData, (record, info, deepCopyOps))); |
267 } | 268 } |
268 | 269 |
269 // Create an SkPictureData-backed SkPicture from an SkRecord. | 270 // Create an SkPictureData-backed SkPicture from an SkRecord. |
270 // This for compatibility with serialization code only. This is not cheap. | 271 // This for compatibility with serialization code only. This is not cheap. |
271 static SkPicture* backport(const SkRecord& src, const SkRect& cullRect) { | 272 static SkPicture* backport(const SkRecord& src, const SkRect& cullRect) { |
272 SkPictureRecorder recorder; | 273 SkPictureRecorder recorder; |
273 SkRecordDraw(src, | 274 SkRecordDraw(src, |
274 recorder.DEPRECATED_beginRecording(cullRect.width(), cullRect.h
eight()), | 275 recorder.DEPRECATED_beginRecording(cullRect.width(), cullRect.h
eight()), |
275 NULL/*bbh*/, NULL/*callback*/); | 276 NULL/*bbh*/, NULL/*callback*/); |
276 return recorder.endRecording(); | 277 return recorder.endRecording(); |
277 } | 278 } |
278 | 279 |
279 // fRecord OK | 280 // fRecord OK |
280 SkPicture::~SkPicture() { | 281 SkPicture::~SkPicture() { |
281 this->callDeletionListeners(); | 282 this->callDeletionListeners(); |
282 } | 283 } |
283 | 284 |
284 // fRecord OK | 285 // fRecord OK |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 , fCullWidth(width) | 454 , fCullWidth(width) |
454 , fCullHeight(height) | 455 , fCullHeight(height) |
455 , fAnalysis() { | 456 , fAnalysis() { |
456 this->needsNewGenID(); | 457 this->needsNewGenID(); |
457 } | 458 } |
458 | 459 |
459 SkPicture* SkPicture::Forwardport(const SkPicture& src) { | 460 SkPicture* SkPicture::Forwardport(const SkPicture& src) { |
460 SkAutoTDelete<SkRecord> record(SkNEW(SkRecord)); | 461 SkAutoTDelete<SkRecord> record(SkNEW(SkRecord)); |
461 SkRecorder canvas(record.get(), src.cullRect().width(), src.cullRect().heigh
t()); | 462 SkRecorder canvas(record.get(), src.cullRect().width(), src.cullRect().heigh
t()); |
462 src.playback(&canvas); | 463 src.playback(&canvas); |
463 return SkNEW_ARGS(SkPicture, (src.cullRect().width(), src.cullRect().height(
), | 464 return SkNEW_ARGS(SkPicture, (src.cullRect().width(), src.cullRect().height(
), |
464 record.detach(), NULL/*bbh*/)); | 465 record.detach(), NULL/*bbh*/)); |
465 } | 466 } |
466 | 467 |
467 // fRecord OK | 468 // fRecord OK |
468 SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc pro
c) { | 469 SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc pro
c) { |
469 SkPictInfo info; | 470 SkPictInfo info; |
470 | 471 |
471 if (!InternalOnly_StreamIsSKP(stream, &info)) { | 472 if (!InternalOnly_StreamIsSKP(stream, &info)) { |
472 return NULL; | 473 return NULL; |
473 } | 474 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 return fUniqueID; | 639 return fUniqueID; |
639 } | 640 } |
640 | 641 |
641 // fRecord OK | 642 // fRecord OK |
642 SkPicture::SkPicture(SkScalar width, SkScalar height, SkRecord* record, SkBBoxHi
erarchy* bbh) | 643 SkPicture::SkPicture(SkScalar width, SkScalar height, SkRecord* record, SkBBoxHi
erarchy* bbh) |
643 : fCullWidth(width) | 644 : fCullWidth(width) |
644 , fCullHeight(height) | 645 , fCullHeight(height) |
645 , fRecord(record) | 646 , fRecord(record) |
646 , fBBH(SkSafeRef(bbh)) | 647 , fBBH(SkSafeRef(bbh)) |
647 , fAnalysis(*record) { | 648 , fAnalysis(*record) { |
| 649 // TODO: move optimization before we construct fAnalysis? |
| 650 SkRecordOptimize(record); |
648 // TODO: delay as much of this work until just before first playback? | 651 // TODO: delay as much of this work until just before first playback? |
649 if (fBBH.get()) { | 652 if (fBBH.get()) { |
650 SkRecordFillBounds(*record, fBBH.get()); | 653 SkRecordFillBounds(*record, fBBH.get()); |
651 } | 654 } |
652 this->needsNewGenID(); | 655 this->needsNewGenID(); |
653 } | 656 } |
654 | 657 |
655 // Note that we are assuming that this entry point will only be called from | 658 // Note that we are assuming that this entry point will only be called from |
656 // one thread. Currently the only client of this method is | 659 // one thread. Currently the only client of this method is |
657 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single | 660 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single |
(...skipping 16 matching lines...) Expand all Loading... |
674 int SkPicture::approximateOpCount() const { | 677 int SkPicture::approximateOpCount() const { |
675 SkASSERT(fRecord.get() || fData.get()); | 678 SkASSERT(fRecord.get() || fData.get()); |
676 if (fRecord.get()) { | 679 if (fRecord.get()) { |
677 return fRecord->count(); | 680 return fRecord->count(); |
678 } | 681 } |
679 if (fData.get()) { | 682 if (fData.get()) { |
680 return fData->opCount(); | 683 return fData->opCount(); |
681 } | 684 } |
682 return 0; | 685 return 0; |
683 } | 686 } |
OLD | NEW |