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 "SkRecord.h" | 10 #include "SkRecord.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); | 44 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); |
45 } | 45 } |
46 | 46 |
47 // Regression test for leaking refs held by optional arguments. | 47 // Regression test for leaking refs held by optional arguments. |
48 DEF_TEST(Recorder_RefLeaking, r) { | 48 DEF_TEST(Recorder_RefLeaking, r) { |
49 // We use SaveLayer to test: | 49 // We use SaveLayer to test: |
50 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. | 50 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. |
51 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. | 51 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. |
52 | 52 |
53 SkRect bounds; | 53 SkRect bounds = SkRect::MakeWH(320, 240); |
54 SkPaint paint; | 54 SkPaint paint; |
55 paint.setShader(SkNEW(SkEmptyShader))->unref(); | 55 paint.setShader(SkNEW(SkEmptyShader))->unref(); |
56 | 56 |
57 REPORTER_ASSERT(r, paint.getShader()->unique()); | 57 REPORTER_ASSERT(r, paint.getShader()->unique()); |
58 { | 58 { |
59 SkRecord record; | 59 SkRecord record; |
60 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080); | 60 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080); |
61 recorder.saveLayer(&bounds, &paint); | 61 recorder.saveLayer(&bounds, &paint); |
62 REPORTER_ASSERT(r, !paint.getShader()->unique()); | 62 REPORTER_ASSERT(r, !paint.getShader()->unique()); |
63 } | 63 } |
64 REPORTER_ASSERT(r, paint.getShader()->unique()); | 64 REPORTER_ASSERT(r, paint.getShader()->unique()); |
65 } | 65 } |
OLD | NEW |