| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 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 #include "SkBBoxHierarchy.h" | 8 #include "SkBBoxHierarchy.h" |
| 9 #include "SkBigPicture.h" | 9 #include "SkBigPicture.h" |
| 10 #include "SkPictureCommon.h" | 10 #include "SkPictureCommon.h" |
| 11 #include "SkRecord.h" | 11 #include "SkRecord.h" |
| 12 #include "SkRecordDraw.h" | 12 #include "SkRecordDraw.h" |
| 13 #include "SkTraceEvent.h" | 13 #include "SkTraceEvent.h" |
| 14 #include <iostream> |
| 14 | 15 |
| 15 SkBigPicture::SkBigPicture(const SkRect& cull, | 16 SkBigPicture::SkBigPicture(const SkRect& cull, |
| 16 SkRecord* record, | 17 SkRecord* record, |
| 17 SnapshotArray* drawablePicts, | 18 SnapshotArray* drawablePicts, |
| 18 SkBBoxHierarchy* bbh, | 19 SkBBoxHierarchy* bbh, |
| 19 AccelData* accelData, | 20 AccelData* accelData, |
| 20 size_t approxBytesUsedBySubPictures) | 21 size_t approxBytesUsedBySubPictures) |
| 21 : fCullRect(cull) | 22 : fCullRect(cull) |
| 22 , fApproxBytesUsedBySubPictures(approxBytesUsedBySubPictures) | 23 , fApproxBytesUsedBySubPictures(approxBytesUsedBySubPictures) |
| 23 , fRecord(record) // Take ownership of caller's ref. | 24 , fRecord(record) // Take ownership of caller's ref. |
| 24 , fDrawablePicts(drawablePicts) // Take ownership. | 25 , fDrawablePicts(drawablePicts) // Take ownership. |
| 25 , fBBH(bbh) // Take ownership of caller's ref. | 26 , fBBH(bbh) // Take ownership of caller's ref. |
| 26 , fAccelData(accelData) // Take ownership of caller's ref. | 27 , fAccelData(accelData) // Take ownership of caller's ref. |
| 27 {} | 28 {} |
| 28 | 29 |
| 29 void SkBigPicture::playback(SkCanvas* canvas, AbortCallback* callback) const { | 30 void SkBigPicture::playback(SkCanvas* canvas, AbortCallback* callback) const { |
| 30 SkASSERT(canvas); | 31 SkASSERT(canvas); |
| 31 | 32 TRACE_EVENT0("pras_skia", "SkBigPicture::playback"); |
| 32 // If the query contains the whole picture, don't bother with the BBH. | 33 // If the query contains the whole picture, don't bother with the BBH. |
| 33 SkRect clipBounds = { 0, 0, 0, 0 }; | 34 SkRect clipBounds = { 0, 0, 0, 0 }; |
| 34 (void)canvas->getClipBounds(&clipBounds); | 35 (void)canvas->getClipBounds(&clipBounds); |
| 35 const bool useBBH = !clipBounds.contains(this->cullRect()); | 36 const bool useBBH = !clipBounds.contains(this->cullRect()); |
| 36 | 37 |
| 38 #if 0 |
| 37 SkRecordDraw(*fRecord, | 39 SkRecordDraw(*fRecord, |
| 38 canvas, | 40 canvas, |
| 39 this->drawablePicts(), | 41 this->drawablePicts(), |
| 40 nullptr, | 42 nullptr, |
| 41 this->drawableCount(), | 43 this->drawableCount(), |
| 42 useBBH ? fBBH.get() : nullptr, | 44 useBBH ? fBBH.get() : nullptr, |
| 43 callback); | 45 callback); |
| 46 #else |
| 47 DrawData draw_data(*fRecord, canvas, this->drawablePicts(), nullptr, |
| 48 this->drawableCount(), useBBH ? fBBH.get() : nullptr, |
| 49 callback); |
| 50 SkRecordDrawPrasInit(draw_data); |
| 51 int count = 0; |
| 52 while (!SkRecordDrawPrasDo(draw_data)) { |
| 53 count++; |
| 54 } |
| 55 // std::cout << "\nPRAS:: count = " << count; |
| 56 SkRecordDrawPrasDeInit(draw_data); |
| 57 #endif |
| 44 } | 58 } |
| 45 | 59 |
| 46 void SkBigPicture::partialPlayback(SkCanvas* canvas, | 60 void SkBigPicture::partialPlayback(SkCanvas* canvas, |
| 47 int start, | 61 int start, |
| 48 int stop, | 62 int stop, |
| 49 const SkMatrix& initialCTM) const { | 63 const SkMatrix& initialCTM) const { |
| 50 SkASSERT(canvas); | 64 SkASSERT(canvas); |
| 51 SkRecordPartialDraw(*fRecord, | 65 SkRecordPartialDraw(*fRecord, |
| 52 canvas, | 66 canvas, |
| 53 this->drawablePicts(), | 67 this->drawablePicts(), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 for (int i = 0; i < record.count(); i++) { | 104 for (int i = 0; i < record.count(); i++) { |
| 91 hasText = hasText || record.visit<bool>(i, text); | 105 hasText = hasText || record.visit<bool>(i, text); |
| 92 hasBitmap = hasBitmap || record.visit<bool>(i, bitmap); | 106 hasBitmap = hasBitmap || record.visit<bool>(i, bitmap); |
| 93 record.visit<void>(i, path); | 107 record.visit<void>(i, path); |
| 94 } | 108 } |
| 95 | 109 |
| 96 fHasText = hasText; | 110 fHasText = hasText; |
| 97 fWillPlaybackBitmaps = hasBitmap; | 111 fWillPlaybackBitmaps = hasBitmap; |
| 98 fNumSlowPathsAndDashEffects = SkTMin<int>(path.fNumSlowPathsAndDashEffects,
255); | 112 fNumSlowPathsAndDashEffects = SkTMin<int>(path.fNumSlowPathsAndDashEffects,
255); |
| 99 } | 113 } |
| OLD | NEW |