| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 | 9 |
| 10 #include "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Regression test for leaking refs held by optional arguments. | 53 // Regression test for leaking refs held by optional arguments. |
| 54 DEF_TEST(Recorder_RefLeaking, r) { | 54 DEF_TEST(Recorder_RefLeaking, r) { |
| 55 // We use SaveLayer to test: | 55 // We use SaveLayer to test: |
| 56 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. | 56 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. |
| 57 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. | 57 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. |
| 58 | 58 |
| 59 SkRect bounds = SkRect::MakeWH(320, 240); | 59 SkRect bounds = SkRect::MakeWH(320, 240); |
| 60 SkPaint paint; | 60 SkPaint paint; |
| 61 paint.setShader(SkShader::CreateEmptyShader())->unref(); | 61 paint.setShader(SkShader::MakeEmptyShader()); |
| 62 | 62 |
| 63 REPORTER_ASSERT(r, paint.getShader()->unique()); | 63 REPORTER_ASSERT(r, paint.getShader()->unique()); |
| 64 { | 64 { |
| 65 SkRecord record; | 65 SkRecord record; |
| 66 SkRecorder recorder(&record, 1920, 1080); | 66 SkRecorder recorder(&record, 1920, 1080); |
| 67 recorder.saveLayer(&bounds, &paint); | 67 recorder.saveLayer(&bounds, &paint); |
| 68 REPORTER_ASSERT(r, !paint.getShader()->unique()); | 68 REPORTER_ASSERT(r, !paint.getShader()->unique()); |
| 69 } | 69 } |
| 70 REPORTER_ASSERT(r, paint.getShader()->unique()); | 70 REPORTER_ASSERT(r, paint.getShader()->unique()); |
| 71 } | 71 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 101 recorder.drawImageRect(image.get(), SkRect::MakeWH(100, 100), nullptr); | 101 recorder.drawImageRect(image.get(), SkRect::MakeWH(100, 100), nullptr); |
| 102 REPORTER_ASSERT(reporter, !image->unique()); | 102 REPORTER_ASSERT(reporter, !image->unique()); |
| 103 | 103 |
| 104 Tally tally; | 104 Tally tally; |
| 105 tally.apply(record); | 105 tally.apply(record); |
| 106 | 106 |
| 107 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); | 107 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); |
| 108 } | 108 } |
| 109 REPORTER_ASSERT(reporter, image->unique()); | 109 REPORTER_ASSERT(reporter, image->unique()); |
| 110 } | 110 } |
| OLD | NEW |