зеркало из https://github.com/mozilla/moz-skia.git
add some debugging to SkNVRefCnt
BUG=skia: Review URL: https://codereview.chromium.org/745383003
This commit is contained in:
Родитель
9891317557
Коммит
90d0ff013b
|
@ -210,10 +210,10 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
BBH fBBH;
|
||||
Mode fMode;
|
||||
SkString fName;
|
||||
SkAutoTDelete<SkPicture> fPic;
|
||||
BBH fBBH;
|
||||
Mode fMode;
|
||||
SkString fName;
|
||||
SkAutoTUnref<SkPicture> fPic;
|
||||
};
|
||||
|
||||
DEF_BENCH( return new TiledPlaybackBench(kNone, kRandom); )
|
||||
|
|
|
@ -37,6 +37,6 @@ void RecordingBench::onDraw(const int loops, SkCanvas*) {
|
|||
SkPictureRecorder recorder;
|
||||
fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : NULL,
|
||||
SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag));
|
||||
SkDELETE(recorder.endRecording());
|
||||
SkSafeUnref(recorder.endRecording());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,10 +261,23 @@ public:
|
|||
|
||||
bool unique() const { return 1 == sk_acquire_load(&fRefCnt); }
|
||||
void ref() const { sk_atomic_inc(&fRefCnt); }
|
||||
void unref() const { if (1 == sk_atomic_dec(&fRefCnt)) { SkDELETE((const Derived*)this); } }
|
||||
void unref() const {
|
||||
int32_t prevValue = sk_atomic_dec(&fRefCnt);
|
||||
SkASSERT(prevValue >= 1);
|
||||
if (1 == prevValue) {
|
||||
SkDELETE((const Derived*)this);
|
||||
}
|
||||
}
|
||||
void deref() const { this->unref(); } // Chrome prefers to call deref().
|
||||
int32_t getRefCnt() const { return fRefCnt; } // Used by Chrome unit tests.
|
||||
|
||||
protected:
|
||||
#ifdef SK_DEBUG
|
||||
~SkNVRefCnt() {
|
||||
SkASSERTF(0 == fRefCnt, "NVRefCnt was %d", fRefCnt);
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
mutable int32_t fRefCnt;
|
||||
};
|
||||
|
|
|
@ -109,13 +109,13 @@ static void test_clear(skiatest::Reporter* r, SkBBHFactory* factory) {
|
|||
// A picture that's just clear().
|
||||
src.beginRecording(1,1, factory)
|
||||
->clear(SK_ColorGREEN);
|
||||
SkAutoTDelete<SkPicture> srcPic(src.endRecording());
|
||||
SkAutoTUnref<SkPicture> srcPic(src.endRecording());
|
||||
|
||||
// A target canvas with an empty clip.
|
||||
SkCanvas* c = dst.beginRecording(1,1, NULL);
|
||||
c->clipRect(SkRect::MakeEmpty());
|
||||
srcPic->playback(c);
|
||||
SkAutoTDelete<SkPicture> dstPic(dst.endRecording());
|
||||
SkAutoTUnref<SkPicture> dstPic(dst.endRecording());
|
||||
|
||||
// Should be Clip - Save - Clear - Restore.
|
||||
// Buggy implementations might return 1 (just Clip) or 3 (Clip - Save - Restore).
|
||||
|
|
|
@ -1909,7 +1909,7 @@ DEF_TEST(Picture_BitmapLeak, r) {
|
|||
SkCanvas* canvas = rec.beginRecording(1920, 1200);
|
||||
canvas->drawBitmap(mut, 0, 0);
|
||||
canvas->drawBitmap(immut, 800, 600);
|
||||
SkAutoTDelete<const SkPicture> pic(rec.endRecording());
|
||||
SkAutoTUnref<const SkPicture> pic(rec.endRecording());
|
||||
|
||||
// The picture shares the immutable pixels but copies the mutable ones.
|
||||
REPORTER_ASSERT(r, mut.pixelRef()->unique());
|
||||
|
|
|
@ -115,7 +115,7 @@ class PictureStrategy : public RecordingStrategy {
|
|||
SkIntToScalar(fHeight),
|
||||
&factory);
|
||||
drawer.draw(canvas, canvasRect, mode);
|
||||
SkAutoTDelete<SkPicture> picture(recorder.endRecording());
|
||||
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
|
||||
|
||||
SkCanvas replayCanvas(fBitmap);
|
||||
replayCanvas.clear(0xffffffff);
|
||||
|
|
|
@ -661,7 +661,7 @@ struct OptTableEntry {
|
|||
|
||||
|
||||
static int filter_picture(const SkString& inFile, const SkString& outFile) {
|
||||
SkAutoTDelete<SkPicture> inPicture;
|
||||
SkAutoTUnref<SkPicture> inPicture;
|
||||
|
||||
SkFILEStream inStream(inFile.c_str());
|
||||
if (inStream.isValid()) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче