| 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 22 matching lines...) Expand all Loading... |
| 33 record.visit<void>(i, *this); | 33 record.visit<void>(i, *this); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 int fHistogram[kRecordTypes]; | 38 int fHistogram[kRecordTypes]; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 DEF_TEST(Recorder, r) { | 41 DEF_TEST(Recorder, r) { |
| 42 SkRecord record; | 42 SkRecord record; |
| 43 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080); | 43 SkRecorder recorder(&record, 1920, 1080); |
| 44 | 44 |
| 45 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); | 45 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); |
| 46 | 46 |
| 47 Tally tally; | 47 Tally tally; |
| 48 tally.apply(record); | 48 tally.apply(record); |
| 49 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); | 49 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Regression test for leaking refs held by optional arguments. | 52 // Regression test for leaking refs held by optional arguments. |
| 53 DEF_TEST(Recorder_RefLeaking, r) { | 53 DEF_TEST(Recorder_RefLeaking, r) { |
| 54 // We use SaveLayer to test: | 54 // We use SaveLayer to test: |
| 55 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. | 55 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. |
| 56 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. | 56 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. |
| 57 | 57 |
| 58 SkRect bounds = SkRect::MakeWH(320, 240); | 58 SkRect bounds = SkRect::MakeWH(320, 240); |
| 59 SkPaint paint; | 59 SkPaint paint; |
| 60 paint.setShader(SkNEW(SkEmptyShader))->unref(); | 60 paint.setShader(SkNEW(SkEmptyShader))->unref(); |
| 61 | 61 |
| 62 REPORTER_ASSERT(r, paint.getShader()->unique()); | 62 REPORTER_ASSERT(r, paint.getShader()->unique()); |
| 63 { | 63 { |
| 64 SkRecord record; | 64 SkRecord record; |
| 65 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080); | 65 SkRecorder recorder(&record, 1920, 1080); |
| 66 recorder.saveLayer(&bounds, &paint); | 66 recorder.saveLayer(&bounds, &paint); |
| 67 REPORTER_ASSERT(r, !paint.getShader()->unique()); | 67 REPORTER_ASSERT(r, !paint.getShader()->unique()); |
| 68 } | 68 } |
| 69 REPORTER_ASSERT(r, paint.getShader()->unique()); | 69 REPORTER_ASSERT(r, paint.getShader()->unique()); |
| 70 } | 70 } |
| OLD | NEW |