aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/RecorderTest.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-08-07 12:19:50 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-07 12:19:50 -0700
commit2347b624678fedf1d2f7ab1d79b9ad70087c3392 (patch)
tree65258856cf934ede815421a36a2b64ecc10b45e4 /tests/RecorderTest.cpp
parente73cd5ab0f693ae0c81f5f1ca76045363b6f999d (diff)
change drawPicture in SkRecord to just ref the picture
also fix some int/unsigned/size_t warnings BUG=skia: R=mtklein@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/449933002
Diffstat (limited to 'tests/RecorderTest.cpp')
-rw-r--r--tests/RecorderTest.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
index 5fcac4d93e..1ca9206b47 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());
+}