Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(852)

Unified Diff: tests/RecorderTest.cpp

Issue 235983015: SkRecord bug fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tomments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/record/SkRecords.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecorderTest.cpp
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
index 34b3f2c0de26b85bd724010f90627d6463e799ee..570bce8a3c299119e4306e5ca114286a78d992e4 100644
--- a/tests/RecorderTest.cpp
+++ b/tests/RecorderTest.cpp
@@ -11,6 +11,8 @@
#include "SkRecorder.h"
#include "SkRecords.h"
+#include "SkEmptyShader.h"
+
#define COUNT(T) + 1
static const int kRecordTypes = SK_RECORD_TYPES(COUNT);
#undef COUNT
@@ -41,3 +43,23 @@ DEF_TEST(Recorder, r) {
REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>());
}
+
+// Regression test for leaking refs held by optional arguments.
+DEF_TEST(Recorder_RefLeaking, r) {
+ // We use SaveLayer to test:
+ // - its SkRect argument is optional and SkRect is POD. Just testing that that works.
+ // - its SkPaint argument is optional and SkPaint is not POD. The bug was here.
+
+ SkRect bounds;
+ SkPaint paint;
+ paint.setShader(SkNEW(SkEmptyShader))->unref();
+
+ REPORTER_ASSERT(r, paint.getShader()->unique());
+ {
+ SkRecord record;
+ SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080);
+ recorder.saveLayer(&bounds, &paint);
+ REPORTER_ASSERT(r, !paint.getShader()->unique());
+ }
+ REPORTER_ASSERT(r, paint.getShader()->unique());
+}
« no previous file with comments | « src/record/SkRecords.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698