Straighten out SkPicture::AccelData APIs.
Must have been we needed them to be weird (mutable, const setter) before. It doesn't look like that's necessary now... we can just pass it to the constructor. BUG=skia: Review URL: https://codereview.chromium.org/1112833003
This commit is contained in:
parent
c64239a466
commit
2420e10d5a
@ -41,8 +41,7 @@ namespace SkRecords {
|
||||
*/
|
||||
class SK_API SkPicture : public SkNVRefCnt<SkPicture> {
|
||||
public:
|
||||
// AccelData provides a base class for device-specific acceleration
|
||||
// data. It is added to the picture via EXPERIMENTAL_addAccelData.
|
||||
// AccelData provides a base class for device-specific acceleration data.
|
||||
class AccelData : public SkRefCnt {
|
||||
public:
|
||||
typedef uint8_t Domain;
|
||||
@ -59,9 +58,6 @@ public:
|
||||
Key fKey;
|
||||
};
|
||||
|
||||
/** PRIVATE / EXPERIMENTAL -- do not call */
|
||||
void EXPERIMENTAL_addAccelData(const AccelData*) const;
|
||||
|
||||
/** PRIVATE / EXPERIMENTAL -- do not call */
|
||||
const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key) const;
|
||||
|
||||
@ -260,11 +256,12 @@ private:
|
||||
static bool IsValidPictInfo(const SkPictInfo& info);
|
||||
|
||||
// Takes ownership of the (optional) SnapshotArray.
|
||||
// For performance, we take ownership of the caller's refs on the SkRecord and BBH.
|
||||
// For performance, we take ownership of the caller's refs on the SkRecord, BBH, and AccelData.
|
||||
SkPicture(const SkRect& cullRect,
|
||||
SkRecord*,
|
||||
SnapshotArray*,
|
||||
SkBBoxHierarchy*,
|
||||
AccelData*,
|
||||
size_t approxBytesUsedBySubPictures);
|
||||
|
||||
static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*);
|
||||
@ -274,10 +271,10 @@ private:
|
||||
// uint32_t fRefCnt; from SkNVRefCnt<SkPicture>
|
||||
mutable uint32_t fUniqueID;
|
||||
const SkRect fCullRect;
|
||||
mutable SkAutoTUnref<const AccelData> fAccelData;
|
||||
SkAutoTUnref<const SkRecord> fRecord;
|
||||
SkAutoTUnref<const SkBBoxHierarchy> fBBH;
|
||||
SkAutoTDelete<const SnapshotArray> fDrawablePicts;
|
||||
SkAutoTUnref<const SkBBoxHierarchy> fBBH;
|
||||
SkAutoTUnref<const AccelData> fAccelData;
|
||||
const size_t fApproxBytesUsedBySubPictures;
|
||||
|
||||
// helpers for fDrawablePicts
|
||||
|
@ -241,10 +241,6 @@ SkPicture::~SkPicture() {
|
||||
}
|
||||
}
|
||||
|
||||
void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) const {
|
||||
fAccelData.reset(SkRef(data));
|
||||
}
|
||||
|
||||
const SkPicture::AccelData* SkPicture::EXPERIMENTAL_getAccelData(
|
||||
SkPicture::AccelData::Key key) const {
|
||||
if (fAccelData.get() && fAccelData->getKey() == key) {
|
||||
@ -452,13 +448,18 @@ bool SkPicture::hasText() const { return fAnalysis.fHasText; }
|
||||
bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitmaps; }
|
||||
int SkPicture::approximateOpCount() const { return fRecord->count(); }
|
||||
|
||||
SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* drawablePicts,
|
||||
SkBBoxHierarchy* bbh, size_t approxBytesUsedBySubPictures)
|
||||
SkPicture::SkPicture(const SkRect& cullRect,
|
||||
SkRecord* record,
|
||||
SnapshotArray* drawablePicts,
|
||||
SkBBoxHierarchy* bbh,
|
||||
AccelData* accelData,
|
||||
size_t approxBytesUsedBySubPictures)
|
||||
: fUniqueID(0)
|
||||
, fCullRect(cullRect)
|
||||
, fRecord(record) // For performance, we take ownership of the caller's ref.
|
||||
, fBBH(bbh) // Ditto.
|
||||
, fDrawablePicts(drawablePicts) // take ownership
|
||||
, fRecord(record) // Take ownership of caller's ref.
|
||||
, fDrawablePicts(drawablePicts) // Take ownership.
|
||||
, fBBH(bbh) // Take ownership of caller's ref.
|
||||
, fAccelData(accelData) // Take ownership of caller's ref.
|
||||
, fApproxBytesUsedBySubPictures(approxBytesUsedBySubPictures)
|
||||
, fAnalysis(*fRecord)
|
||||
{}
|
||||
|
@ -77,14 +77,12 @@ SkPicture* SkPictureRecorder::endRecordingAsPicture() {
|
||||
for (int i = 0; pictList && i < pictList->count(); i++) {
|
||||
subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin()[i]);
|
||||
}
|
||||
SkPicture* pict = SkNEW_ARGS(SkPicture,
|
||||
(fCullRect, fRecord.detach(), pictList, fBBH.detach(), subPictureBytes));
|
||||
|
||||
if (saveLayerData) {
|
||||
pict->EXPERIMENTAL_addAccelData(saveLayerData);
|
||||
}
|
||||
|
||||
return pict;
|
||||
return SkNEW_ARGS(SkPicture, (fCullRect,
|
||||
fRecord.detach(),
|
||||
pictList,
|
||||
fBBH.detach(),
|
||||
saveLayerData.detach(),
|
||||
subPictureBytes));
|
||||
}
|
||||
|
||||
void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
|
||||
@ -161,13 +159,12 @@ protected:
|
||||
}
|
||||
// SkPicture 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.
|
||||
SkPicture* pict = SkNEW_ARGS(SkPicture,
|
||||
(fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(fBBH.get()), subPictureBytes));
|
||||
|
||||
if (saveLayerData) {
|
||||
pict->EXPERIMENTAL_addAccelData(saveLayerData);
|
||||
}
|
||||
return pict;
|
||||
return SkNEW_ARGS(SkPicture, (fBounds,
|
||||
SkRef(fRecord.get()),
|
||||
pictList,
|
||||
SkSafeRef(fBBH.get()),
|
||||
saveLayerData.detach(),
|
||||
subPictureBytes));
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user