| 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 "SkRecord.h" | 11 #include "SkRecord.h" |
| 11 #include "SkRecorder.h" | 12 #include "SkRecorder.h" |
| 12 #include "SkRecords.h" | 13 #include "SkRecords.h" |
| 13 #include "SkShader.h" | 14 #include "SkShader.h" |
| 14 | 15 |
| 15 #define COUNT(T) + 1 | 16 #define COUNT(T) + 1 |
| 16 static const int kRecordTypes = SK_RECORD_TYPES(COUNT); | 17 static const int kRecordTypes = SK_RECORD_TYPES(COUNT); |
| 17 #undef COUNT | 18 #undef COUNT |
| 18 | 19 |
| 19 // Tallies the types of commands it sees into a histogram. | 20 // Tallies the types of commands it sees into a histogram. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 61 |
| 61 REPORTER_ASSERT(r, paint.getShader()->unique()); | 62 REPORTER_ASSERT(r, paint.getShader()->unique()); |
| 62 { | 63 { |
| 63 SkRecord record; | 64 SkRecord record; |
| 64 SkRecorder recorder(&record, 1920, 1080); | 65 SkRecorder recorder(&record, 1920, 1080); |
| 65 recorder.saveLayer(&bounds, &paint); | 66 recorder.saveLayer(&bounds, &paint); |
| 66 REPORTER_ASSERT(r, !paint.getShader()->unique()); | 67 REPORTER_ASSERT(r, !paint.getShader()->unique()); |
| 67 } | 68 } |
| 68 REPORTER_ASSERT(r, paint.getShader()->unique()); | 69 REPORTER_ASSERT(r, paint.getShader()->unique()); |
| 69 } | 70 } |
| 71 |
| 72 DEF_TEST(Recorder_RefPictures, r) { |
| 73 SkAutoTUnref<SkPicture> pic; |
| 74 |
| 75 { |
| 76 SkPictureRecorder pr; |
| 77 SkCanvas* canvas = pr.beginRecording(100, 100); |
| 78 canvas->drawColor(SK_ColorRED); |
| 79 pic.reset(pr.endRecording()); |
| 80 } |
| 81 REPORTER_ASSERT(r, pic->unique()); |
| 82 |
| 83 { |
| 84 SkRecord record; |
| 85 SkRecorder recorder(&record, 100, 100); |
| 86 recorder.drawPicture(pic); |
| 87 // the recorder should now also be an owner |
| 88 REPORTER_ASSERT(r, !pic->unique()); |
| 89 } |
| 90 // the recorder destructor should have released us (back to unique) |
| 91 REPORTER_ASSERT(r, pic->unique()); |
| 92 } |
| OLD | NEW |