Index: tests/RecorderTest.cpp |
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp |
index 5fcac4d93e7e4c3e23cd57b2b4a9d0c116259773..1ca9206b474dd9afdcd2564401af89be9986f847 100644 |
--- a/tests/RecorderTest.cpp |
+++ b/tests/RecorderTest.cpp |
@@ -7,6 +7,7 @@ |
#include "Test.h" |
+#include "SkPictureRecorder.h" |
#include "SkRecord.h" |
#include "SkRecorder.h" |
#include "SkRecords.h" |
@@ -67,3 +68,25 @@ DEF_TEST(Recorder_RefLeaking, r) { |
} |
REPORTER_ASSERT(r, paint.getShader()->unique()); |
} |
+ |
+DEF_TEST(Recorder_RefPictures, r) { |
+ SkAutoTUnref<SkPicture> pic; |
+ |
+ { |
+ SkPictureRecorder pr; |
+ SkCanvas* canvas = pr.beginRecording(100, 100); |
+ canvas->drawColor(SK_ColorRED); |
+ pic.reset(pr.endRecording()); |
+ } |
+ REPORTER_ASSERT(r, pic->unique()); |
+ |
+ { |
+ SkRecord record; |
+ SkRecorder recorder(&record, 100, 100); |
+ recorder.drawPicture(pic); |
+ // the recorder should now also be an owner |
+ REPORTER_ASSERT(r, !pic->unique()); |
+ } |
+ // the recorder destructor should have released us (back to unique) |
+ REPORTER_ASSERT(r, pic->unique()); |
+} |