Revert "remove approxbytes api from SkPicture"
This reverts commit bfc11853a8
.
Bug: skia:
Change-Id: Ied4baad0496a06a52bec6965f9c97e13ebe2ab0a
Reviewed-on: https://skia-review.googlesource.com/89442
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
0a9d728851
commit
7557bbbe19
@ -738,6 +738,7 @@ public:
|
||||
SkString name = SkOSPath::Basename(path.c_str());
|
||||
fSourceType = "skp";
|
||||
fBenchType = "recording";
|
||||
fSKPBytes = static_cast<double>(pic->approximateBytesUsed());
|
||||
fSKPOps = pic->approximateOpCount();
|
||||
return new RecordingBench(name.c_str(), pic.get(), FLAGS_bbh, FLAGS_lite);
|
||||
}
|
||||
@ -752,6 +753,7 @@ public:
|
||||
SkString name = SkOSPath::Basename(path.c_str());
|
||||
fSourceType = "skp";
|
||||
fBenchType = "piping";
|
||||
fSKPBytes = static_cast<double>(pic->approximateBytesUsed());
|
||||
fSKPOps = pic->approximateOpCount();
|
||||
return new PipingBench(name.c_str(), pic.get());
|
||||
}
|
||||
@ -766,6 +768,7 @@ public:
|
||||
SkString name = SkOSPath::Basename(path.c_str());
|
||||
fSourceType = "skp";
|
||||
fBenchType = "deserial";
|
||||
fSKPBytes = static_cast<double>(data->size());
|
||||
fSKPOps = 0;
|
||||
return new DeserializePictureBench(name.c_str(), std::move(data));
|
||||
}
|
||||
@ -1059,6 +1062,7 @@ public:
|
||||
}
|
||||
}
|
||||
if (0 == strcmp(fBenchType, "recording")) {
|
||||
log->metric("bytes", fSKPBytes);
|
||||
log->metric("ops", fSKPOps);
|
||||
}
|
||||
}
|
||||
@ -1089,7 +1093,7 @@ private:
|
||||
SkScalar fZoomMax;
|
||||
double fZoomPeriodMs;
|
||||
|
||||
double fSKPOps;
|
||||
double fSKPBytes, fSKPOps;
|
||||
|
||||
const char* fSourceType; // What we're benching: bench, GM, SKP, ...
|
||||
const char* fBenchType; // How we bench it: micro, recording, playback, ...
|
||||
|
@ -102,6 +102,9 @@ public:
|
||||
*/
|
||||
virtual int approximateOpCount() const = 0;
|
||||
|
||||
/** Returns the approximate byte size of this picture, not including large ref'd objects. */
|
||||
virtual size_t approximateBytesUsed() const = 0;
|
||||
|
||||
// Returns NULL if this is not an SkBigPicture.
|
||||
virtual const SkBigPicture* asSkBigPicture() const { return nullptr; }
|
||||
|
||||
|
@ -15,8 +15,10 @@
|
||||
SkBigPicture::SkBigPicture(const SkRect& cull,
|
||||
SkRecord* record,
|
||||
SnapshotArray* drawablePicts,
|
||||
SkBBoxHierarchy* bbh)
|
||||
SkBBoxHierarchy* bbh,
|
||||
size_t approxBytesUsedBySubPictures)
|
||||
: fCullRect(cull)
|
||||
, fApproxBytesUsedBySubPictures(approxBytesUsedBySubPictures)
|
||||
, fRecord(record) // Take ownership of caller's ref.
|
||||
, fDrawablePicts(drawablePicts) // Take ownership.
|
||||
, fBBH(bbh) // Take ownership of caller's ref.
|
||||
@ -52,7 +54,12 @@ void SkBigPicture::partialPlayback(SkCanvas* canvas,
|
||||
}
|
||||
|
||||
SkRect SkBigPicture::cullRect() const { return fCullRect; }
|
||||
int SkBigPicture::approximateOpCount() const { return fRecord->count(); }
|
||||
int SkBigPicture::approximateOpCount() const { return fRecord->count(); }
|
||||
size_t SkBigPicture::approximateBytesUsed() const {
|
||||
size_t bytes = sizeof(*this) + fRecord->bytesUsed() + fApproxBytesUsedBySubPictures;
|
||||
if (fBBH) { bytes += fBBH->bytesUsed(); }
|
||||
return bytes;
|
||||
}
|
||||
|
||||
int SkBigPicture::drawableCount() const {
|
||||
return fDrawablePicts ? fDrawablePicts->count() : 0;
|
||||
|
@ -36,13 +36,15 @@ public:
|
||||
SkBigPicture(const SkRect& cull,
|
||||
SkRecord*, // We take ownership of the caller's ref.
|
||||
SnapshotArray*, // We take exclusive ownership.
|
||||
SkBBoxHierarchy*); // We take ownership of the caller's ref.
|
||||
SkBBoxHierarchy*, // We take ownership of the caller's ref.
|
||||
size_t approxBytesUsedBySubPictures);
|
||||
|
||||
|
||||
// SkPicture overrides
|
||||
void playback(SkCanvas*, AbortCallback*) const override;
|
||||
SkRect cullRect() const override;
|
||||
int approximateOpCount() const override;
|
||||
size_t approximateBytesUsed() const override;
|
||||
const SkBigPicture* asSkBigPicture() const override { return this; }
|
||||
|
||||
// Used by GrLayerHoister
|
||||
@ -59,6 +61,7 @@ private:
|
||||
SkPicture const* const* drawablePicts() const;
|
||||
|
||||
const SkRect fCullRect;
|
||||
const size_t fApproxBytesUsedBySubPictures;
|
||||
sk_sp<const SkRecord> fRecord;
|
||||
std::unique_ptr<const SnapshotArray> fDrawablePicts;
|
||||
sk_sp<const SkBBoxHierarchy> fBBH;
|
||||
|
@ -20,6 +20,7 @@ class SkEmptyPicture final : public SkPicture {
|
||||
public:
|
||||
void playback(SkCanvas*, AbortCallback*) const override { }
|
||||
|
||||
size_t approximateBytesUsed() const override { return sizeof(*this); }
|
||||
int approximateOpCount() const override { return 0; }
|
||||
SkRect cullRect() const override { return SkRect::MakeEmpty(); }
|
||||
};
|
||||
@ -52,6 +53,7 @@ public:
|
||||
SkRecords::Draw(c, nullptr, nullptr, 0, nullptr)(fOp);
|
||||
}
|
||||
|
||||
size_t approximateBytesUsed() const override { return sizeof(*this); }
|
||||
int approximateOpCount() const override { return 1; }
|
||||
SkRect cullRect() const override { return fCull; }
|
||||
|
||||
|
@ -83,7 +83,12 @@ sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPicture(uint32_t finishFlag
|
||||
fCullRect = bbhBound;
|
||||
}
|
||||
|
||||
return sk_make_sp<SkBigPicture>(fCullRect, fRecord.release(), pictList, fBBH.release());
|
||||
size_t subPictureBytes = fRecorder->approxBytesUsedBySubPictures();
|
||||
for (int i = 0; pictList && i < pictList->count(); i++) {
|
||||
subPictureBytes += pictList->begin()[i]->approximateBytesUsed();
|
||||
}
|
||||
return sk_make_sp<SkBigPicture>(fCullRect, fRecord.release(), pictList, fBBH.release(),
|
||||
subPictureBytes);
|
||||
}
|
||||
|
||||
sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPictureWithCull(const SkRect& cullRect,
|
||||
|
@ -31,9 +31,14 @@ SkPicture* SkRecordedDrawable::onNewPictureSnapshot() {
|
||||
pictList = fDrawableList->newDrawableSnapshot();
|
||||
}
|
||||
|
||||
size_t subPictureBytes = 0;
|
||||
for (int i = 0; pictList && i < pictList->count(); i++) {
|
||||
subPictureBytes += pictList->begin()[i]->approximateBytesUsed();
|
||||
}
|
||||
// SkBigPicture will take ownership of a ref on both fRecord and fBBH.
|
||||
// We're not willing to give up our ownership, so we must ref them for SkPicture.
|
||||
return new SkBigPicture(fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(fBBH.get()));
|
||||
return new SkBigPicture(fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(fBBH.get()),
|
||||
subPictureBytes);
|
||||
}
|
||||
|
||||
void SkRecordedDrawable::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -302,6 +302,7 @@ void SkRecorder::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
|
||||
void SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) {
|
||||
if (fDrawPictureMode == Record_DrawPictureMode) {
|
||||
fApproxBytesUsedBySubPictures += pic->approximateBytesUsed();
|
||||
APPEND(DrawPicture, this->copy(paint), sk_ref_sp(pic), matrix ? *matrix : SkMatrix::I());
|
||||
} else {
|
||||
SkASSERT(fDrawPictureMode == Playback_DrawPictureMode);
|
||||
|
Loading…
Reference in New Issue
Block a user